2023-02-06 05:49:47 +00:00
|
|
|
package engine
|
|
|
|
|
|
|
|
import (
|
|
|
|
kyvernov1 "github.com/kyverno/kyverno/api/kyverno/v1"
|
2024-06-24 16:36:55 +00:00
|
|
|
kyvernov2 "github.com/kyverno/kyverno/api/kyverno/v2"
|
2023-02-06 05:49:47 +00:00
|
|
|
"k8s.io/client-go/tools/cache"
|
|
|
|
)
|
|
|
|
|
2023-11-13 15:43:25 +00:00
|
|
|
// GetPolicyExceptions get all exceptions that match both the policy and the rule.
|
|
|
|
func (e *engine) GetPolicyExceptions(
|
2023-02-06 05:49:47 +00:00
|
|
|
policy kyvernov1.PolicyInterface,
|
|
|
|
rule string,
|
2024-06-24 16:36:55 +00:00
|
|
|
) ([]*kyvernov2.PolicyException, error) {
|
2023-11-13 15:43:25 +00:00
|
|
|
if e.exceptionSelector == nil {
|
2024-03-28 09:31:40 +00:00
|
|
|
return nil, nil
|
2023-02-06 05:49:47 +00:00
|
|
|
}
|
2024-03-28 09:31:40 +00:00
|
|
|
return e.exceptionSelector.Find(cache.MetaObjectToName(policy).String(), rule)
|
2023-02-06 05:49:47 +00:00
|
|
|
}
|