...

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

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

     1  package labels
     2  
     3  import (
     4  	"k8s.io/apimachinery/pkg/labels"
     5  	"k8s.io/apimachinery/pkg/selection"
     6  )
     7  
     8  type selectorBuilder struct {
     9  	selector labels.Selector
    10  }
    11  
    12  func SelectorBuilder() selectorBuilder {
    13  	return selectorBuilder{
    14  		selector: labels.NewSelector(),
    15  	}
    16  }
    17  
    18  func (o selectorBuilder) WithComponent(name string) selectorBuilder {
    19  	req, err := labels.NewRequirement(componentLabel, selection.Equals, []string{name})
    20  	if err != nil {
    21  		panic(err)
    22  	}
    23  	o.selector = o.selector.Add(*req)
    24  	return o
    25  }
    26  
    27  func (o selectorBuilder) WithoutSourcePVC(s string) selectorBuilder {
    28  	req, err := labels.NewRequirement(sourcePVCLabel, selection.NotEquals, []string{s})
    29  	if err != nil {
    30  		panic(err)
    31  	}
    32  	o.selector = o.selector.Add(*req)
    33  	return o
    34  }
    35  
    36  func (o selectorBuilder) Selector() string {
    37  	return o.selector.String()
    38  }
    39  

View as plain text