Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/apis/serving/v1/configuration_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func TestConfigurationValidation(t *testing.T) {
},
},
},
want: apis.ErrInvalidValue("not a DNS 1035 label: [a DNS-1035 label must consist of lower case alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character (e.g. 'my-name', or 'abc-123', regex used for validation is '[a-z]([-a-z0-9]*[a-z0-9])?')]",
want: apis.ErrInvalidValue("not a DNS label: [must not contain dots]",
"spec.template.metadata.name"),
}, {
name: "invalid generate name for configuration spec",
Expand All @@ -209,7 +209,7 @@ func TestConfigurationValidation(t *testing.T) {
},
},
},
want: apis.ErrInvalidValue("not a DNS 1035 label prefix: [a DNS-1035 label must consist of lower case alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character (e.g. 'my-name', or 'abc-123', regex used for validation is '[a-z]([-a-z0-9]*[a-z0-9])?')]",
want: apis.ErrInvalidValue("not a DNS label prefix: [must not contain dots]",
"spec.template.metadata.generateName"),
}, {
name: "valid generate name for configuration spec",
Expand Down
8 changes: 4 additions & 4 deletions pkg/apis/serving/v1/revision_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,16 @@ func (r *Revision) ValidateLabels() (errs *apis.FieldError) {
// validateRevisionName validates name and generateName for the revisionTemplate
func validateRevisionName(ctx context.Context, name, generateName string) *apis.FieldError {
if generateName != "" {
if msgs := validation.NameIsDNS1035Label(generateName, true); len(msgs) > 0 {
if msgs := validation.NameIsDNSLabel(generateName, true); len(msgs) > 0 {
return apis.ErrInvalidValue(
fmt.Sprint("not a DNS 1035 label prefix: ", msgs),
fmt.Sprint("not a DNS label prefix: ", msgs),
"metadata.generateName")
}
}
if name != "" {
if msgs := validation.NameIsDNS1035Label(name, false); len(msgs) > 0 {
if msgs := validation.NameIsDNSLabel(name, false); len(msgs) > 0 {
return apis.ErrInvalidValue(
fmt.Sprint("not a DNS 1035 label: ", msgs),
fmt.Sprint("not a DNS label: ", msgs),
"metadata.name")
}
om := apis.ParentMeta(ctx)
Expand Down
14 changes: 10 additions & 4 deletions pkg/apis/serving/v1/revision_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ func TestRevisionTemplateSpecValidation(t *testing.T) {
},
},
},
want: apis.ErrInvalidValue("not a DNS 1035 label: [a DNS-1035 label must consist of lower case alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character (e.g. 'my-name', or 'abc-123', regex used for validation is '[a-z]([-a-z0-9]*[a-z0-9])?')]",
want: apis.ErrInvalidValue("not a DNS label: [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])?')]",
"metadata.name"),
}, {
name: "invalid generate name for revision template",
Expand All @@ -883,7 +883,7 @@ func TestRevisionTemplateSpecValidation(t *testing.T) {
},
},
},
want: apis.ErrInvalidValue("not a DNS 1035 label prefix: [a DNS-1035 label must consist of lower case alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character (e.g. 'my-name', or 'abc-123', regex used for validation is '[a-z]([-a-z0-9]*[a-z0-9])?')]",
want: apis.ErrInvalidValue("not a DNS label prefix: [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])?')]",
"metadata.generateName"),
}, {
name: "invalid metadata.annotations for scale",
Expand Down Expand Up @@ -1225,12 +1225,12 @@ func TestValidateRevisionName(t *testing.T) {
}{{
name: "invalid revision generateName - dots",
revGenerateName: "foo.bar",
expectErr: apis.ErrInvalidValue("not a DNS 1035 label prefix: [a DNS-1035 label must consist of lower case alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character (e.g. 'my-name', or 'abc-123', regex used for validation is '[a-z]([-a-z0-9]*[a-z0-9])?')]",
expectErr: apis.ErrInvalidValue("not a DNS label prefix: [must not contain dots]",
"metadata.generateName"),
}, {
name: "invalid revision name - dots",
revName: "foo.bar",
expectErr: apis.ErrInvalidValue("not a DNS 1035 label: [a DNS-1035 label must consist of lower case alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character (e.g. 'my-name', or 'abc-123', regex used for validation is '[a-z]([-a-z0-9]*[a-z0-9])?')]",
expectErr: apis.ErrInvalidValue("not a DNS label: [must not contain dots]",
"metadata.name"),
}, {
name: "invalid name (not prefixed)",
Expand All @@ -1253,6 +1253,12 @@ func TestValidateRevisionName(t *testing.T) {
Name: "valid",
},
revName: "valid-name",
}, {
name: "valid name - starts with a digit",
objectMeta: metav1.ObjectMeta{
Name: "1valid",
},
revName: "1valid-name",
}}

for _, c := range cases {
Expand Down
Loading