Skip to content

Commit e077b0f

Browse files
authored
Merge pull request kubernetes#94182 from mattfenwick/issue-94088
modify DNS-1123 error messages to indicate that RFC 1123 is not followed exactly
2 parents 81bf1f8 + d407129 commit e077b0f

File tree

23 files changed

+44
-44
lines changed

23 files changed

+44
-44
lines changed

api/openapi-spec/swagger.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/admissionregistration/validation/validation_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) {
693693
SideEffects: &unknownSideEffect,
694694
},
695695
}, true),
696-
expectedError: `clientConfig.service.path: Invalid value: "/apis/foo.bar/v1alpha1/--bad": segment[3]: a DNS-1123 subdomain`,
696+
expectedError: `clientConfig.service.path: Invalid value: "/apis/foo.bar/v1alpha1/--bad": segment[3]: a lowercase RFC 1123 subdomain`,
697697
},
698698
{
699699
name: "invalid port 0",
@@ -1662,7 +1662,7 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) {
16621662
SideEffects: &unknownSideEffect,
16631663
},
16641664
}, true),
1665-
expectedError: `clientConfig.service.path: Invalid value: "/apis/foo.bar/v1alpha1/--bad": segment[3]: a DNS-1123 subdomain`,
1665+
expectedError: `clientConfig.service.path: Invalid value: "/apis/foo.bar/v1alpha1/--bad": segment[3]: a lowercase RFC 1123 subdomain`,
16661666
},
16671667
{
16681668
name: "invalid port 0",

pkg/apis/certificates/validation/validation_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func TestValidateCertificateSigningRequestCreate(t *testing.T) {
153153
},
154154
},
155155
errs: field.ErrorList{
156-
field.Invalid(specPath.Child("signerName"), "", `validating label "": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')`),
156+
field.Invalid(specPath.Child("signerName"), "", `validating label "": a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')`),
157157
},
158158
},
159159
"signerName path component ends with a symbol": {
@@ -166,7 +166,7 @@ func TestValidateCertificateSigningRequestCreate(t *testing.T) {
166166
},
167167
},
168168
errs: field.ErrorList{
169-
field.Invalid(specPath.Child("signerName"), "something-", `validating label "something-": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')`),
169+
field.Invalid(specPath.Child("signerName"), "something-", `validating label "something-": a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')`),
170170
},
171171
},
172172
"signerName path component is a symbol": {
@@ -179,7 +179,7 @@ func TestValidateCertificateSigningRequestCreate(t *testing.T) {
179179
},
180180
},
181181
errs: field.ErrorList{
182-
field.Invalid(specPath.Child("signerName"), "-", `validating label "-": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')`),
182+
field.Invalid(specPath.Child("signerName"), "-", `validating label "-": a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')`),
183183
},
184184
},
185185
"signerName path component contains no '.' but is valid": {

pkg/apis/core/validation/validation_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ import (
4141
)
4242

4343
const (
44-
dnsLabelErrMsg = "a DNS-1123 label must consist of"
45-
dnsSubdomainLabelErrMsg = "a DNS-1123 subdomain"
44+
dnsLabelErrMsg = "a lowercase RFC 1123 label must consist of"
45+
dnsSubdomainLabelErrMsg = "a lowercase RFC 1123 subdomain"
4646
envVarNameErrMsg = "a valid environment variable name must consist of"
4747
)
4848

pkg/apis/flowcontrol/validation/validation_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ func TestFlowSchemaValidation(t *testing.T) {
614614
},
615615
},
616616
expectedErrors: field.ErrorList{
617-
field.Invalid(field.NewPath("spec").Child("priorityLevelConfiguration").Child("name"), "system+++$$", `a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')`),
617+
field.Invalid(field.NewPath("spec").Child("priorityLevelConfiguration").Child("name"), "system+++$$", `a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')`),
618618
},
619619
},
620620
{
@@ -857,7 +857,7 @@ func TestFlowSchemaValidation(t *testing.T) {
857857
},
858858
},
859859
expectedErrors: field.ErrorList{
860-
field.Invalid(field.NewPath("spec").Child("rules").Index(0).Child("resourceRules").Index(0).Child("namespaces").Index(0), "-foo", nsErrIntro+`a DNS-1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')`),
860+
field.Invalid(field.NewPath("spec").Child("rules").Index(0).Child("resourceRules").Index(0).Child("namespaces").Index(0), "-foo", nsErrIntro+`a lowercase RFC 1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')`),
861861
},
862862
},
863863
{

pkg/apis/networking/validation/validation_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,7 +1391,7 @@ func TestValidateIngressCreate(t *testing.T) {
13911391
tweakIngress: func(ingress *networking.Ingress) {
13921392
ingress.Spec.TLS = []networking.IngressTLS{{SecretName: "invalid name"}}
13931393
},
1394-
expectedErrs: field.ErrorList{field.Invalid(field.NewPath("spec").Child("tls").Index(0).Child("secretName"), "invalid name", `a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')`)},
1394+
expectedErrs: field.ErrorList{field.Invalid(field.NewPath("spec").Child("tls").Index(0).Child("secretName"), "invalid name", `a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')`)},
13951395
},
13961396
"v1beta1: valid secret": {
13971397
groupVersion: &networkingv1beta1.SchemeGroupVersion,
@@ -1821,7 +1821,7 @@ func TestValidateIngressUpdate(t *testing.T) {
18211821
oldIngress.Spec.TLS = []networking.IngressTLS{{SecretName: "valid"}}
18221822
newIngress.Spec.TLS = []networking.IngressTLS{{SecretName: "invalid name"}}
18231823
},
1824-
expectedErrs: field.ErrorList{field.Invalid(field.NewPath("spec").Child("tls").Index(0).Child("secretName"), "invalid name", `a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')`)},
1824+
expectedErrs: field.ErrorList{field.Invalid(field.NewPath("spec").Child("tls").Index(0).Child("secretName"), "invalid name", `a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')`)},
18251825
},
18261826
"v1: change invalid secret -> invalid secret": {
18271827
gv: networkingv1.SchemeGroupVersion,
@@ -2017,7 +2017,7 @@ func TestValidateIngressClass(t *testing.T) {
20172017
Controller: "foo.co/bar",
20182018
},
20192019
},
2020-
expectedErrs: field.ErrorList{field.Invalid(field.NewPath("metadata.name"), "test*123", "a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')")},
2020+
expectedErrs: field.ErrorList{field.Invalid(field.NewPath("metadata.name"), "test*123", "a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')")},
20212021
},
20222022
"valid name, empty controller": {
20232023
ingressClass: networking.IngressClass{

staging/src/k8s.io/api/core/v1/generated.proto

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/api/core/v1/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4068,7 +4068,7 @@ type ServiceSpec struct {
40684068

40694069
// externalName is the external reference that kubedns or equivalent will
40704070
// return as a CNAME record for this service. No proxying will be involved.
4071-
// Must be a valid RFC-1123 hostname (https://tools.ietf.org/html/rfc1123)
4071+
// Must be a lowercase RFC-1123 hostname (https://tools.ietf.org/html/rfc1123)
40724072
// and requires Type to be ExternalName.
40734073
// +optional
40744074
ExternalName string `json:"externalName,omitempty" protobuf:"bytes,10,opt,name=externalName"`

staging/src/k8s.io/api/core/v1/types_swagger_doc_generated.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/api/discovery/v1alpha1/generated.proto

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)