return on delete request
@@ -17,19 +17,18 @@ func (ws *WebhookServer) HandlePolicyValidation(request *v1beta1.AdmissionReques
admissionResp := &v1beta1.AdmissionResponse{
Allowed: true,
}
-
- raw := request.Object.Raw
+ // nothing to do on DELETE
if request.Operation == v1beta1.Delete {
- raw = request.OldObject.Raw
+ return admissionResp
}
+
+ raw := request.Object.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 {
+ // check for uniqueness of rule names while CREATE/DELET
admissionResp = ws.validateUniqueRuleName(policy)
- }
if admissionResp.Allowed {
ws.manageWebhookConfigurations(*policy, request.Operation)
