mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
admission/webhook: fix panic from empty response in mutating webhooks
This commit is contained in:
parent
72f8a369d0
commit
10969e1b8d
@ -20,6 +20,7 @@ package mutating
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
jsonpatch "github.com/evanphx/json-patch"
|
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}
|
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 {
|
if !response.Response.Allowed {
|
||||||
return webhookerrors.ToStatusErr(h.Name, response.Response.Result)
|
return webhookerrors.ToStatusErr(h.Name, response.Response.Result)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user