1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-04-15 08:46:36 +00:00

chore: simplify getting exception name (#9916)

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
Charles-Edouard Brétéché 2024-03-15 16:02:57 +01:00 committed by GitHub
parent ae1ab5d848
commit ad62014b33
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,8 +1,6 @@
package engine
import (
"fmt"
kyvernov1 "github.com/kyverno/kyverno/api/kyverno/v1"
kyvernov2beta1 "github.com/kyverno/kyverno/api/kyverno/v2beta1"
"k8s.io/apimachinery/pkg/labels"
@ -22,10 +20,7 @@ func (e *engine) GetPolicyExceptions(
if err != nil {
return exceptions, err
}
policyName, err := cache.MetaNamespaceKeyFunc(policy)
if err != nil {
return exceptions, fmt.Errorf("failed to compute policy key: %w", err)
}
policyName := cache.MetaObjectToName(policy).String()
for _, polex := range polexs {
if polex.Contains(policyName, rule) {
exceptions = append(exceptions, *polex)