diff --git a/webhook/resourcesemantics/validation/validation_admit.go b/webhook/resourcesemantics/validation/validation_admit.go index 2b05a7cd0..d30e1e981 100644 --- a/webhook/resourcesemantics/validation/validation_admit.go +++ b/webhook/resourcesemantics/validation/validation_admit.go @@ -84,7 +84,10 @@ func (ac *reconciler) Admit(ctx context.Context, request *admissionv1.AdmissionR // below all overwrite `resp`, but the `defer` affords us one final // crack at things. defer func() { - resp.Warnings = []string{warnings.Error()} + resp.Warnings = make([]string, 0, len(warnings)) + for _, w := range warnings { + resp.Warnings = append(resp.Warnings, w.Error()) + } }() } if errors != nil { @@ -157,7 +160,7 @@ func (ac *reconciler) decodeRequestAndPrepareContext( return ctx, newObj, nil } -func validate(ctx context.Context, resource resourcesemantics.GenericCRD, req *admissionv1.AdmissionRequest) (err error, warn error) { +func validate(ctx context.Context, resource resourcesemantics.GenericCRD, req *admissionv1.AdmissionRequest) (err error, warn []error) { logger := logging.FromContext(ctx) // Only run validation for supported create and update validation. @@ -187,7 +190,11 @@ func validate(ctx context.Context, resource resourcesemantics.GenericCRD, req *a err = errorResult } if warningResult := result.Filter(apis.WarningLevel); warningResult != nil { - warn = warningResult + ws := warningResult.WrappedErrors() + warn = make([]error, 0, len(ws)) + for _, w := range ws { + warn = append(warn, w) + } } } return err, warn