Skip to content

Commit 9adcbd7

Browse files
committed
decode admission responses into a fresh object
1 parent f1d9962 commit 9adcbd7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

plugin/pkg/admission/webhook/admission.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,20 +242,21 @@ func (a *GenericAdmissionWebhook) callHook(ctx context.Context, h *v1alpha1.Exte
242242
if err != nil {
243243
return &ErrCallingWebhook{WebhookName: h.Name, Reason: err}
244244
}
245-
if err := client.Post().Context(ctx).Body(&request).Do().Into(&request); err != nil {
245+
response := &admissionv1alpha1.AdmissionReview{}
246+
if err := client.Post().Context(ctx).Body(&request).Do().Into(response); err != nil {
246247
return &ErrCallingWebhook{WebhookName: h.Name, Reason: err}
247248
}
248249

249-
if request.Status.Allowed {
250+
if response.Status.Allowed {
250251
return nil
251252
}
252253

253-
if request.Status.Result == nil {
254+
if response.Status.Result == nil {
254255
return fmt.Errorf("admission webhook %q denied the request without explanation", h.Name)
255256
}
256257

257258
return &apierrors.StatusError{
258-
ErrStatus: *request.Status.Result,
259+
ErrStatus: *response.Status.Result,
259260
}
260261
}
261262

0 commit comments

Comments
 (0)