1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2024-12-14 11:57:51 +00:00

Simplify code

Drop unnecessry typedefs.
This commit is contained in:
Markus Lehtonen 2024-07-09 09:05:33 +03:00
parent dc52c507e7
commit b5b701fbbf
5 changed files with 17 additions and 17 deletions

View file

@ -146,13 +146,13 @@ func TestFeature(t *testing.T) {
f2.Instances["dom.inst"] = NewInstanceFeatures(*NewInstanceFeature(map[string]string{"a1": "v3.1", "a3": "v3.3"}))
f2.MergeInto(&f)
expectedFeatures = *NewFeatures()
expectedFeatures.Flags["dom.flag"] = FlagFeatureSet{Elements: map[string]Nil{"k1": Nil{}, "k2": Nil{}, "k3": Nil{}}}
expectedFeatures.Flags["dom.flag"] = FlagFeatureSet{Elements: map[string]Nil{"k1": {}, "k2": {}, "k3": {}}}
expectedFeatures.Attributes["dom.attr"] = AttributeFeatureSet{Elements: map[string]string{"k1": "v1.override", "k2": "v2"}}
expectedFeatures.Instances["dom.inst"] = InstanceFeatureSet{
Elements: []InstanceFeature{
InstanceFeature{Attributes: map[string]string{"a1": "v1.1", "a2": "v1.2"}},
InstanceFeature{Attributes: map[string]string{"a1": "v2.1", "a2": "v2.2"}},
InstanceFeature{Attributes: map[string]string{"a1": "v3.1", "a3": "v3.3"}},
{Attributes: map[string]string{"a1": "v1.1", "a2": "v1.2"}},
{Attributes: map[string]string{"a1": "v2.1", "a2": "v2.2"}},
{Attributes: map[string]string{"a1": "v3.1", "a3": "v3.3"}},
},
}
assert.Equal(t, expectedFeatures, f)
@ -184,7 +184,7 @@ func TestFeatureSpec(t *testing.T) {
expectedFeatures.Labels["l1"] = "v1.override"
expectedFeatures.Labels["l3"] = "v3"
expectedFeatures.Features.Flags["dom.flag2"] = FlagFeatureSet{Elements: map[string]Nil{"k3": Nil{}}}
expectedFeatures.Features.Flags["dom.flag2"] = FlagFeatureSet{Elements: map[string]Nil{"k3": {}}}
f2.MergeInto(&f)
assert.Equal(t, expectedFeatures, f)

View file

@ -213,14 +213,14 @@ func TestMatchInstances(t *testing.T) {
{name: "2", input: []I{}, output: O{}, result: assert.False, err: assert.Nil}, // zero instances -> false
{name: "3", input: []I{I{Attributes: A{}}}, output: O{A{}}, result: assert.True, err: assert.Nil}, // one "empty" instance
{name: "3", input: []I{{Attributes: A{}}}, output: O{A{}}, result: assert.True, err: assert.Nil}, // one "empty" instance
{name: "4",
mes: `
foo: { op: Exists }
bar: { op: Lt, value: ["10"] }
`,
input: []I{I{Attributes: A{"foo": "1"}}, I{Attributes: A{"bar": "1"}}},
input: []I{{Attributes: A{"foo": "1"}}, {Attributes: A{"bar": "1"}}},
output: O{},
result: assert.False, err: assert.Nil},
@ -229,7 +229,7 @@ bar: { op: Lt, value: ["10"] }
foo: { op: Exists }
bar: { op: Lt, value: ["10"] }
`,
input: []I{I{Attributes: A{"foo": "1"}}, I{Attributes: A{"foo": "2", "bar": "1"}}},
input: []I{{Attributes: A{"foo": "1"}}, {Attributes: A{"foo": "2", "bar": "1"}}},
output: O{A{"foo": "2", "bar": "1"}},
result: assert.True, err: assert.Nil},
@ -237,7 +237,7 @@ bar: { op: Lt, value: ["10"] }
mes: `
bar: { op: Lt, value: ["10"] }
`,
input: []I{I{Attributes: A{"foo": "1"}}, I{Attributes: A{"bar": "0x1"}}},
input: []I{{Attributes: A{"foo": "1"}}, {Attributes: A{"bar": "0x1"}}},
result: assert.False, err: assert.NotNil},
}

View file

@ -24,7 +24,7 @@ import (
// e.g RMDA related features. NFD configuration file may extend these custom features by adding rules.
func getStaticRules() []nfdv1alpha1.Rule {
return []nfdv1alpha1.Rule{
nfdv1alpha1.Rule{
{
Name: "RDMA capable static rule",
Labels: map[string]string{"rdma.capable": "true"},
MatchFeatures: nfdv1alpha1.FeatureMatcher{
@ -38,7 +38,7 @@ func getStaticRules() []nfdv1alpha1.Rule {
},
},
},
nfdv1alpha1.Rule{
{
Name: "RDMA available static rule",
Labels: map[string]string{"rdma.available": "true"},
MatchFeatures: nfdv1alpha1.FeatureMatcher{

View file

@ -62,20 +62,20 @@ func newDefaultConfig() *Config {
"attr_3": "10",
},
InstanceFeatures: []FakeInstance{
FakeInstance{
{
"name": "instance_1",
"attr_1": "true",
"attr_2": "false",
"attr_3": "10",
"attr_4": "foobar",
},
FakeInstance{
{
"name": "instance_2",
"attr_1": "true",
"attr_2": "true",
"attr_3": "100",
},
FakeInstance{
{
"name": "instance_3",
},
},

View file

@ -49,16 +49,16 @@ func TestPciSource(t *testing.T) {
// Specify expected "raw" features. These are always the same for the same
// mocked sysfs.
expectedFeatures := map[string]*nfdv1alpha1.Features{
"rootfs-empty": &nfdv1alpha1.Features{
"rootfs-empty": {
Flags: map[string]nfdv1alpha1.FlagFeatureSet{},
Attributes: map[string]nfdv1alpha1.AttributeFeatureSet{},
Instances: map[string]nfdv1alpha1.InstanceFeatureSet{},
},
"rootfs-1": &nfdv1alpha1.Features{
"rootfs-1": {
Flags: map[string]nfdv1alpha1.FlagFeatureSet{},
Attributes: map[string]nfdv1alpha1.AttributeFeatureSet{},
Instances: map[string]nfdv1alpha1.InstanceFeatureSet{
"device": nfdv1alpha1.InstanceFeatureSet{
"device": {
Elements: []nfdv1alpha1.InstanceFeature{
{
Attributes: map[string]string{