Skip to content

Commit b37201d

Browse files
committed
chore: move error as the last value returned by CustomValidatorWarn's methods
Signed-off-by: STRRL <[email protected]>
1 parent 31371cc commit b37201d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pkg/webhook/admission/validator_warn_custom.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ import (
2929

3030
// CustomValidatorWarn works like CustomValidator, but it allows to return warnings.
3131
type CustomValidatorWarn interface {
32-
ValidateCreate(ctx context.Context, obj runtime.Object) (err error, warnings []string)
33-
ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (err error, warnings []string)
34-
ValidateDelete(ctx context.Context, obj runtime.Object) (err error, warnings []string)
32+
ValidateCreate(ctx context.Context, obj runtime.Object) (warnings []string, err error)
33+
ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (warnings []string, err error)
34+
ValidateDelete(ctx context.Context, obj runtime.Object) (warnings []string, err error)
3535
}
3636

3737
// WithCustomValidatorWarn creates a new Webhook for validating the provided type.
@@ -75,7 +75,7 @@ func (h *validatorWarnForType) Handle(ctx context.Context, req Request) Response
7575
return Errored(http.StatusBadRequest, err)
7676
}
7777

78-
err, warnings = h.validatorWarn.ValidateCreate(ctx, obj)
78+
warnings, err = h.validatorWarn.ValidateCreate(ctx, obj)
7979
case v1.Update:
8080
oldObj := obj.DeepCopyObject()
8181
if err := h.decoder.DecodeRaw(req.Object, obj); err != nil {
@@ -85,15 +85,15 @@ func (h *validatorWarnForType) Handle(ctx context.Context, req Request) Response
8585
return Errored(http.StatusBadRequest, err)
8686
}
8787

88-
err, warnings = h.validatorWarn.ValidateUpdate(ctx, oldObj, obj)
88+
warnings, err = h.validatorWarn.ValidateUpdate(ctx, oldObj, obj)
8989
case v1.Delete:
9090
// In reference to PR: https://github.com/kubernetes/kubernetes/pull/76346
9191
// OldObject contains the object being deleted
9292
if err := h.decoder.DecodeRaw(req.OldObject, obj); err != nil {
9393
return Errored(http.StatusBadRequest, err)
9494
}
9595

96-
err, warnings = h.validatorWarn.ValidateDelete(ctx, obj)
96+
warnings, err = h.validatorWarn.ValidateDelete(ctx, obj)
9797
default:
9898
return Errored(http.StatusBadRequest, fmt.Errorf("unknown operation request %q", req.Operation))
9999
}

0 commit comments

Comments
 (0)