1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-06 07:57:07 +00:00
kyverno/pkg/engine/api/policycontext.go
Charles-Edouard Brétéché 7a1d4374c6
refactor: move client out of policy context (#6233)
* refactor: move client out of policy context

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* fix

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* fix

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* fix test

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

---------

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2023-02-07 15:09:15 +00:00

34 lines
1 KiB
Go

package api
import (
kyvernov1 "github.com/kyverno/kyverno/api/kyverno/v1"
kyvernov1beta1 "github.com/kyverno/kyverno/api/kyverno/v1beta1"
enginecontext "github.com/kyverno/kyverno/pkg/engine/context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
)
// ExcludeFunc is a function used to determine if a resource is excluded
type ExcludeFunc = func(kind, namespace, name string) bool
type SubResource struct {
APIResource metav1.APIResource
ParentResource metav1.APIResource
}
type PolicyContext interface {
Policy() kyvernov1.PolicyInterface
NewResource() unstructured.Unstructured
OldResource() unstructured.Unstructured
AdmissionInfo() kyvernov1beta1.RequestInfo
NamespaceLabels() map[string]string
SubResource() string
SubresourcesInPolicy() []SubResource
AdmissionOperation() bool
RequestResource() metav1.GroupVersionResource
Element() unstructured.Unstructured
SetElement(element unstructured.Unstructured)
JSONContext() enginecontext.Interface
Copy() PolicyContext
}