mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
block dry run if a webhook would be called
This commit is contained in:
parent
972e154977
commit
e4c219df42
@ -45,3 +45,9 @@ func ToStatusErr(webhookName string, result *metav1.Status) *apierrors.StatusErr
|
|||||||
ErrStatus: *result,
|
ErrStatus: *result,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewDryRunUnsupportedErr returns a StatusError with information about the webhook plugin
|
||||||
|
func NewDryRunUnsupportedErr(webhookName string) *apierrors.StatusError {
|
||||||
|
reason := fmt.Sprintf("admission webhook %q does not support dry run", webhookName)
|
||||||
|
return apierrors.NewBadRequest(reason)
|
||||||
|
}
|
||||||
|
@ -82,6 +82,11 @@ func (a *mutatingDispatcher) Dispatch(ctx context.Context, attr *generic.Version
|
|||||||
|
|
||||||
// note that callAttrMutatingHook updates attr
|
// note that callAttrMutatingHook updates attr
|
||||||
func (a *mutatingDispatcher) callAttrMutatingHook(ctx context.Context, h *v1beta1.Webhook, attr *generic.VersionedAttributes) error {
|
func (a *mutatingDispatcher) callAttrMutatingHook(ctx context.Context, h *v1beta1.Webhook, attr *generic.VersionedAttributes) error {
|
||||||
|
if attr.IsDryRun() {
|
||||||
|
// TODO: support this
|
||||||
|
webhookerrors.NewDryRunUnsupportedErr(h.Name)
|
||||||
|
}
|
||||||
|
|
||||||
// Make the webhook request
|
// Make the webhook request
|
||||||
request := request.CreateAdmissionReview(attr)
|
request := request.CreateAdmissionReview(attr)
|
||||||
client, err := a.cm.HookClient(h)
|
client, err := a.cm.HookClient(h)
|
||||||
|
@ -97,6 +97,11 @@ func (d *validatingDispatcher) Dispatch(ctx context.Context, attr *generic.Versi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *validatingDispatcher) callHook(ctx context.Context, h *v1beta1.Webhook, attr *generic.VersionedAttributes) error {
|
func (d *validatingDispatcher) callHook(ctx context.Context, h *v1beta1.Webhook, attr *generic.VersionedAttributes) error {
|
||||||
|
if attr.IsDryRun() {
|
||||||
|
// TODO: support this
|
||||||
|
webhookerrors.NewDryRunUnsupportedErr(h.Name)
|
||||||
|
}
|
||||||
|
|
||||||
// Make the webhook request
|
// Make the webhook request
|
||||||
request := request.CreateAdmissionReview(attr)
|
request := request.CreateAdmissionReview(attr)
|
||||||
client, err := d.cm.HookClient(h)
|
client, err := d.cm.HookClient(h)
|
||||||
|
Loading…
Reference in New Issue
Block a user