Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Operator ¶
type Operator string
Operator represents a key's relationship operator.
const ( // Exists is a special operator that checks whether a key exists. Exists Operator = "exists" // NotExist is a special operator that checks whether a key does not exist. NotExist Operator = "!" // Equals is a regular key/value matching. Equals Operator = "=" // NotEquals is a regular key/value matching. NotEquals Operator = "!=" // In is a regular key/value matching. In Operator = "in" // NotIn is a regular key/value matching. NotIn Operator = "notin" // GreaterThan is a regular key/value matching. GreaterThan Operator = ">" // LessThan is a regular key/value matching. LessThan Operator = "<" // GreaterOrEqual is a regular key/value matching. GreaterOrEqual Operator = ">=" // LessOrEqual is a regular key/value matching. LessOrEqual Operator = "<=" )
type Requirement ¶
type Requirement struct {
// contains filtered or unexported fields
}
Requirement is a single key/value pair that is used to filter
func NewRequirement ¶
func NewRequirement(key string, op Operator, vals []string) (*Requirement, error)
NewRequirement creates a new Requirement based on the provided key, operator and values. If any of these rules is violated, an error is returned when constructed. 1. The Operator must be one of the predefined constants. such as: Exists, NotExist, Equals, NotEquals, In, NotIn, GreaterThan, LessThan, GreaterOrEqual, LessOrEqual 2. For operators GreaterThan, LessThan, GreaterOrEqual, LessOrEqual, the values must be a number. 3. For operators In, NotIn, the values must not be empty. 4. For operators Exists, NotExist, the values must not be empty. 5. For operators Equals, NotEquals, the values must have exactly one entry.
func (*Requirement) Matches ¶
func (r *Requirement) Matches(labels Labels) bool
Matches checks whether the given Labels match this Requirement.
func (*Requirement) String ¶
func (r *Requirement) String() string
String converts a Requirement to a string.
type Requirements ¶
type Requirements []Requirement
Requirements is a single element selector.
func (Requirements) AddRequirement ¶
func (x Requirements) AddRequirement(r ...Requirement) Selector
AddRequirement adds new Requirement to this Selector.
func (Requirements) Matches ¶
func (x Requirements) Matches(labels Labels) bool
Matches returns true if all requirements matches the given Labels.
func (Requirements) String ¶
func (x Requirements) String() string
String converts this Selector to a string.
type Selector ¶
type Selector interface { // Matches returns true if the specified Labels match this Selector. Matches(labels Labels) bool // AddRequirement adds new Requirement to this Selector. AddRequirement(r ...Requirement) Selector }
Selector is a label selector.
type Set ¶
Set is a set of key-value pairs.
func (Set) AsSelector ¶
AsSelector converts labels into a selectors. It does not perform any validation, which means the server will reject the request if the Set contains invalid values.
func (Set) AsValidatedSelector ¶
AsValidatedSelector converts labels into a selectors. The Set is validated client-side, which allows to catch errors early.