v1alpha1

package
v0.12.0-devel Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package v1alpha1 is the v1alpha1 version of the nfd API. +k8s:deepcopy-gen=package +kubebuilder:object:generate=true +groupName=nfd.k8s-sigs.io

Index

Constants

View Source
const (
	// RuleBackrefDomain is the special feature domain for backreferencing
	// output of preceding rules.
	RuleBackrefDomain = "rule"
	// RuleBackrefFeature is the special feature name for backreferencing
	// output of preceding rules.
	RuleBackrefFeature = "matched"
)

Variables

View Source
var (
	// SchemeGroupVersion is group version used to register these objects
	SchemeGroupVersion = schema.GroupVersion{Group: "nfd.k8s-sigs.io", Version: "v1alpha1"}

	// SchemeBuilder is the scheme builder for this API.
	SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)

	// AddToScheme is a function to register this API group and version to a scheme.
	AddToScheme = SchemeBuilder.AddToScheme
)

Functions

func Resource

func Resource(resource string) schema.GroupResource

Resource takes an unqualified resource name and returns a Group qualified GroupResource.

Types

type Expressions

type Expressions map[string]*MatchExpression

Expressions is a helper type to work around issues with k8s deepcopy-gen

func (Expressions) DeepCopy

func (in Expressions) DeepCopy() Expressions

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Expressions.

func (Expressions) DeepCopyInto

func (in Expressions) DeepCopyInto(out *Expressions)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*Expressions) Len

func (e *Expressions) Len() int

Len returns the number of expressions.

type FeatureMatcher

type FeatureMatcher []FeatureMatcherTerm

FeatureMatcher specifies a set of feature matcher terms (i.e. per-feature matchers), all of which must match.

func (FeatureMatcher) DeepCopy

func (in FeatureMatcher) DeepCopy() FeatureMatcher

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FeatureMatcher.

func (FeatureMatcher) DeepCopyInto

func (in FeatureMatcher) DeepCopyInto(out *FeatureMatcher)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type FeatureMatcherTerm

type FeatureMatcherTerm struct {
	Feature          string             `json:"feature"`
	MatchExpressions MatchExpressionSet `json:"matchExpressions"`
}

FeatureMatcherTerm defines requirements against one feature set. All requirements (specified as MatchExpressions) are evaluated against each element in the feature set.

func (*FeatureMatcherTerm) DeepCopy

func (in *FeatureMatcherTerm) DeepCopy() *FeatureMatcherTerm

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FeatureMatcherTerm.

func (*FeatureMatcherTerm) DeepCopyInto

func (in *FeatureMatcherTerm) DeepCopyInto(out *FeatureMatcherTerm)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type MatchAnyElem

type MatchAnyElem struct {
	// MatchFeatures specifies a set of matcher terms all of which must match.
	MatchFeatures FeatureMatcher `json:"matchFeatures"`
}

MatchAnyElem specifies one sub-matcher of MatchAny.

func (*MatchAnyElem) DeepCopy

func (in *MatchAnyElem) DeepCopy() *MatchAnyElem

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MatchAnyElem.

func (*MatchAnyElem) DeepCopyInto

func (in *MatchAnyElem) DeepCopyInto(out *MatchAnyElem)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type MatchExpression

type MatchExpression struct {
	// Op is the operator to be applied.
	Op MatchOp `json:"op"`

	// Value is the list of values that the operand evaluates the input
	// against. Value should be empty if the operator is Exists, DoesNotExist,
	// IsTrue or IsFalse. Value should contain exactly one element if the
	// operator is Gt or Lt and exactly two elements if the operator is GtLt.
	// In other cases Value should contain at least one element.
	// +optional
	Value MatchValue `json:"value,omitempty"`
	// contains filtered or unexported fields
}

MatchExpression specifies an expression to evaluate against a set of input values. It contains an operator that is applied when matching the input and an array of values that the operator evaluates the input against.

NB: CreateMatchExpression or MustCreateMatchExpression() should be used for

creating new instances.

