mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2025-03-14 20:56:42 +00:00
pkg/api/feature: generator functions with initial values
Flavor the generator helper functions with arguments for specifying the set of features to put into the generated objects.
This commit is contained in:
parent
5de4d8857c
commit
9bff4b3185
1 changed files with 24 additions and 8 deletions
|
@ -25,12 +25,28 @@ func NewDomainFeatures() *DomainFeatures {
|
|||
Instances: make(map[string]*InstanceFeatureSet)}
|
||||
}
|
||||
|
||||
func NewKeyFeatures() *KeyFeatureSet { return &KeyFeatureSet{Elements: make(map[string]Nil)} }
|
||||
|
||||
func NewValueFeatures() *ValueFeatureSet { return &ValueFeatureSet{Elements: make(map[string]string)} }
|
||||
|
||||
func NewInstanceFeatures() *InstanceFeatureSet { return &InstanceFeatureSet{} }
|
||||
|
||||
func NewInstanceFeature() *InstanceFeature {
|
||||
return &InstanceFeature{Attributes: make(map[string]string)}
|
||||
func NewKeyFeatures(keys ...string) *KeyFeatureSet {
|
||||
e := make(map[string]Nil, len(keys))
|
||||
for _, k := range keys {
|
||||
e[k] = Nil{}
|
||||
}
|
||||
return &KeyFeatureSet{Elements: e}
|
||||
}
|
||||
|
||||
func NewValueFeatures(values map[string]string) *ValueFeatureSet {
|
||||
if values == nil {
|
||||
values = make(map[string]string)
|
||||
}
|
||||
return &ValueFeatureSet{Elements: values}
|
||||
}
|
||||
|
||||
func NewInstanceFeatures(instances []InstanceFeature) *InstanceFeatureSet {
|
||||
return &InstanceFeatureSet{Elements: instances}
|
||||
}
|
||||
|
||||
func NewInstanceFeature(attrs map[string]string) *InstanceFeature {
|
||||
if attrs == nil {
|
||||
attrs = make(map[string]string)
|
||||
}
|
||||
return &InstanceFeature{Attributes: attrs}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue