From 6fd12a2da781663aa4481cff1094b7da84a7f071 Mon Sep 17 00:00:00 2001 From: Viktor Oreshkin Date: Mon, 22 Aug 2022 02:29:50 +0300 Subject: [PATCH] apis/nfd: fix templates with MatchAny only Signed-off-by: Viktor Oreshkin --- pkg/apis/nfd/v1alpha1/rule.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/apis/nfd/v1alpha1/rule.go b/pkg/apis/nfd/v1alpha1/rule.go index 267680326f..1237a6f192 100644 --- a/pkg/apis/nfd/v1alpha1/rule.go +++ b/pkg/apis/nfd/v1alpha1/rule.go @@ -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 }