From dd92c9a9ce614eda4938b9aac268e365150cb702 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Thu, 11 Nov 2021 17:40:14 +0200 Subject: [PATCH] pkg/api/feature: revert back to structs instead of pointers Less error prone, as no chance for a nil pointer dereference. --- pkg/api/feature/feature.go | 18 +++++++++--------- pkg/api/feature/types.go | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/api/feature/feature.go b/pkg/api/feature/feature.go index 2c6619e18..d90339e22 100644 --- a/pkg/api/feature/feature.go +++ b/pkg/api/feature/feature.go @@ -20,28 +20,28 @@ package feature // features to empty values func NewDomainFeatures() *DomainFeatures { return &DomainFeatures{ - Keys: make(map[string]*KeyFeatureSet), - Values: make(map[string]*ValueFeatureSet), - Instances: make(map[string]*InstanceFeatureSet)} + Keys: make(map[string]KeyFeatureSet), + Values: make(map[string]ValueFeatureSet), + Instances: make(map[string]InstanceFeatureSet)} } -func NewKeyFeatures(keys ...string) *KeyFeatureSet { +func NewKeyFeatures(keys ...string) KeyFeatureSet { e := make(map[string]Nil, len(keys)) for _, k := range keys { e[k] = Nil{} } - return &KeyFeatureSet{Elements: e} + return KeyFeatureSet{Elements: e} } -func NewValueFeatures(values map[string]string) *ValueFeatureSet { +func NewValueFeatures(values map[string]string) ValueFeatureSet { if values == nil { values = make(map[string]string) } - return &ValueFeatureSet{Elements: values} + return ValueFeatureSet{Elements: values} } -func NewInstanceFeatures(instances []InstanceFeature) *InstanceFeatureSet { - return &InstanceFeatureSet{Elements: instances} +func NewInstanceFeatures(instances []InstanceFeature) InstanceFeatureSet { + return InstanceFeatureSet{Elements: instances} } func NewInstanceFeature(attrs map[string]string) *InstanceFeature { diff --git a/pkg/api/feature/types.go b/pkg/api/feature/types.go index c514a85ad..dbcf6655a 100644 --- a/pkg/api/feature/types.go +++ b/pkg/api/feature/types.go @@ -22,9 +22,9 @@ type Features map[string]*DomainFeatures // DomainFeatures is the collection of all discovered features of one domain. type DomainFeatures struct { - Keys map[string]*KeyFeatureSet `protobuf:"bytes,1,rep,name=keys"` - Values map[string]*ValueFeatureSet `protobuf:"bytes,2,rep,name=values"` - Instances map[string]*InstanceFeatureSet `protobuf:"bytes,3,rep,name=instances"` + Keys map[string]KeyFeatureSet `protobuf:"bytes,1,rep,name=keys"` + Values map[string]ValueFeatureSet `protobuf:"bytes,2,rep,name=values"` + Instances map[string]InstanceFeatureSet `protobuf:"bytes,3,rep,name=instances"` } // KeyFeatureSet is a set of simple features only containing names without values.