diff --git a/api/nfd/v1alpha1/feature_test.go b/api/nfd/v1alpha1/feature_test.go index e73c4d5db..9d2a68b40 100644 --- a/api/nfd/v1alpha1/feature_test.go +++ b/api/nfd/v1alpha1/feature_test.go @@ -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) diff --git a/pkg/apis/nfd/nodefeaturerule/expression-api_test.go b/pkg/apis/nfd/nodefeaturerule/expression-api_test.go index ba15e2d94..c6f778159 100644 --- a/pkg/apis/nfd/nodefeaturerule/expression-api_test.go +++ b/pkg/apis/nfd/nodefeaturerule/expression-api_test.go @@ -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}, } diff --git a/source/custom/static_features.go b/source/custom/static_features.go index bcb91d3b8..9357e7330 100644 --- a/source/custom/static_features.go +++ b/source/custom/static_features.go @@ -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{ diff --git a/source/fake/fake.go b/source/fake/fake.go index 573fdb862..ea577d94f 100644 --- a/source/fake/fake.go +++ b/source/fake/fake.go @@ -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", }, }, diff --git a/source/pci/pci_test.go b/source/pci/pci_test.go index c5a7e40b5..778b961e6 100644 --- a/source/pci/pci_test.go +++ b/source/pci/pci_test.go @@ -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{