Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnknownConstraintType is the error when unknown Constraint.Type // enum is processed. ErrUnknownConstraintType = errors.New( "unknown enum value for Constraint.Type") // ErrUnknownLabelCondition is the error when unknown // LabelConstraint.Condition enum is processed. ErrUnknownLabelCondition = errors.New( "unknown enum value for LabelConstraint.Condition") )
Functions ¶
func HasExclusiveLabel ¶
func IsNonExclusiveConstraint ¶
func IsNonExclusiveConstraint(constraint *pod.Constraint) bool
IsNonExclusiveConstraint returns true if all components of the constraint specification do not use a host label constraint for exclusive attribute.
Types ¶
type EvaluateResult ¶
type EvaluateResult int
EvaluateResult is an enum indicating various possible result.
const ( // EvaluateResultMatch indicates that given constraint fully matched // input labelValues. EvaluateResultMatch EvaluateResult = iota // EvaluateResultMismatch indicates that given constraint mismatched // input labelValues. EvaluateResultMismatch // EvaluateResultNotApplicable indicates that given constraint is not // applicable to input values. EvaluateResultNotApplicable )
type Evaluator ¶
type Evaluator interface { // Evaluate returns true if given constraint is satisfied on // these labelValues. Evaluate( constraint *pod.Constraint, labelValues LabelValues, ) (EvaluateResult, error) }
Evaluator is the interface to evaluate whether given LabelValueSet satisifies given constraint.
func NewEvaluator ¶
func NewEvaluator(kind pod.LabelConstraint_Kind) Evaluator
NewEvaluator return a new instance of evaluator which filters out constraints of different kind.
type LabelValues ¶
LabelValues tracks how many times a value presents for a given label key. First level key is label key, second level key is label value. This is the subject of constraint evaluation process.
func GetHostLabelValues ¶
func GetHostLabelValues( hostname string, labels []*peloton.Label, ) LabelValues
GetHostLabelValues returns label counts for a host and its labels, which can be used to evaluate a constraint. NOTE: `hostname` is added unconditionally, to make sure hostname based constraints can be done regardless of label configuration.