1
0
Fork 0
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:
Kubernetes Prow Robot 2021-12-13 09:03:59 -08:00 committed by GitHub
commit 09c1ff86ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View file

@ -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 = ""
} }

View file

@ -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) {