1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-09 09:26:54 +00:00
kyverno/webhooks/admission.go

29 lines
890 B
Go
Raw Normal View History

package webhooks
import (
kubeclient "github.com/nirmata/kube-policy/kubeclient"
types "github.com/nirmata/kube-policy/pkg/apis/policy/v1alpha1"
policymanager "github.com/nirmata/kube-policy/pkg/policymanager"
"k8s.io/api/admission/v1beta1"
)
func kindIsSupported(kind string) bool {
2019-05-07 13:26:54 -07:00
for _, k := range kubeclient.GetSupportedKinds() {
if k == kind {
return true
}
}
return false
}
// Checks for admission if kind is supported
func AdmissionIsRequired(request *v1beta1.AdmissionRequest) bool {
// Here you can make additional hardcoded checks
return kindIsSupported(request.Kind.Kind)
}
// Checks requests kind, name and labels to fit the policy
2019-04-30 17:26:50 -07:00
func IsRuleApplicableToRequest(policyResource types.PolicyResource, request *v1beta1.AdmissionRequest) (bool, error) {
return policymanager.IsRuleApplicableToResource(request.Kind.Kind, request.Object.Raw, policyResource)
}