NB: Validate() must be called if Op or Value fields are modified or if a new

instance is created from scratch without using the helper functions.

func CreateMatchExpression

func CreateMatchExpression(op MatchOp, values ...string) (*MatchExpression, error)

CreateMatchExpression creates a new MatchExpression instance. Returns an error if validation fails.

func MustCreateMatchExpression

func MustCreateMatchExpression(op MatchOp, values ...string) *MatchExpression

MustCreateMatchExpression creates a new MatchExpression instance. Panics if validation fails.

func (*MatchExpression) DeepCopy

func (in *MatchExpression) DeepCopy() *MatchExpression

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MatchExpression.

func (*MatchExpression) DeepCopyInto

func (in *MatchExpression) DeepCopyInto(out *MatchExpression)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*MatchExpression) Match

func (m *MatchExpression) Match(valid bool, value interface{}) (bool, error)

Match evaluates the MatchExpression against a single input value.

func (*MatchExpression) MatchKeys

func (m *MatchExpression) MatchKeys(name string, keys map[string]feature.Nil) (bool, error)

MatchKeys evaluates the MatchExpression against a set of keys.

func (*MatchExpression) MatchValues

func (m *MatchExpression) MatchValues(name string, values map[string]string) (bool, error)

MatchValues evaluates the MatchExpression against a set of key-value pairs.

func (*MatchExpression) UnmarshalJSON

func (m *MatchExpression) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the Unmarshaler interface of "encoding/json"

func (*MatchExpression) Validate

func (m *MatchExpression) Validate() error

Validate validates the expression.

type MatchExpressionSet

type MatchExpressionSet struct {
	Expressions `json:",inline"`
}

MatchExpressionSet contains a set of MatchExpressions, each of which is evaluated against a set of input values.

func NewMatchExpressionSet

func NewMatchExpressionSet() *MatchExpressionSet

NewMatchExpressionSet returns a new MatchExpressionSet instance.

func (*MatchExpressionSet) DeepCopy

func (in *MatchExpressionSet) DeepCopy() *MatchExpressionSet

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MatchExpressionSet.

func (*MatchExpressionSet) DeepCopyInto

func (in *MatchExpressionSet) DeepCopyInto(out *MatchExpressionSet)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*MatchExpressionSet) MatchGetInstances

func (m *MatchExpressionSet) MatchGetInstances(instances []feature.InstanceFeature) ([]MatchedInstance, error)

MatchGetInstances evaluates the MatchExpressionSet against a set of instance features, each of which is an individual set of key-value pairs (attributes). A slice containing all matching instances is returned. An empty (non-nil) slice is returned if no matching instances were found.

func (*MatchExpressionSet) MatchGetKeys

func (m *MatchExpressionSet) MatchGetKeys(keys map[string]feature.Nil) (bool, []MatchedKey, error)

MatchGetKeys evaluates the MatchExpressionSet against a set of keys and returns all matched keys or nil if no match was found. Special case of an empty MatchExpressionSet returns all existing keys are returned. Note that an empty MatchExpressionSet and an empty set of keys returns an empty slice which is not nil and is treated as a match.

func (*MatchExpressionSet) MatchGetValues

func (m *MatchExpressionSet) MatchGetValues(values map[string]string) (bool, []MatchedValue, error)

MatchGetValues evaluates the MatchExpressionSet against a set of key-value pairs and returns all matched key-value pairs. Special case of an empty MatchExpressionSet returns all existing key-value pairs. Note that an empty MatchExpressionSet and an empty set of values returns an empty non-nil map which is treated as a match.

func (*MatchExpressionSet) MatchInstances

func (m *MatchExpressionSet) MatchInstances(instances []feature.InstanceFeature) (bool, error)

MatchInstances evaluates the MatchExpressionSet against a set of instance features, each of which is an individual set of key-value pairs (attributes).

func (*MatchExpressionSet) MatchKeys

func (m *MatchExpressionSet) MatchKeys(keys map[string]feature.Nil) (bool, error)

MatchKeys evaluates the MatchExpressionSet against a set of keys.

