diff --git a/pkg/apis/serving/v1/route_validation.go b/pkg/apis/serving/v1/route_validation.go index f0ba152139f4..bf29a6c32a4b 100644 --- a/pkg/apis/serving/v1/route_validation.go +++ b/pkg/apis/serving/v1/route_validation.go @@ -203,10 +203,6 @@ func validateClusterVisibilityLabel(label string) *apis.FieldError { // validateLabels function validates route labels. func (r *Route) validateLabels() (errs *apis.FieldError) { - if val, ok := r.Labels[network.VisibilityLabelKey]; ok { - errs = errs.Also(validateClusterVisibilityLabel(val)) - } - if val, ok := r.Labels[serving.ServiceLabelKey]; ok { errs = errs.Also(verifyLabelOwnerRef(val, serving.ServiceLabelKey, "Service", r.GetOwnerReferences())) } diff --git a/pkg/apis/serving/v1/route_validation_test.go b/pkg/apis/serving/v1/route_validation_test.go index 76678adfa94d..99e24bebe747 100644 --- a/pkg/apis/serving/v1/route_validation_test.go +++ b/pkg/apis/serving/v1/route_validation_test.go @@ -490,18 +490,6 @@ func TestRouteLabelValidation(t *testing.T) { }, Spec: validRouteSpec, }, - }, { - name: "invalid visibility name", - r: &Route{ - ObjectMeta: metav1.ObjectMeta{ - Name: "byo-name", - Labels: map[string]string{ - network.VisibilityLabelKey: "bad-value", - }, - }, - Spec: validRouteSpec, - }, - want: apis.ErrInvalidValue("bad-value", "metadata.labels."+network.VisibilityLabelKey), }, { name: "valid knative service name", r: &Route{ diff --git a/pkg/apis/serving/v1/service_validation.go b/pkg/apis/serving/v1/service_validation.go index 33b54aadb242..4f63ced3f777 100644 --- a/pkg/apis/serving/v1/service_validation.go +++ b/pkg/apis/serving/v1/service_validation.go @@ -19,7 +19,6 @@ package v1 import ( "context" - network "knative.dev/networking/pkg" "knative.dev/pkg/apis" "knative.dev/serving/pkg/apis/serving" ) @@ -32,7 +31,6 @@ func (s *Service) Validate(ctx context.Context) (errs *apis.FieldError) { // spec validation. if !apis.IsInStatusUpdate(ctx) { errs = errs.Also(serving.ValidateObjectMetadata(ctx, s.GetObjectMeta(), false)) - errs = errs.Also(s.validateLabels().ViaField("labels")) errs = errs.Also(serving.ValidateRolloutDurationAnnotation( s.GetAnnotations()).ViaField("annotations")) errs = errs.ViaField("metadata") @@ -61,11 +59,3 @@ func (ss *ServiceSpec) Validate(ctx context.Context) *apis.FieldError { // configurationName. ss.RouteSpec.Validate(WithDefaultConfigurationName(ctx))) } - -// validateLabels function validates service labels -func (s *Service) validateLabels() (errs *apis.FieldError) { - if val, ok := s.Labels[network.VisibilityLabelKey]; ok { - errs = errs.Also(validateClusterVisibilityLabel(val)) - } - return errs -} diff --git a/pkg/apis/serving/v1/service_validation_test.go b/pkg/apis/serving/v1/service_validation_test.go index 07cd57dbe82c..b482d1e7de84 100644 --- a/pkg/apis/serving/v1/service_validation_test.go +++ b/pkg/apis/serving/v1/service_validation_test.go @@ -97,21 +97,6 @@ func TestServiceValidation(t *testing.T) { RouteSpec: goodRouteSpec, }, }, - }, { - name: "invalid visibility label value", - r: &Service{ - ObjectMeta: metav1.ObjectMeta{ - Name: "valid", - Labels: map[string]string{ - network.VisibilityLabelKey: "bad-label", - }, - }, - Spec: ServiceSpec{ - ConfigurationSpec: goodConfigSpec, - RouteSpec: goodRouteSpec, - }, - }, - wantErr: apis.ErrInvalidValue("bad-label", "metadata.labels."+network.VisibilityLabelKey), }, { name: "valid release", r: &Service{