...

Source file src/github.com/redhat-developer/odo/pkg/labels/builder.go

Documentation: github.com/redhat-developer/odo/pkg/labels

     1  package labels
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"k8s.io/apimachinery/pkg/labels"
     7  )
     8  
     9  type builder struct {
    10  	m labels.Set
    11  }
    12  
    13  func Builder() builder {
    14  	return builder{
    15  		m: make(map[string]string),
    16  	}
    17  }
    18  
    19  func (o builder) Labels() map[string]string {
    20  	return o.m
    21  }
    22  
    23  func (o builder) Selector() string {
    24  	return o.m.String()
    25  }
    26  
    27  func (o builder) SelectorFlag() string {
    28  	return fmt.Sprintf("--selector=%s", o.m.String())
    29  }
    30  
    31  func (o builder) WithComponentName(name string) builder {
    32  	o.m[kubernetesInstanceLabel] = name
    33  	return o
    34  }
    35  
    36  func (o builder) WithAppName(name string) builder {
    37  	o.m[kubernetesPartOfLabel] = name
    38  	return o
    39  }
    40  
    41  func (o builder) WithApp(name string) builder {
    42  	o.m[appLabel] = name
    43  	return o
    44  }
    45  
    46  func (o builder) WithManager(manager string) builder {
    47  	o.m[kubernetesManagedByLabel] = manager
    48  	return o
    49  }
    50  
    51  func (o builder) WithProjectType(typ string) builder {
    52  	o.m[odoProjectTypeAnnotation] = typ
    53  	return o
    54  }
    55  
    56  func (o builder) WithMode(mode string) builder {
    57  	o.m[odoModeLabel] = mode
    58  	return o
    59  }
    60  
    61  func (o builder) WithSourcePVC(s string) builder {
    62  	o.m[sourcePVCLabel] = s
    63  	return o
    64  }
    65  
    66  func (o builder) WithDevfileStorageName(name string) builder {
    67  	o.m[devfileStorageLabel] = name
    68  	return o
    69  }
    70  
    71  func (o builder) WithStorageName(name string) builder {
    72  	o.m[kubernetesStorageNameLabel] = name
    73  	return o
    74  }
    75  
    76  func (o builder) WithComponent(name string) builder {
    77  	o.m[componentLabel] = name
    78  	return o
    79  }
    80  
    81  func (o builder) WithManagedByVersion(version string) builder {
    82  	o.m[kubernetesManagedByVersionLabel] = version
    83  	return o
    84  }
    85  

View as plain text