func (*MatchExpressionSet) MatchValues

func (m *MatchExpressionSet) MatchValues(values map[string]string) (bool, error)

MatchValues evaluates the MatchExpressionSet against a set of key-value pairs.

func (*MatchExpressionSet) UnmarshalJSON

func (m *MatchExpressionSet) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the Unmarshaler interface of "encoding/json".

type MatchOp

type MatchOp string

MatchOp is the match operator that is applied on values when evaluating a MatchExpression. +kubebuilder:validation:Enum="In";"NotIn";"InRegexp";"Exists";"DoesNotExist";"Gt";"Lt";"GtLt";"IsTrue";"IsFalse"

const (
	// MatchAny returns always true.
	MatchAny MatchOp = ""
	// MatchIn returns true if any of the values stored in the expression is
	// equal to the input.
	MatchIn MatchOp = "In"
	// MatchNotIn returns true if none of the values in the expression are
	// equal to the input.
	MatchNotIn MatchOp = "NotIn"
	// MatchInRegexp treats values of the expression as regular expressions and
	// returns true if any of them matches the input.
	MatchInRegexp MatchOp = "InRegexp"
	// MatchExists returns true if the input is valid. The expression must not
	// have any values.
	MatchExists MatchOp = "Exists"
	// MatchDoesNotExist returns true if the input is not valid. The expression
	// must not have any values.
	MatchDoesNotExist MatchOp = "DoesNotExist"
	// MatchGt returns true if the input is greater than the value of the
	// expression (number of values in the expression must be exactly one).
	// Both the input and value must be integer numbers, otherwise an error is
	// returned.
	MatchGt MatchOp = "Gt"
	// MatchLt returns true if the input is less  than the value of the
	// expression (number of values in the expression must be exactly one).
	// Both the input and value must be integer numbers, otherwise an error is
	// returned.
	MatchLt MatchOp = "Lt"
	// MatchGtLt returns true if the input is between two values, i.e. greater
	// than the first value and less than the second value of the expression
	// (number of values in the expression must be exactly two). Both the input
	// and values must be integer numbers, otherwise an error is returned.
	MatchGtLt MatchOp = "GtLt"
	// MatchIsTrue returns true if the input holds the value "true". The
	// expression must not have any values.
	MatchIsTrue MatchOp = "IsTrue"
	// MatchIsFalse returns true if the input holds the value "false". The
	// expression must not have any values.
	MatchIsFalse MatchOp = "IsFalse"
)

func (*MatchOp) UnmarshalJSON

func (m *MatchOp) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the Unmarshaler interface of "encoding/json".

type MatchValue

type MatchValue []string

MatchValue is the list of values associated with a MatchExpression.

func (MatchValue) DeepCopy

func (in MatchValue) DeepCopy() MatchValue

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MatchValue.

func (MatchValue) DeepCopyInto

func (in MatchValue) DeepCopyInto(out *MatchValue)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*MatchValue) UnmarshalJSON

func (m *MatchValue) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the Unmarshaler interface of "encoding/json".

type MatchedInstance

type MatchedInstance map[string]string

MatchedInstance holds one matched Instance.

func (MatchedInstance) DeepCopy

func (in MatchedInstance) DeepCopy() MatchedInstance

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MatchedInstance.

func (MatchedInstance) DeepCopyInto

func (in MatchedInstance) DeepCopyInto(out *MatchedInstance)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type MatchedKey

type MatchedKey struct {
	Name string
}

MatchedKey holds one matched key.

func (*MatchedKey) DeepCopy

func (in *MatchedKey) DeepCopy() *MatchedKey

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MatchedKey.

func (*MatchedKey) DeepCopyInto

func (in *MatchedKey) DeepCopyInto(out *MatchedKey)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type MatchedValue

type MatchedValue struct {
	Name  string
	Value string
}

MatchedValue holds one matched key-value pair.

func (*MatchedValue) DeepCopy

func (in *MatchedValue) DeepCopy() *MatchedValue

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MatchedValue.

