2021-08-31 11:10:12 +03:00
|
|
|
//go:build !ignore_autogenerated
|
|
|
|
// +build !ignore_autogenerated
|
|
|
|
|
|
|
|
// Code generated by controller-gen. DO NOT EDIT.
|
|
|
|
|
|
|
|
package v1alpha1
|
|
|
|
|
|
|
|
import (
|
2022-10-06 17:04:04 +03:00
|
|
|
"k8s.io/api/core/v1"
|
2021-06-08 14:59:29 +03:00
|
|
|
"k8s.io/apimachinery/pkg/runtime"
|
2021-08-31 11:10:12 +03:00
|
|
|
)
|
|
|
|
|
2022-07-04 13:43:57 +03:00
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
|
|
func (in *AttributeFeatureSet) DeepCopyInto(out *AttributeFeatureSet) {
|
|
|
|
*out = *in
|
|
|
|
if in.Elements != nil {
|
|
|
|
in, out := &in.Elements, &out.Elements
|
|
|
|
*out = make(map[string]string, len(*in))
|
|
|
|
for key, val := range *in {
|
|
|
|
(*out)[key] = val
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AttributeFeatureSet.
|
|
|
|
func (in *AttributeFeatureSet) DeepCopy() *AttributeFeatureSet {
|
|
|
|
if in == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
out := new(AttributeFeatureSet)
|
|
|
|
in.DeepCopyInto(out)
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
2021-08-31 11:10:12 +03:00
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
|
|
func (in FeatureMatcher) DeepCopyInto(out *FeatureMatcher) {
|
|
|
|
{
|
|
|
|
in := &in
|
|
|
|
*out = make(FeatureMatcher, len(*in))
|
|
|
|
for i := range *in {
|
|
|
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FeatureMatcher.
|
|
|
|
func (in FeatureMatcher) DeepCopy() FeatureMatcher {
|
|
|
|
if in == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
out := new(FeatureMatcher)
|
|
|
|
in.DeepCopyInto(out)
|
|
|
|
return *out
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
|
|
func (in *FeatureMatcherTerm) DeepCopyInto(out *FeatureMatcherTerm) {
|
|
|
|
*out = *in
|
2022-07-07 21:11:40 +03:00
|
|
|
if in.MatchExpressions != nil {
|
|
|
|
in, out := &in.MatchExpressions, &out.MatchExpressions
|
|
|
|
*out = make(MatchExpressionSet, len(*in))
|
|
|
|
for key, val := range *in {
|
|
|
|
var outVal *MatchExpression
|
|
|
|
if val == nil {
|
|
|
|
(*out)[key] = nil
|
|
|
|
} else {
|
|
|
|
in, out := &val, &outVal
|
|
|
|
*out = new(MatchExpression)
|
|
|
|
(*in).DeepCopyInto(*out)
|
|
|
|
}
|
|
|
|
(*out)[key] = outVal
|
|
|
|
}
|
|
|
|
}
|
2021-08-31 11:10:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FeatureMatcherTerm.
|
|
|
|
func (in *FeatureMatcherTerm) DeepCopy() *FeatureMatcherTerm {
|
|
|
|
if in == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
out := new(FeatureMatcherTerm)
|
|
|
|
in.DeepCopyInto(out)
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
2022-07-04 13:43:57 +03:00
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
2022-08-24 15:45:28 +03:00
|
|
|
func (in *Features) DeepCopyInto(out *Features) {
|
|
|
|
*out = *in
|
|
|
|
if in.Flags != nil {
|
|
|
|
in, out := &in.Flags, &out.Flags
|
|
|
|
*out = make(map[string]FlagFeatureSet, len(*in))
|
2022-07-04 13:43:57 +03:00
|
|
|
for key, val := range *in {
|
2022-08-24 15:45:28 +03:00
|
|
|
(*out)[key] = *val.DeepCopy()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if in.Attributes != nil {
|
|
|
|
in, out := &in.Attributes, &out.Attributes
|
|
|
|
*out = make(map[string]AttributeFeatureSet, len(*in))
|
|
|
|
for key, val := range *in {
|
|
|
|
(*out)[key] = *val.DeepCopy()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if in.Instances != nil {
|
|
|
|
in, out := &in.Instances, &out.Instances
|
|
|
|
*out = make(map[string]InstanceFeatureSet, len(*in))
|
|
|
|
for key, val := range *in {
|
|
|
|
(*out)[key] = *val.DeepCopy()
|
2022-07-04 13:43:57 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Features.
|
2022-08-24 15:45:28 +03:00
|
|
|
func (in *Features) DeepCopy() *Features {
|
2022-07-04 13:43:57 +03:00
|
|
|
if in == nil {
|
|
|
|
return nil
|
|
|
|
}
|
2022-08-24 15:45:28 +03:00
|
|
|
out := new(Features)
|
2022-07-04 13:43:57 +03:00
|
|
|
in.DeepCopyInto(out)
|
2022-08-24 15:45:28 +03:00
|
|
|
return out
|
2022-07-04 13:43:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
|
|
func (in *FlagFeatureSet) DeepCopyInto(out *FlagFeatureSet) {
|
|
|
|
*out = *in
|
|
|
|
if in.Elements != nil {
|
|
|
|
in, out := &in.Elements, &out.Elements
|
|
|
|
*out = make(map[string]Nil, len(*in))
|
|
|
|
for key, val := range *in {
|
|
|
|
(*out)[key] = val
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FlagFeatureSet.
|
|
|
|
func (in *FlagFeatureSet) DeepCopy() *FlagFeatureSet {
|
|
|
|
if in == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
out := new(FlagFeatureSet)
|
|
|
|
in.DeepCopyInto(out)
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
|
|
func (in *InstanceFeature) DeepCopyInto(out *InstanceFeature) {
|
|
|
|
*out = *in
|
|
|
|
if in.Attributes != nil {
|
|
|
|
in, out := &in.Attributes, &out.Attributes
|
|
|
|
*out = make(map[string]string, len(*in))
|
|
|
|
for key, val := range *in {
|
|
|
|
(*out)[key] = val
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceFeature.
|
|
|
|
func (in *InstanceFeature) DeepCopy() *InstanceFeature {
|
|
|
|
if in == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
out := new(InstanceFeature)
|
|
|
|
in.DeepCopyInto(out)
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
|
|
func (in *InstanceFeatureSet) DeepCopyInto(out *InstanceFeatureSet) {
|
|
|
|
*out = *in
|
|
|
|
if in.Elements != nil {
|
|
|
|
in, out := &in.Elements, &out.Elements
|
|
|
|
*out = make([]InstanceFeature, len(*in))
|
|
|
|
for i := range *in {
|
|
|
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceFeatureSet.
|
|
|
|
func (in *InstanceFeatureSet) DeepCopy() *InstanceFeatureSet {
|
|
|
|
if in == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
out := new(InstanceFeatureSet)
|
|
|
|
in.DeepCopyInto(out)
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
2021-08-31 11:10:12 +03:00
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
|
|
func (in *MatchAnyElem) DeepCopyInto(out *MatchAnyElem) {
|
|
|
|
*out = *in
|
|
|
|
if in.MatchFeatures != nil {
|
|
|
|
in, out := &in.MatchFeatures, &out.MatchFeatures
|
|
|
|
*out = make(FeatureMatcher, len(*in))
|
|
|
|
for i := range *in {
|
|
|
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MatchAnyElem.
|
|
|
|
func (in *MatchAnyElem) DeepCopy() *MatchAnyElem {
|
|
|
|
if in == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
out := new(MatchAnyElem)
|
|
|
|
in.DeepCopyInto(out)
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
|
|
func (in *MatchExpression) DeepCopyInto(out *MatchExpression) {
|
|
|
|
*out = *in
|
|
|
|
if in.Value != nil {
|
|
|
|
in, out := &in.Value, &out.Value
|
|
|
|
*out = make(MatchValue, len(*in))
|
|
|
|
copy(*out, *in)
|
|
|
|
}
|
2021-08-30 19:57:55 +03:00
|
|
|
in.valueRe.DeepCopyInto(&out.valueRe)
|
2021-08-31 11:10:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MatchExpression.
|
|
|
|
func (in *MatchExpression) DeepCopy() *MatchExpression {
|
|
|
|
if in == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
out := new(MatchExpression)
|
|
|
|
in.DeepCopyInto(out)
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
2022-07-07 21:11:40 +03:00
|
|
|
func (in MatchExpressionSet) DeepCopyInto(out *MatchExpressionSet) {
|
|
|
|
{
|
|
|
|
in := &in
|
|
|
|
*out = make(MatchExpressionSet, len(*in))
|
2021-08-31 11:10:12 +03:00
|
|
|
for key, val := range *in {
|
|
|
|
var outVal *MatchExpression
|
|
|
|
if val == nil {
|
|
|
|
(*out)[key] = nil
|
|
|
|
} else {
|
|
|
|
in, out := &val, &outVal
|
|
|
|
*out = new(MatchExpression)
|
|
|
|
(*in).DeepCopyInto(*out)
|
|
|
|
}
|
|
|
|
(*out)[key] = outVal
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MatchExpressionSet.
|
2022-07-07 21:11:40 +03:00
|
|
|
func (in MatchExpressionSet) DeepCopy() MatchExpressionSet {
|
2021-08-31 11:10:12 +03:00
|
|
|
if in == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
out := new(MatchExpressionSet)
|
|
|
|
in.DeepCopyInto(out)
|
2022-07-07 21:11:40 +03:00
|
|
|
return *out
|
2021-08-31 11:10:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
|
|
func (in MatchValue) DeepCopyInto(out *MatchValue) {
|
|
|
|
{
|
|
|
|
in := &in
|
|
|
|
*out = make(MatchValue, len(*in))
|
|
|
|
copy(*out, *in)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MatchValue.
|
|
|
|
func (in MatchValue) DeepCopy() MatchValue {
|
|
|
|
if in == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
out := new(MatchValue)
|
|
|
|
in.DeepCopyInto(out)
|
|
|
|
return *out
|
|
|
|
}
|
|
|
|
|
pkg/apis/nfd: support label name templating
Support templating of label names in feature rules. It is available both
in NodeFeatureRule CRs and in custom rule configuration of nfd-worker.
This patch adds a new 'labelsTemplate' field to the rule spec, making it
possible to dynamically generate multiple labels per rule based on the
matched features. The feature relies on the golang "text/template"
package. When expanded, the template must contain labels in a raw
<key>[=<value>] format (where 'value' defaults to "true"), separated by
newlines i.e.:
- name: <rule-name>
labelsTemplate: |
<label-1>[=<value-1>]
<label-2>[=<value-2>]
...
All the matched features of 'matchFeatures' directives are available for
templating engine in a nested data structure that can be described in
yaml as:
.
<domain-1>:
<key-feature-1>:
- Name: <matched-key>
- ...
<value-feature-1:
- Name: <matched-key>
Value: <matched-value>
- ...
<instance-feature-1>:
- <attribute-1-name>: <attribute-1-value>
<attribute-2-name>: <attribute-2-value>
...
- ...
<domain-2>:
...
That is, the per-feature data available for matching depends on the type
of feature that was matched:
- "key features": only 'Name' is available
- "value features": 'Name' and 'Value' can be used
- "instance features": all attributes of the matched instance are
available
NOTE: In case of matchAny is specified, the template is executed
separately against each individual matchFeatures matcher and the
eventual set of labels is a superset of all these expansions. Consider
the following:
- name: <name>
labelsTemplate: <template>
matchAny:
- matchFeatures: <matcher#1>
- matchFeatures: <matcher#2>
matchFeatures: <matcher#3>
In the example above (assuming the overall result is a match) the
template would be executed on matcher#1 and/or matcher#2 (depending on
whether both or only one of them match), and finally on matcher#3, and
all the labels from these separate expansions would be created (i.e. the
end result would be a union of all the individual expansions).
NOTE 2: The 'labels' field has priority over 'labelsTemplate', i.e.
labels specified in the 'labels' field will override any labels
originating from the 'labelsTemplate' field.
A special case of an empty match expression set matches everything (i.e.
matches/returns all existing keys/values). This makes it simpler to
write templates that run over all values. Also, makes it possible to
later implement support for templates that run over all _keys_ of a
feature.
Some example configurations:
- name: "my-pci-template-features"
labelsTemplate: |
{{ range .pci.device }}intel-{{ .class }}-{{ .device }}=present
{{ end }}
matchFeatures:
- feature: pci.device
matchExpressions:
class: {op: InRegexp, value: ["^06"]}
vendor: ["8086"]
- name: "my-system-template-features"
labelsTemplate: |
{{ range .system.osrelease }}system-{{ .Name }}={{ .Value }}
{{ end }}
matchFeatures:
- feature: system.osRelease
matchExpressions:
ID: {op: Exists}
VERSION_ID.major: {op: Exists}
Imaginative template pipelines are possible, of course, but care must be
taken in order to produce understandable and maintainable rule sets.
2021-05-04 16:30:06 +03:00
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
|
|
func (in MatchedInstance) DeepCopyInto(out *MatchedInstance) {
|
|
|
|
{
|
|
|
|
in := &in
|
|
|
|
*out = make(MatchedInstance, len(*in))
|
|
|
|
for key, val := range *in {
|
|
|
|
(*out)[key] = val
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MatchedInstance.
|
|
|
|
func (in MatchedInstance) DeepCopy() MatchedInstance {
|
|
|
|
if in == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
out := new(MatchedInstance)
|
|
|
|
in.DeepCopyInto(out)
|
|
|
|
return *out
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
|
|
func (in *MatchedKey) DeepCopyInto(out *MatchedKey) {
|
|
|
|
*out = *in
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MatchedKey.
|
|
|
|
func (in *MatchedKey) DeepCopy() *MatchedKey {
|
|
|
|
if in == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
out := new(MatchedKey)
|
|
|
|
in.DeepCopyInto(out)
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
|
|
func (in *MatchedValue) DeepCopyInto(out *MatchedValue) {
|
|
|
|
*out = *in
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MatchedValue.
|
|
|
|
func (in *MatchedValue) DeepCopy() *MatchedValue {
|
|
|
|
if in == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
out := new(MatchedValue)
|
|
|
|
in.DeepCopyInto(out)
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
2022-07-04 13:43:57 +03:00
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
|
|
func (in *Nil) DeepCopyInto(out *Nil) {
|
|
|
|
*out = *in
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Nil.
|
|
|
|
func (in *Nil) DeepCopy() *Nil {
|
|
|
|
if in == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
out := new(Nil)
|
|
|
|
in.DeepCopyInto(out)
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
2022-07-04 18:03:19 +03:00
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
|
|
func (in *NodeFeature) DeepCopyInto(out *NodeFeature) {
|
|
|
|
*out = *in
|
|
|
|
out.TypeMeta = in.TypeMeta
|
|
|
|
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
|
|
|
in.Spec.DeepCopyInto(&out.Spec)
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeFeature.
|
|
|
|
func (in *NodeFeature) DeepCopy() *NodeFeature {
|
|
|
|
if in == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
out := new(NodeFeature)
|
|
|
|
in.DeepCopyInto(out)
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
|
|
|
func (in *NodeFeature) DeepCopyObject() runtime.Object {
|
|
|
|
if c := in.DeepCopy(); c != nil {
|
|
|
|
return c
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
|
|
func (in *NodeFeatureList) DeepCopyInto(out *NodeFeatureList) {
|
|
|
|
*out = *in
|
|
|
|
out.TypeMeta = in.TypeMeta
|
|
|
|
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
|
|
|
if in.Items != nil {
|
|
|
|
in, out := &in.Items, &out.Items
|
|
|
|
*out = make([]NodeFeature, len(*in))
|
|
|
|
for i := range *in {
|
|
|
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeFeatureList.
|
|
|
|
func (in *NodeFeatureList) DeepCopy() *NodeFeatureList {
|
|
|
|
if in == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
out := new(NodeFeatureList)
|
|
|
|
in.DeepCopyInto(out)
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
|
|
|
func (in *NodeFeatureList) DeepCopyObject() runtime.Object {
|
|
|
|
if c := in.DeepCopy(); c != nil {
|
|
|
|
return c
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-08-31 11:10:12 +03:00
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
|
|
func (in *NodeFeatureRule) DeepCopyInto(out *NodeFeatureRule) {
|
|
|
|
*out = *in
|
|
|
|
out.TypeMeta = in.TypeMeta
|
|
|
|
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
|
|
|
in.Spec.DeepCopyInto(&out.Spec)
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeFeatureRule.
|
|
|
|
func (in *NodeFeatureRule) DeepCopy() *NodeFeatureRule {
|
|
|
|
if in == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
out := new(NodeFeatureRule)
|
|
|
|
in.DeepCopyInto(out)
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
|
|
|
func (in *NodeFeatureRule) DeepCopyObject() runtime.Object {
|
|
|
|
if c := in.DeepCopy(); c != nil {
|
|
|
|
return c
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
|
|
func (in *NodeFeatureRuleList) DeepCopyInto(out *NodeFeatureRuleList) {
|
|
|
|
*out = *in
|
|
|
|
out.TypeMeta = in.TypeMeta
|
|
|
|
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
|
|
|
if in.Items != nil {
|
|
|
|
in, out := &in.Items, &out.Items
|
|
|
|
*out = make([]NodeFeatureRule, len(*in))
|
|
|
|
for i := range *in {
|
|
|
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeFeatureRuleList.
|
|
|
|
func (in *NodeFeatureRuleList) DeepCopy() *NodeFeatureRuleList {
|
|
|
|
if in == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
out := new(NodeFeatureRuleList)
|
|
|
|
in.DeepCopyInto(out)
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
|
|
|
func (in *NodeFeatureRuleList) DeepCopyObject() runtime.Object {
|
|
|
|
if c := in.DeepCopy(); c != nil {
|
|
|
|
return c
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
|
|
func (in *NodeFeatureRuleSpec) DeepCopyInto(out *NodeFeatureRuleSpec) {
|
|
|
|
*out = *in
|
|
|
|
if in.Rules != nil {
|
|
|
|
in, out := &in.Rules, &out.Rules
|
|
|
|
*out = make([]Rule, len(*in))
|
|
|
|
for i := range *in {
|
|
|
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeFeatureRuleSpec.
|
|
|
|
func (in *NodeFeatureRuleSpec) DeepCopy() *NodeFeatureRuleSpec {
|
|
|
|
if in == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
out := new(NodeFeatureRuleSpec)
|
|
|
|
in.DeepCopyInto(out)
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
2022-07-04 18:03:19 +03:00
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
|
|
func (in *NodeFeatureSpec) DeepCopyInto(out *NodeFeatureSpec) {
|
|
|
|
*out = *in
|
|
|
|
in.Features.DeepCopyInto(&out.Features)
|
|
|
|
if in.Labels != nil {
|
|
|
|
in, out := &in.Labels, &out.Labels
|
|
|
|
*out = make(map[string]string, len(*in))
|
|
|
|
for key, val := range *in {
|
|
|
|
(*out)[key] = val
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeFeatureSpec.
|
|
|
|
func (in *NodeFeatureSpec) DeepCopy() *NodeFeatureSpec {
|
|
|
|
if in == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
out := new(NodeFeatureSpec)
|
|
|
|
in.DeepCopyInto(out)
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
2021-08-31 11:10:12 +03:00
|
|
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
|
|
|
func (in *Rule) DeepCopyInto(out *Rule) {
|
|
|
|
*out = *in
|
|
|
|
if in.Labels != nil {
|
|
|
|
in, out := &in.Labels, &out.Labels
|
|
|
|
*out = make(map[string]string, len(*in))
|
|
|
|
for key, val := range *in {
|
|
|
|
(*out)[key] = val
|
|
|
|
}
|
|
|
|
}
|
2021-06-18 18:29:08 +03:00
|
|
|
if in.Vars != nil {
|
|
|
|
in, out := &in.Vars, &out.Vars
|
|
|
|
*out = make(map[string]string, len(*in))
|
|
|
|
for key, val := range *in {
|
|
|
|
(*out)[key] = val
|
|
|
|
}
|
|
|
|
}
|
2022-10-06 17:04:04 +03:00
|
|
|
if in.Taints != nil {
|
|
|
|
in, out := &in.Taints, &out.Taints
|
|
|
|
*out = make([]v1.Taint, len(*in))
|
|
|
|
for i := range *in {
|
|
|
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
|
|
|
}
|
|
|
|
}
|
2021-08-31 11:10:12 +03:00
|
|
|
if in.MatchFeatures != nil {
|
|
|
|
in, out := &in.MatchFeatures, &out.MatchFeatures
|
|
|
|
*out = make(FeatureMatcher, len(*in))
|
|
|
|
for i := range *in {
|
|
|
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if in.MatchAny != nil {
|
|
|
|
in, out := &in.MatchAny, &out.MatchAny
|
|
|
|
*out = make([]MatchAnyElem, len(*in))
|
|
|
|
for i := range *in {
|
|
|
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
|
|
|
}
|
|
|
|
}
|
pkg/apis/nfd: support label name templating
Support templating of label names in feature rules. It is available both
in NodeFeatureRule CRs and in custom rule configuration of nfd-worker.
This patch adds a new 'labelsTemplate' field to the rule spec, making it
possible to dynamically generate multiple labels per rule based on the
matched features. The feature relies on the golang "text/template"
package. When expanded, the template must contain labels in a raw
<key>[=<value>] format (where 'value' defaults to "true"), separated by
newlines i.e.:
- name: <rule-name>
labelsTemplate: |
<label-1>[=<value-1>]
<label-2>[=<value-2>]
...
All the matched features of 'matchFeatures' directives are available for
templating engine in a nested data structure that can be described in
yaml as:
.
<domain-1>:
<key-feature-1>:
- Name: <matched-key>
- ...
<value-feature-1:
- Name: <matched-key>
Value: <matched-value>
- ...
<instance-feature-1>:
- <attribute-1-name>: <attribute-1-value>
<attribute-2-name>: <attribute-2-value>
...
- ...
<domain-2>:
...
That is, the per-feature data available for matching depends on the type
of feature that was matched:
- "key features": only 'Name' is available
- "value features": 'Name' and 'Value' can be used
- "instance features": all attributes of the matched instance are
available
NOTE: In case of matchAny is specified, the template is executed
separately against each individual matchFeatures matcher and the
eventual set of labels is a superset of all these expansions. Consider
the following:
- name: <name>
labelsTemplate: <template>
matchAny:
- matchFeatures: <matcher#1>
- matchFeatures: <matcher#2>
matchFeatures: <matcher#3>
In the example above (assuming the overall result is a match) the
template would be executed on matcher#1 and/or matcher#2 (depending on
whether both or only one of them match), and finally on matcher#3, and
all the labels from these separate expansions would be created (i.e. the
end result would be a union of all the individual expansions).
NOTE 2: The 'labels' field has priority over 'labelsTemplate', i.e.
labels specified in the 'labels' field will override any labels
originating from the 'labelsTemplate' field.
A special case of an empty match expression set matches everything (i.e.
matches/returns all existing keys/values). This makes it simpler to
write templates that run over all values. Also, makes it possible to
later implement support for templates that run over all _keys_ of a
feature.
Some example configurations:
- name: "my-pci-template-features"
labelsTemplate: |
{{ range .pci.device }}intel-{{ .class }}-{{ .device }}=present
{{ end }}
matchFeatures:
- feature: pci.device
matchExpressions:
class: {op: InRegexp, value: ["^06"]}
vendor: ["8086"]
- name: "my-system-template-features"
labelsTemplate: |
{{ range .system.osrelease }}system-{{ .Name }}={{ .Value }}
{{ end }}
matchFeatures:
- feature: system.osRelease
matchExpressions:
ID: {op: Exists}
VERSION_ID.major: {op: Exists}
Imaginative template pipelines are possible, of course, but care must be
taken in order to produce understandable and maintainable rule sets.
2021-05-04 16:30:06 +03:00
|
|
|
if in.labelsTemplate != nil {
|
|
|
|
in, out := &in.labelsTemplate, &out.labelsTemplate
|
|
|
|
*out = (*in).DeepCopy()
|
|
|
|
}
|
|
|
|
if in.varsTemplate != nil {
|
|
|
|
in, out := &in.varsTemplate, &out.varsTemplate
|
|
|
|
*out = (*in).DeepCopy()
|
|
|
|
}
|
2021-08-31 11:10:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Rule.
|
|
|
|
func (in *Rule) DeepCopy() *Rule {
|
|
|
|
if in == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
out := new(Rule)
|
|
|
|
in.DeepCopyInto(out)
|
|
|
|
return out
|
|
|
|
}
|