admission/webhook: fix panic from empty response in mutating webhooks

pull/8/head
Dr. Stefan Schimanski 2018-02-12 14:58:57 +01:00
parent 72f8a369d0
commit 10969e1b8d
1 changed files with 5 additions and 0 deletions

View File

@ -20,6 +20,7 @@ package mutating
import (
"context"
"fmt"
"time"
jsonpatch "github.com/evanphx/json-patch"
@ -88,6 +89,10 @@ func (a *mutatingDispatcher) callAttrMutatingHook(ctx context.Context, h *v1beta
return &webhookerrors.ErrCallingWebhook{WebhookName: h.Name, Reason: err}
}
if response.Response == nil {
return &webhookerrors.ErrCallingWebhook{WebhookName: h.Name, Reason: fmt.Errorf("Webhook response was absent")}
}
if !response.Response.Allowed {
return webhookerrors.ToStatusErr(h.Name, response.Response.Result)
}