func (*MatchedValue) DeepCopyInto

func (in *MatchedValue) DeepCopyInto(out *MatchedValue)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type NodeFeatureRule

type NodeFeatureRule struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec NodeFeatureRuleSpec `json:"spec"`
}

NodeFeatureRule resource specifies a configuration for feature-based customization of node objects, such as node labeling. +kubebuilder:object:root=true +kubebuilder:resource:scope=Cluster +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +genclient +genclient:nonNamespaced

func (*NodeFeatureRule) DeepCopy

func (in *NodeFeatureRule) DeepCopy() *NodeFeatureRule

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeFeatureRule.

func (*NodeFeatureRule) DeepCopyInto

func (in *NodeFeatureRule) DeepCopyInto(out *NodeFeatureRule)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*NodeFeatureRule) DeepCopyObject

func (in *NodeFeatureRule) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type NodeFeatureRuleList

type NodeFeatureRuleList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata"`

	Items []NodeFeatureRule `json:"items"`
}

NodeFeatureRuleList contains a list of NodeFeatureRule objects. +kubebuilder:object:root=true +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

func (*NodeFeatureRuleList) DeepCopy

func (in *NodeFeatureRuleList) DeepCopy() *NodeFeatureRuleList

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeFeatureRuleList.

func (*NodeFeatureRuleList) DeepCopyInto

func (in *NodeFeatureRuleList) DeepCopyInto(out *NodeFeatureRuleList)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*NodeFeatureRuleList) DeepCopyObject

func (in *NodeFeatureRuleList) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type NodeFeatureRuleSpec

type NodeFeatureRuleSpec struct {
	// Rules is a list of node customization rules.
	Rules []Rule `json:"rules"`
}

NodeFeatureRuleSpec describes a NodeFeatureRule.

func (*NodeFeatureRuleSpec) DeepCopy

func (in *NodeFeatureRuleSpec) DeepCopy() *NodeFeatureRuleSpec

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeFeatureRuleSpec.

func (*NodeFeatureRuleSpec) DeepCopyInto

func (in *NodeFeatureRuleSpec) DeepCopyInto(out *NodeFeatureRuleSpec)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Rule

type Rule struct {
	// Name of the rule.
	Name string `json:"name"`

	// Labels to create if the rule matches.
	// +optional
	Labels map[string]string `json:"labels"`

	// LabelsTemplate specifies a template to expand for dynamically generating
	// multiple labels. Data (after template expansion) must be keys with an
	// optional value (<key>[=<value>]) separated by newlines.
	// +optional
	LabelsTemplate string `json:"labelsTemplate"`

	// Vars is the variables to store if the rule matches. Variables do not
	// directly inflict any changes in the node object. However, they can be
	// referenced from other rules enabling more complex rule hierarchies,
	// without exposing intermediary output values as labels.
	// +optional
	Vars map[string]string `json:"vars"`

	// VarsTemplate specifies a template to expand for dynamically generating
	// multiple variables. Data (after template expansion) must be keys with an
	// optional value (<key>[=<value>]) separated by newlines.
	// +optional
	VarsTemplate string `json:"varsTemplate"`

	// MatchFeatures specifies a set of matcher terms all of which must match.
	// +optional
	MatchFeatures FeatureMatcher `json:"matchFeatures"`

	// MatchAny specifies a list of matchers one of which must match.
	// +optional
	MatchAny []MatchAnyElem `json:"matchAny"`
	// contains filtered or unexported fields
}

Rule defines a rule for node customization such as labeling.

func (*Rule) DeepCopy

func (in *Rule) DeepCopy() *Rule

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Rule.

func (*Rule) DeepCopyInto

func (in *Rule) DeepCopyInto(out *Rule)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*Rule) Execute

func (r *Rule) Execute(features feature.Features) (RuleOutput, error)

Execute the rule against a set of input features.

type RuleOutput

type RuleOutput struct {
	Labels map[string]string
	Vars   map[string]string
}

RuleOutput contains the output out rule execution. +k8s:deepcopy-gen=false

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL