From 937e3ec229eb29c8dc40b8bf531cd5b6bb98a073 Mon Sep 17 00:00:00 2001 From: Alice Wasko Date: Fri, 27 Oct 2023 00:03:40 -0700 Subject: [PATCH] remove sectionName CEL validation until it is supported Signed-off-by: Alice Wasko --- api/v1alpha1/backendtrafficpolicy_types.go | 1 - ....envoyproxy.io_backendtrafficpolicies.yaml | 2 -- .../backendtrafficpolicy_test.go | 34 ------------------- 3 files changed, 37 deletions(-) diff --git a/api/v1alpha1/backendtrafficpolicy_types.go b/api/v1alpha1/backendtrafficpolicy_types.go index 7a360348f12..7dafedbc197 100644 --- a/api/v1alpha1/backendtrafficpolicy_types.go +++ b/api/v1alpha1/backendtrafficpolicy_types.go @@ -40,7 +40,6 @@ type BackendTrafficPolicy struct { type BackendTrafficPolicySpec struct { // +kubebuilder:validation:XValidation:rule="self.group == 'gateway.networking.k8s.io'", message="this policy can only have a targetRef.group of gateway.networking.k8s.io" // +kubebuilder:validation:XValidation:rule="self.kind == 'Gateway' || self.kind == 'HTTPRoute' || self.kind == 'GRPCRoute' || self.kind == 'UDPRoute' || self.kind == 'TCPRoute' || self.kind == 'TLSRoute'", message="this policy can only have a targetRef.kind of Gateway/HTTPRoute/GRPCRoute/TCPRoute/UDPRoute/TLSRoute" - // +kubebuilder:validation:XValidation:rule="has(self.sectionName) ? self.kind == 'Gateway': true", message="sectionName can only be set when kind is 'Gateway'." // +kubebuilder:validation:Required // // targetRef is the name of the resource this policy diff --git a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml index 1d852143e65..efcf36693b2 100644 --- a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml +++ b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml @@ -270,8 +270,6 @@ spec: rule: self.kind == 'Gateway' || self.kind == 'HTTPRoute' || self.kind == 'GRPCRoute' || self.kind == 'UDPRoute' || self.kind == 'TCPRoute' || self.kind == 'TLSRoute' - - message: sectionName can only be set when kind is 'Gateway'. - rule: 'has(self.sectionName) ? self.kind == ''Gateway'': true' required: - targetRef type: object diff --git a/test/cel-validation/backendtrafficpolicy_test.go b/test/cel-validation/backendtrafficpolicy_test.go index e62f06552ff..522d89a6995 100644 --- a/test/cel-validation/backendtrafficpolicy_test.go +++ b/test/cel-validation/backendtrafficpolicy_test.go @@ -133,40 +133,6 @@ func TestBackendTrafficPolicyTarget(t *testing.T) { "spec.targetRef: Invalid value: \"object\": this policy can only have a targetRef.kind of Gateway/HTTPRoute/GRPCRoute/TCPRoute/UDPRoute/TLSRoute", }, }, - { - desc: "targetRef section name with gateway", - mutate: func(btp *egv1a1.BackendTrafficPolicy) { - btp.Spec = egv1a1.BackendTrafficPolicySpec{ - TargetRef: gwapiv1a2.PolicyTargetReferenceWithSectionName{ - PolicyTargetReference: gwapiv1a2.PolicyTargetReference{ - Group: gwapiv1a2.Group("gateway.networking.k8s.io"), - Kind: gwapiv1a2.Kind("Gateway"), - Name: gwapiv1a2.ObjectName("eg"), - }, - SectionName: §ionName, - }, - } - }, - wantErrors: []string{}, - }, - { - desc: "targetRef section name with httproute", - mutate: func(btp *egv1a1.BackendTrafficPolicy) { - btp.Spec = egv1a1.BackendTrafficPolicySpec{ - TargetRef: gwapiv1a2.PolicyTargetReferenceWithSectionName{ - PolicyTargetReference: gwapiv1a2.PolicyTargetReference{ - Group: gwapiv1a2.Group("gateway.networking.k8s.io"), - Kind: gwapiv1a2.Kind("HTTPRoute"), - Name: gwapiv1a2.ObjectName("eg"), - }, - SectionName: §ionName, - }, - } - }, - wantErrors: []string{ - "spec.targetRef: Invalid value: \"object\": sectionName can only be set when kind is 'Gateway'.", - }, - }, } for _, tc := range cases {