mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2025-03-16 21:38:23 +00:00
Merge pull request #697 from marquiz/devel/custom-label-prefix
nfd-worker: drop 'custom-' prefix from matchFeatures custom rules
This commit is contained in:
commit
09c1ff86ca
2 changed files with 10 additions and 3 deletions
|
@ -498,8 +498,8 @@ func getFeatureLabels(source source.LabelSource, labelWhiteList regexp.Regexp) (
|
||||||
// Prefix for labels in the default namespace
|
// Prefix for labels in the default namespace
|
||||||
prefix := source.Name() + "-"
|
prefix := source.Name() + "-"
|
||||||
switch source.Name() {
|
switch source.Name() {
|
||||||
case "local":
|
case "local", "custom":
|
||||||
// Do not prefix labels from the hooks
|
// Do not prefix labels from the custom rules, hooks or feature files
|
||||||
prefix = ""
|
prefix = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -171,11 +171,18 @@ func (r *LegacyRule) execute(features map[string]*feature.DomainFeatures) (map[s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prefix non-namespaced labels with "custom-"
|
||||||
|
name := r.Name
|
||||||
|
if !strings.Contains(name, "/") {
|
||||||
|
name = "custom-" + name
|
||||||
|
}
|
||||||
|
|
||||||
value := "true"
|
value := "true"
|
||||||
if r.Value != nil {
|
if r.Value != nil {
|
||||||
value = *r.Value
|
value = *r.Value
|
||||||
}
|
}
|
||||||
return map[string]string{r.Name: value}, nil
|
|
||||||
|
return map[string]string{name: value}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *LegacyMatcher) match() (bool, error) {
|
func (m *LegacyMatcher) match() (bool, error) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue