Skip to content

Commit 75ed142

Browse files
committed
Fix image compatibility processing panic in case of a nil pointer
Signed-off-by: Marcin Franczyk <[email protected]>
1 parent 60b8a21 commit 75ed142

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pkg/client-nfd/compat/node-validator/node-validator.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ func (nv *nodeValidator) Execute(ctx context.Context) ([]*CompatibilityStatus, e
9797
}
9898

9999
func evaluateRuleStatus(rule *nfdv1alpha1.Rule, matchStatus *nodefeaturerule.MatchStatus) ProcessedRuleStatus {
100+
var matchedFeatureTerms nfdv1alpha1.FeatureMatcher
100101
out := ProcessedRuleStatus{Name: rule.Name, IsMatch: matchStatus.IsMatch}
101102

102103
evaluateFeatureMatcher := func(featureMatcher, matchedFeatureTerms nfdv1alpha1.FeatureMatcher) []MatchedExpression {
@@ -163,11 +164,17 @@ func evaluateRuleStatus(rule *nfdv1alpha1.Rule, matchStatus *nodefeaturerule.Mat
163164
}
164165

165166
if matchFeatures := rule.MatchFeatures; matchFeatures != nil {
166-
out.MatchedExpressions = evaluateFeatureMatcher(matchFeatures, matchStatus.MatchedFeaturesTerms)
167+
if matchStatus.MatchFeatureStatus != nil {
168+
matchedFeatureTerms = matchStatus.MatchFeatureStatus.MatchedFeaturesTerms
169+
}
170+
out.MatchedExpressions = evaluateFeatureMatcher(matchFeatures, matchedFeatureTerms)
167171
}
168172

169173
for i, matchAnyElem := range rule.MatchAny {
170-
matchedExpressions := evaluateFeatureMatcher(matchAnyElem.MatchFeatures, matchStatus.MatchAny[i].MatchedFeaturesTerms)
174+
if matchStatus.MatchAny[i].MatchedFeaturesTerms != nil {
175+
matchedFeatureTerms = matchStatus.MatchAny[i].MatchedFeaturesTerms
176+
}
177+
matchedExpressions := evaluateFeatureMatcher(matchAnyElem.MatchFeatures, matchedFeatureTerms)
171178
out.MatchedAny = append(out.MatchedAny, MatchAnyElem{MatchedExpressions: matchedExpressions})
172179
}
173180

0 commit comments

Comments
 (0)