diff --git a/apis/v1/grpcroute_types.go b/apis/v1/grpcroute_types.go index f416b4f8cf..e016d0b0e3 100644 --- a/apis/v1/grpcroute_types.go +++ b/apis/v1/grpcroute_types.go @@ -156,6 +156,7 @@ type GRPCRouteRule struct { // // Support: Extended // +optional + // Name *SectionName `json:"name,omitempty"` // Matches define conditions used for matching the rule against incoming diff --git a/apis/v1/httproute_types.go b/apis/v1/httproute_types.go index 2462390e7c..4e91d8346f 100644 --- a/apis/v1/httproute_types.go +++ b/apis/v1/httproute_types.go @@ -138,6 +138,7 @@ type HTTPRouteRule struct { // // Support: Extended // +optional + // Name *SectionName `json:"name,omitempty"` // Matches define conditions used for matching the rule against incoming diff --git a/pkg/test/cel/httproute_test.go b/pkg/test/cel/httproute_test.go index d118e17292..689c7097ea 100644 --- a/pkg/test/cel/httproute_test.go +++ b/pkg/test/cel/httproute_test.go @@ -23,9 +23,8 @@ import ( "testing" "time" - gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" ) //////////////////////////////////////////////////////////////////////////////// @@ -1263,6 +1262,21 @@ func TestHTTPRouteRule(t *testing.T) { }, }, }, + { + name: "invalid because multiple names are repeated with others", + wantErrors: []string{"Rule name must be unique within the route"}, + rules: []gatewayv1.HTTPRouteRule{ + { + Name: ptrTo(gatewayv1.SectionName("name1")), + }, + { + Name: ptrTo(gatewayv1.SectionName("not-name1")), + }, + { + Name: ptrTo(gatewayv1.SectionName("name1")), + }, + }, + }, { name: "valid because names are unique", wantErrors: nil,