diff --git a/pkg/apis/admissionregistration/validation/validation_test.go b/pkg/apis/admissionregistration/validation/validation_test.go index 5b84ea21c3b..5df26bc5e4f 100644 --- a/pkg/apis/admissionregistration/validation/validation_test.go +++ b/pkg/apis/admissionregistration/validation/validation_test.go @@ -455,7 +455,7 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) { }, }, }, true), - expectedError: `[0].clientConfig.url: Invalid value: "": host must be provided`, + expectedError: `[0].clientConfig.url: Invalid value: "": host must be specified`, }, { name: "wrong scheme", @@ -479,7 +479,7 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) { }, }, }, true), - expectedError: `host must be provided`, + expectedError: `host must be specified`, }, { name: "fragment", @@ -527,7 +527,7 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) { }, }, }, true), - expectedError: `host must be provided`, + expectedError: `host must be specified`, }, { name: "path must start with slash", @@ -757,11 +757,11 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) { err := errs.ToAggregate() if err != nil { if e, a := test.expectedError, err.Error(); !strings.Contains(a, e) || e == "" { - t.Errorf("expected to contain %s, got %s", e, a) + t.Errorf("expected to contain:\n %s\ngot:\n %s", e, a) } } else { if test.expectedError != "" { - t.Errorf("unexpected no error, expected to contain %s", test.expectedError) + t.Errorf("unexpected no error, expected to contain:\n %s", test.expectedError) } } }) @@ -916,11 +916,11 @@ func TestValidateValidatingWebhookConfigurationUpdate(t *testing.T) { err := errs.ToAggregate() if err != nil { if e, a := test.expectedError, err.Error(); !strings.Contains(a, e) || e == "" { - t.Errorf("expected to contain %s, got %s", e, a) + t.Errorf("expected to contain:\n %s\ngot:\n %s", e, a) } } else { if test.expectedError != "" { - t.Errorf("unexpected no error, expected to contain %s", test.expectedError) + t.Errorf("unexpected no error, expected to contain:\n %s", test.expectedError) } } }) @@ -1355,7 +1355,7 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) { }, }, }, true), - expectedError: `[0].clientConfig.url: Invalid value: "": host must be provided`, + expectedError: `[0].clientConfig.url: Invalid value: "": host must be specified`, }, { name: "wrong scheme", @@ -1379,7 +1379,7 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) { }, }, }, true), - expectedError: `host must be provided`, + expectedError: `host must be specified`, }, { name: "fragment", @@ -1427,7 +1427,7 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) { }, }, }, true), - expectedError: `host must be provided`, + expectedError: `host must be specified`, }, { name: "path must start with slash", @@ -1657,11 +1657,11 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) { err := errs.ToAggregate() if err != nil { if e, a := test.expectedError, err.Error(); !strings.Contains(a, e) || e == "" { - t.Errorf("expected to contain %s, got %s", e, a) + t.Errorf("expected to contain:\n %s\ngot:\n %s", e, a) } } else { if test.expectedError != "" { - t.Errorf("unexpected no error, expected to contain %s", test.expectedError) + t.Errorf("unexpected no error, expected to contain:\n %s", test.expectedError) } } }) @@ -1849,11 +1849,11 @@ func TestValidateMutatingWebhookConfigurationUpdate(t *testing.T) { err := errs.ToAggregate() if err != nil { if e, a := test.expectedError, err.Error(); !strings.Contains(a, e) || e == "" { - t.Errorf("expected to contain %s, got %s", e, a) + t.Errorf("expected to contain:\n %s\ngot:\n %s", e, a) } } else { if test.expectedError != "" { - t.Errorf("unexpected no error, expected to contain %s", test.expectedError) + t.Errorf("unexpected no error, expected to contain:\n %s", test.expectedError) } } }) diff --git a/pkg/apis/certificates/validation/validation.go b/pkg/apis/certificates/validation/validation.go index 0d1e4333cad..806e5c2d4f7 100644 --- a/pkg/apis/certificates/validation/validation.go +++ b/pkg/apis/certificates/validation/validation.go @@ -176,7 +176,7 @@ func validateCertificateSigningRequest(csr *certificates.CertificateSigningReque allErrs = append(allErrs, field.Invalid(specPath.Child("request"), csr.Spec.Request, fmt.Sprintf("%v", err))) } if len(csr.Spec.Usages) == 0 { - allErrs = append(allErrs, field.Required(specPath.Child("usages"), "usages must be provided")) + allErrs = append(allErrs, field.Required(specPath.Child("usages"), "")) } if !opts.allowUnknownUsages { for i, usage := range csr.Spec.Usages { @@ -275,7 +275,7 @@ func validateConditions(fldPath *field.Path, csr *certificates.CertificateSignin func ValidateCertificateSigningRequestSignerName(fldPath *field.Path, signerName string) field.ErrorList { var el field.ErrorList if len(signerName) == 0 { - el = append(el, field.Required(fldPath, "signerName must be provided")) + el = append(el, field.Required(fldPath, "")) return el } diff --git a/pkg/apis/certificates/validation/validation_test.go b/pkg/apis/certificates/validation/validation_test.go index fa36767d754..339b69abd0b 100644 --- a/pkg/apis/certificates/validation/validation_test.go +++ b/pkg/apis/certificates/validation/validation_test.go @@ -89,7 +89,7 @@ func TestValidateCertificateSigningRequestCreate(t *testing.T) { }, }, errs: field.ErrorList{ - field.Required(specPath.Child("usages"), "usages must be provided"), + field.Required(specPath.Child("usages"), ""), }, }, "CSR with no signerName set should fail": { @@ -101,7 +101,7 @@ func TestValidateCertificateSigningRequestCreate(t *testing.T) { }, }, errs: field.ErrorList{ - field.Required(specPath.Child("signerName"), "signerName must be provided"), + field.Required(specPath.Child("signerName"), ""), }, }, "signerName contains no '/'": { @@ -337,7 +337,7 @@ func TestValidateCertificateSigningRequestCreate(t *testing.T) { }, }, errs: field.ErrorList{ - field.Required(specPath.Child("usages"), "usages must be provided"), + field.Required(specPath.Child("usages"), ""), }, }, "unknown and duplicate usages": { diff --git a/staging/src/k8s.io/apiserver/pkg/util/webhook/validation.go b/staging/src/k8s.io/apiserver/pkg/util/webhook/validation.go index c46cc9d6b80..695c00d1763 100644 --- a/staging/src/k8s.io/apiserver/pkg/util/webhook/validation.go +++ b/staging/src/k8s.io/apiserver/pkg/util/webhook/validation.go @@ -36,7 +36,7 @@ func ValidateWebhookURL(fldPath *field.Path, URL string, forceHttps bool) field. allErrors = append(allErrors, field.Invalid(fldPath, u.Scheme, "'https' is the only allowed URL scheme"+form)) } if len(u.Host) == 0 { - allErrors = append(allErrors, field.Invalid(fldPath, u.Host, "host must be provided"+form)) + allErrors = append(allErrors, field.Invalid(fldPath, u.Host, "host must be specified"+form)) } if u.User != nil { allErrors = append(allErrors, field.Invalid(fldPath, u.User.String(), "user information is not permitted in the URL"))