From 40b40fb6011794a68d33d78db71f9e3ae47f0f56 Mon Sep 17 00:00:00 2001 From: NoSkillGirl Date: Wed, 25 Nov 2020 11:50:53 +0530 Subject: [PATCH] fixed attotaions for empty set --- pkg/policy/validate.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/policy/validate.go b/pkg/policy/validate.go index 05b768e8f6af..576c087c9d0a 100644 --- a/pkg/policy/validate.go +++ b/pkg/policy/validate.go @@ -302,6 +302,17 @@ func doMatchAndExcludeConflict(rule kyverno.Rule) bool { return false } + if rule.MatchResources.Annotations != nil && rule.ExcludeResources.Annotations != nil { + if !(reflect.DeepEqual(rule.MatchResources.Annotations, rule.ExcludeResources.Annotations)) { + return false + } + } + + if (rule.MatchResources.Annotations == nil && rule.ExcludeResources.Annotations != nil) || + (rule.MatchResources.Annotations != nil && rule.ExcludeResources.Annotations == nil) { + return false + } + return true }