Skip to content

Commit 814255b

Browse files
authored
Merge pull request #1671 from marquiz/devel/nfd-api-multi-type-feature
apis/nfd: allow different types of features of the same name
2 parents 5fe3433 + bb565c0 commit 814255b

File tree

8 files changed

+700
-88
lines changed

8 files changed

+700
-88
lines changed

api/nfd/v1alpha1/feature.go

-15
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,6 @@ func (f *Features) InsertAttributeFeatures(domain, feature string, values map[st
8080
maps.Copy(f.Attributes[key].Elements, values)
8181
}
8282

83-
// Exists returns a non-empty string if a feature exists. The return value is
84-
// the type of the feautre, i.e. "flag", "attribute" or "instance".
85-
func (f *Features) Exists(name string) string {
86-
if _, ok := f.Flags[name]; ok {
87-
return "flag"
88-
}
89-
if _, ok := f.Attributes[name]; ok {
90-
return "attribute"
91-
}
92-
if _, ok := f.Instances[name]; ok {
93-
return "instance"
94-
}
95-
return ""
96-
}
97-
9883
// MergeInto merges two FeatureSpecs into one. Data in the input object takes
9984
// precedence (overwrite) over data of the existing object we're merging into.
10085
func (in *NodeFeatureSpec) MergeInto(out *NodeFeatureSpec) {

api/nfd/v1alpha1/feature_test.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,9 @@ func TestInstanceFeatureSet(t *testing.T) {
113113
func TestFeature(t *testing.T) {
114114
f := Features{}
115115

116-
// Test Exists() and InsertAttributeFeatures()
117-
assert.Empty(t, f.Exists("dom.attr"), "empty features shouldn't contain anything")
118-
116+
// Test InsertAttributeFeatures()
119117
f.InsertAttributeFeatures("dom", "attr", map[string]string{"k1": "v1", "k2": "v2"})
120118
expectedAttributes := map[string]string{"k1": "v1", "k2": "v2"}
121-
assert.Equal(t, "attribute", f.Exists("dom.attr"), "attribute feature should exist")
122119
assert.Equal(t, expectedAttributes, f.Attributes["dom.attr"].Elements)
123120

124121
f.InsertAttributeFeatures("dom", "attr", map[string]string{"k2": "v2.override", "k3": "v3"})

docs/usage/customization-guide.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ NodeFeature object as NFD uses it to determine the node which it is targeting.
101101

102102
### Feature types
103103

104-
Features are divided into three different types:
104+
Features have three different types:
105105

106106
- **flag** features: a set of names without any associated values, e.g. CPUID
107107
flags or loaded kernel modules
@@ -955,7 +955,7 @@ true).
955955

956956
The following features are available for matching:
957957

958-
| Feature | [Feature type](#feature-types) | Elements | Value type | Description |
958+
| Feature | [Feature types](#feature-types) | Elements | Value type | Description |
959959
| ---------------- | ------------ | -------- | ---------- | ----------- |
960960
| **`cpu.cpuid`** | flag | | | Supported CPU capabilities |
961961
| | | **`<cpuid-flag>`** | | CPUID flag is present |

0 commit comments

Comments
 (0)