1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-31 03:45:17 +00:00

return on delete request

This commit is contained in:
shivkumar dudhani 2019-08-21 16:42:42 -07:00
parent 35e0c7ca49
commit fdfa074954

View file

@ -17,19 +17,18 @@ func (ws *WebhookServer) HandlePolicyValidation(request *v1beta1.AdmissionReques
admissionResp := &v1beta1.AdmissionResponse{
Allowed: true,
}
// nothing to do on DELETE
if request.Operation == v1beta1.Delete {
return admissionResp
}
raw := request.Object.Raw
if request.Operation == v1beta1.Delete {
raw = request.OldObject.Raw
}
if err := json.Unmarshal(raw, &policy); err != nil {
glog.Errorf("Failed to unmarshal policy admission request, err %v\n", err)
return &v1beta1.AdmissionResponse{Allowed: false}
}
if request.Operation != v1beta1.Delete {
admissionResp = ws.validateUniqueRuleName(policy)
}
// check for uniqueness of rule names while CREATE/DELET
admissionResp = ws.validateUniqueRuleName(policy)
if admissionResp.Allowed {
ws.manageWebhookConfigurations(*policy, request.Operation)