Skip to content

Commit

Permalink
Relax label validation for networking.knative.dev/visibility
Browse files Browse the repository at this point in the history
This patch removes `networking.knative.dev/visibility` validation.
Curently only `cluster-local` can be specified.

Fix knative#8185
Part of knative-extensions/net-gateway-api#198
  • Loading branch information
nak3 committed Dec 6, 2021
1 parent d436895 commit 8150054
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 41 deletions.
4 changes: 0 additions & 4 deletions pkg/apis/serving/v1/route_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}
Expand Down
12 changes: 0 additions & 12 deletions pkg/apis/serving/v1/route_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
10 changes: 0 additions & 10 deletions pkg/apis/serving/v1/service_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package v1
import (
"context"

network "knative.dev/networking/pkg"
"knative.dev/pkg/apis"
"knative.dev/serving/pkg/apis/serving"
)
Expand All @@ -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")
Expand Down Expand Up @@ -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
}
15 changes: 0 additions & 15 deletions pkg/apis/serving/v1/service_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 8150054

Please sign in to comment.