Commit 9adcbd72 authored by David Eads's avatar David Eads

decode admission responses into a fresh object

parent f1d9962f
...@@ -242,20 +242,21 @@ func (a *GenericAdmissionWebhook) callHook(ctx context.Context, h *v1alpha1.Exte ...@@ -242,20 +242,21 @@ func (a *GenericAdmissionWebhook) callHook(ctx context.Context, h *v1alpha1.Exte
if err != nil { if err != nil {
return &ErrCallingWebhook{WebhookName: h.Name, Reason: err} return &ErrCallingWebhook{WebhookName: h.Name, Reason: err}
} }
if err := client.Post().Context(ctx).Body(&request).Do().Into(&request); err != nil { response := &admissionv1alpha1.AdmissionReview{}
if err := client.Post().Context(ctx).Body(&request).Do().Into(response); err != nil {
return &ErrCallingWebhook{WebhookName: h.Name, Reason: err} return &ErrCallingWebhook{WebhookName: h.Name, Reason: err}
} }
if request.Status.Allowed { if response.Status.Allowed {
return nil return nil
} }
if request.Status.Result == nil { if response.Status.Result == nil {
return fmt.Errorf("admission webhook %q denied the request without explanation", h.Name) return fmt.Errorf("admission webhook %q denied the request without explanation", h.Name)
} }
return &apierrors.StatusError{ return &apierrors.StatusError{
ErrStatus: *request.Status.Result, ErrStatus: *response.Status.Result,
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment