Documentation ¶
Index ¶
Constants ¶
const ( // Pod of the object. KeyPod = "pod" // ID of the object. KeyID = "id" // UID of the object. KeyUID = "uid" // Name of the object. KeyName = "name" // Namespace of the object. KeyNamespace = "namespace" // QoSClass of the object. KeyQOSClass = "qosclass" // Labels of the object. KeyLabels = "labels" // Tags of the object. KeyTags = "tags" )
Keys of supported object properties.
Variables ¶
This section is empty.
Functions ¶
func Expand ¶
Expand performs non-recursive key substitution on strings containing 0 or more well-formed or plain (${key}, $key) references, replacing each key with its value when evaluated against the given subject. If mustResolve is true, unresolvable references are flagged as an error. Otherwise they are replaced by an empty string.
func ResolveRef ¶
ResolveRef walks an object trying to resolve a reference to a value.
Keys can be combined into compound keys using '/' as the separator. For instance, "pod/labels/io.test.domain/my-label" refers to the value of the "io.test.domain/my-label" label key of the pod of the evaluated object.
Types ¶
type Evaluable ¶
type Evaluable interface { // EvalKey returns the value of a simple/single key. EvalKey(string) interface{} // EvalRef returns the value of a (potentially joint) key (reference). EvalRef(string) (string, bool) }
Evaluable is the interface objects need to implement to be evaluable against Expressions.
type Expression ¶
type Expression struct { // Key is the expression key. Key string `json:"key"` // Op is the expression operator. // +kubebuilder:validation:Enum=Equals;NotEqual;In;NotIn;Exists;NotExist;AlwaysTrue;Matches;MatchesNot;MatchesAny;MatchesNone // +kubebuilder:validation:Format:string Op Operator `json:"operator"` // Values contains the values the key value is evaluated against. Values []string `json:"values,omitempty"` }
Expression describes some runtime-evaluated condition. An expression consists of a key, an operator and a set of values. An expression is evaluated against an object which implements the Evaluable interface. Evaluating an expression consists of looking up the value for the key in the object, then using the operator to check it against the values of the expression. The result is a single boolean value. An object is said to satisfy the evaluated expression if this value is true. An expression can contain 0, 1 or more values depending on the operator. +k8s:deepcopy-gen=true
func (*Expression) DeepCopy ¶
func (in *Expression) DeepCopy() *Expression
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Expression.
func (*Expression) DeepCopyInto ¶
func (in *Expression) DeepCopyInto(out *Expression)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*Expression) Evaluate ¶
func (e *Expression) Evaluate(subject Evaluable) bool
Evaluate evaluates an expression against a container.
func (*Expression) String ¶
func (e *Expression) String() string
String returns the expression as a string.
func (*Expression) Validate ¶
func (e *Expression) Validate() error
Validate checks the expression for (obvious) invalidity.
type Operator ¶
type Operator string
Operator is an expression operator.
const ( // Equals tests for equality with a single value. Equals Operator = "Equals" // NotEqual test for inequality with a single value. NotEqual Operator = "NotEqual" // In tests for any value for the given set. In Operator = "In" // NotIn tests for the lack of value in a given set. NotIn Operator = "NotIn" // Exists tests if the given key exists with any value. Exists Operator = "Exists" // NotExist tests if the given key does not exist. NotExist Operator = "NotExist" // AlwaysTrue always evaluates to true. AlwaysTrue Operator = "AlwaysTrue" // Matches tests if the key value matches a single globbing pattern. Matches Operator = "Matches" // MatchesNot tests if the key value does not match a single globbing pattern. MatchesNot Operator = "MatchesNot" // MatchesAny tests if the key value matches any of a set of globbing patterns. MatchesAny Operator = "MatchesAny" // MatchesNone tests if the key value matches none of a set of globbing patterns. MatchesNone Operator = "MatchesNone" )
supported operators