From d297d220a8b69264999b832ed57973c656833c0a Mon Sep 17 00:00:00 2001 From: "Paul S. Schweigert" <44698588+psschwei@users.noreply.github.com> Date: Mon, 19 Apr 2021 15:42:41 -0400 Subject: [PATCH] allow dot character in resource names --- .../pipeline/v1alpha1/condition_validation_test.go | 9 --------- .../pipeline/v1beta1/pipeline_validation_test.go | 12 ------------ pkg/apis/validate/metadata.go | 9 --------- pkg/apis/validate/metadata_test.go | 1 - 4 files changed, 31 deletions(-) diff --git a/pkg/apis/pipeline/v1alpha1/condition_validation_test.go b/pkg/apis/pipeline/v1alpha1/condition_validation_test.go index 2e408010f56..f71e02f768d 100644 --- a/pkg/apis/pipeline/v1alpha1/condition_validation_test.go +++ b/pkg/apis/pipeline/v1alpha1/condition_validation_test.go @@ -54,15 +54,6 @@ func TestCondition_Invalid(t *testing.T) { cond *v1alpha1.Condition expectedError apis.FieldError }{{ - name: "invalid meta", - cond: &v1alpha1.Condition{ - ObjectMeta: metav1.ObjectMeta{Name: "invalid.,name"}, - }, - expectedError: apis.FieldError{ - Message: "Invalid resource name: special character . must not be present", - Paths: []string{"metadata.name"}, - }, - }, { name: "no image", cond: &v1alpha1.Condition{ ObjectMeta: metav1.ObjectMeta{Name: "condname"}, diff --git a/pkg/apis/pipeline/v1beta1/pipeline_validation_test.go b/pkg/apis/pipeline/v1beta1/pipeline_validation_test.go index 03c385c0123..37e394cb011 100644 --- a/pkg/apis/pipeline/v1beta1/pipeline_validation_test.go +++ b/pkg/apis/pipeline/v1beta1/pipeline_validation_test.go @@ -134,18 +134,6 @@ func TestPipeline_Validate_Failure(t *testing.T) { expectedError apis.FieldError wc func(context.Context) context.Context }{{ - name: "period in name", - p: &Pipeline{ - ObjectMeta: metav1.ObjectMeta{Name: "pipe.line"}, - Spec: PipelineSpec{ - Tasks: []PipelineTask{{Name: "foo", TaskRef: &TaskRef{Name: "foo-task"}}}, - }, - }, - expectedError: apis.FieldError{ - Message: `Invalid resource name: special character . must not be present`, - Paths: []string{"metadata.name"}, - }, - }, { name: "pipeline name too long", p: &Pipeline{ ObjectMeta: metav1.ObjectMeta{Name: "asdf123456789012345678901234567890123456789012345678901234567890"}, diff --git a/pkg/apis/validate/metadata.go b/pkg/apis/validate/metadata.go index d943d4a9ae1..147234ad4c4 100644 --- a/pkg/apis/validate/metadata.go +++ b/pkg/apis/validate/metadata.go @@ -17,8 +17,6 @@ limitations under the License. package validate import ( - "strings" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" ) @@ -28,13 +26,6 @@ const MaxLength = 63 func ObjectMetadata(meta metav1.Object) *apis.FieldError { name := meta.GetName() - if strings.Contains(name, ".") { - return &apis.FieldError{ - Message: "Invalid resource name: special character . must not be present", - Paths: []string{"name"}, - } - } - if len(name) > MaxLength { return &apis.FieldError{ Message: "Invalid resource name: length must be no more than 63 characters", diff --git a/pkg/apis/validate/metadata_test.go b/pkg/apis/validate/metadata_test.go index 08db611bb15..1eeabe6c53b 100644 --- a/pkg/apis/validate/metadata_test.go +++ b/pkg/apis/validate/metadata_test.go @@ -28,7 +28,6 @@ func TestMetadataInvalidLongName(t *testing.T) { invalidMetas := []*metav1.ObjectMeta{ {Name: strings.Repeat("s", validate.MaxLength+1)}, - {Name: "bad.name"}, } for _, invalidMeta := range invalidMetas { if err := validate.ObjectMetadata(invalidMeta); err == nil {