Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuilderRequirement ¶
type BuilderRequirement struct {
*resourcepb.ExpressionSelectorRequirement
}
PCRequirement contains a expression, a value, and an operator that relates the field and value. the value is also an expression targeting the parent
func NewBuilderRequirement ¶
func NewBuilderRequirement(expr string, op resourcepb.Operator, vals []string) (BuilderRequirement, error)
NewRequirement is the constructor for a Requirement. If any of these rules is violated, an error is returned:
- The operator can only be Equals, DoubleEquals, Gt, Lt, NotEquals, Exists, or DoesNotExist.
- If the operator is Equals, DoubleEquals, or NotEquals, the values set must contain one value.
The empty string is a valid value in the input values set. Returned error, if not nil, is guaranteed to be an aggregated field.ErrorList
type BuilderRequirements ¶
type BuilderRequirements []BuilderRequirement
Requirements is AND of all requirements.
type Requirement ¶
type Requirement struct {
*resourcepb.ExpressionSelectorRequirement
}
Requirement contains a expression, a value, and an operator that relates the field and value. This is currently for reading internal selection information of expression selector.
func NewRequirement ¶
func NewRequirement(expr string, op resourcepb.Operator, vals []string) (Requirement, error)
NewRequirement is the constructor for a Requirement. If any of these rules is violated, an error is returned:
- The operator can only be In, NotIn, Equals, DoubleEquals, Gt, Lt, NotEquals, Exists, or DoesNotExist.
- If the operator is In or NotIn, the values set must be non-empty.
- If the operator is Equals, DoubleEquals, or NotEquals, the values set must contain one value.
- If the operator is Exists or DoesNotExist, the value set must be empty.
- If the operator is Gt or Lt, the values set must contain only one value, which will be interpreted as an integer.
The empty string is a valid value in the input values set. Returned error, if not nil, is guaranteed to be an aggregated field.ErrorList
func (*Requirement) Matches ¶
func (r *Requirement) Matches(data map[string]any) bool
Matches returns true if the Requirement matches the input Labels. There is a match in the following cases:
- The operator is Exists and Labels has the Requirement's key.
- The operator is In, Labels has the Requirement's key and Labels' value for that key is in Requirement's value set.
- The operator is NotIn, Labels has the Requirement's key and Labels' value for that key is not in Requirement's value set.
- The operator is DoesNotExist or NotIn and Labels does not have the Requirement's key.
- The operator is GreaterThanOperator or LessThanOperator, and Labels has the Requirement's key and the corresponding value satisfies mathematical inequality.
type Selector ¶
type Selector interface { // Matches returns true if this selector matches the given struct. Matches(map[string]any) bool // Add adds requirements to the Selector Add(r ...Requirement) Selector // String returns a human readable string that represents this selector. String() string }
func ExprSelectorAsSelector ¶
func ExprSelectorAsSelector(es *selector1alpha1.ExpressionSelector) (Selector, error)
func ResourceExprSelectorAsSelector ¶
func ResourceExprSelectorAsSelector(es *resourcepb.ExpressionSelector) (Selector, error)
type SelectorBuilder ¶
type SelectorBuilder interface { // Matches returns true if the expression match both objectss. GetSelector(map[string]any) map[string]string // Add adds requirements to the Selector Add(r ...BuilderRequirement) SelectorBuilder String() string }
func NewSelectorBuilder ¶
func NewSelectorBuilder() SelectorBuilder
NewParentChildSelector returns a nil parent child selector
func SelectorAsSelectorBuilder ¶
func SelectorAsSelectorBuilder(es *selector1alpha1.ExpressionSelector) (SelectorBuilder, error)