mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-30 11:25:04 +00:00
fix: use policyName key to get the policy name (#4114)
In case of namespace policy `ur.spec.policy` contains namespace/policy-name combinations, hence can't be used to set the policy name label. Signed-off-by: prateekpandey14 <prateek.pandey@nirmata.com> Co-authored-by: shuting <shuting@nirmata.com>
This commit is contained in:
parent
bc1b051b90
commit
02b806deee
1 changed files with 3 additions and 2 deletions
|
@ -71,10 +71,11 @@ func (g *generator) applyResource(policyName string, urSpec kyvernov1beta1.Updat
|
|||
func (g *generator) tryApplyResource(policyName string, urSpec kyvernov1beta1.UpdateRequestSpec) error {
|
||||
l := logger.WithValues("ruleType", urSpec.Type, "kind", urSpec.Resource.Kind, "name", urSpec.Resource.Name, "namespace", urSpec.Resource.Namespace)
|
||||
var queryLabels labels.Set
|
||||
|
||||
if urSpec.Type == kyvernov1beta1.Mutate {
|
||||
queryLabels = common.MutateLabelsSet(urSpec.Policy, urSpec.Resource)
|
||||
queryLabels = common.MutateLabelsSet(policyName, urSpec.Resource)
|
||||
} else if urSpec.Type == kyvernov1beta1.Generate {
|
||||
queryLabels = common.GenerateLabelsSet(urSpec.Policy, urSpec.Resource)
|
||||
queryLabels = common.GenerateLabelsSet(policyName, urSpec.Resource)
|
||||
}
|
||||
urList, err := g.urLister.List(labels.SelectorFromSet(queryLabels))
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Reference in a new issue