mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
Merge pull request #112582 from thockin/validation-msgs
Clarify a few validation messages
This commit is contained in:
commit
dc129a29d2
@ -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)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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": {
|
||||
|
@ -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"))
|
||||
|
Loading…
Reference in New Issue
Block a user