Skip to content

Commit

Permalink
apis/nfd: fix templates with MatchAny only
Browse files Browse the repository at this point in the history
Signed-off-by: Viktor Oreshkin <[email protected]>
  • Loading branch information
stek29 committed Aug 23, 2022
1 parent 4375e08 commit 6fd12a2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/apis/nfd/v1alpha1/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ func (r *Rule) Execute(features feature.Features) (RuleOutput, error) {
matched = true
utils.KlogDump(4, "matches for matchAny "+r.Name, " ", matches)

if r.labelsTemplate == nil {
// No templating so we stop here (further matches would just
// produce the same labels)
if r.LabelsTemplate == "" && r.VarsTemplate == "" {
// there's no need to evaluate other matchers in MatchAny
// if there are no templates to be executed on them - so
// short-circuit and stop on first match here
break
}

if err := r.executeLabelsTemplate(matches, labels); err != nil {
return RuleOutput{}, err
}
Expand Down

0 comments on commit 6fd12a2

Please sign in to comment.