Skip to content

Commit

Permalink
Rename and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
howardjohn committed Jul 19, 2024
1 parent 5677744 commit 689d741
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 17 deletions.
2 changes: 1 addition & 1 deletion apis/v1/grpcroute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ type GRPCRouteSpec struct {
//
// +optional
// +kubebuilder:validation:MaxItems=16
// +kubebuilder:validation:XValidation:message="Route name must be unique within the route",rule="self.all(l1, !has(l1.name) || self.exists_one(l2, has(l2.name) && l1.name == l2.name))"
// +kubebuilder:validation:XValidation:message="Rule name must be unique within the route",rule="self.all(l1, !has(l1.name) || self.exists_one(l2, has(l2.name) && l1.name == l2.name))"
Rules []GRPCRouteRule `json:"rules,omitempty"`
}

Expand Down
2 changes: 1 addition & 1 deletion apis/v1/httproute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ type HTTPRouteSpec struct {
// Rules are a list of HTTP matchers, filters and actions.
//
// +optional
// +kubebuilder:validation:XValidation:message="Route name must be unique within the route",rule="self.all(l1, !has(l1.name) || self.exists_one(l2, has(l2.name) && l1.name == l2.name))"
// +kubebuilder:validation:XValidation:message="Rule name must be unique within the route",rule="self.all(l1, !has(l1.name) || self.exists_one(l2, has(l2.name) && l1.name == l2.name))"
// +kubebuilder:validation:MaxItems=16
// +kubebuilder:default={{matches: {{path: {type: "PathPrefix", value: "/"}}}}}
Rules []HTTPRouteRule `json:"rules,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion apis/v1alpha2/tcproute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type TCPRouteSpec struct {
//
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:MaxItems=16
// +kubebuilder:validation:XValidation:message="Route name must be unique within the route",rule="self.all(l1, !has(l1.name) || self.exists_one(l2, has(l2.name) && l1.name == l2.name))"
// +kubebuilder:validation:XValidation:message="Rule name must be unique within the route",rule="self.all(l1, !has(l1.name) || self.exists_one(l2, has(l2.name) && l1.name == l2.name))"
Rules []TCPRouteRule `json:"rules"`
}

Expand Down
2 changes: 1 addition & 1 deletion apis/v1alpha2/tlsroute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ type TLSRouteSpec struct {
//
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:MaxItems=16
// +kubebuilder:validation:XValidation:message="Route name must be unique within the route",rule="self.all(l1, !has(l1.name) || self.exists_one(l2, has(l2.name) && l1.name == l2.name))"
// +kubebuilder:validation:XValidation:message="Rule name must be unique within the route",rule="self.all(l1, !has(l1.name) || self.exists_one(l2, has(l2.name) && l1.name == l2.name))"
Rules []TLSRouteRule `json:"rules"`
}

Expand Down
2 changes: 1 addition & 1 deletion apis/v1alpha2/udproute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type UDPRouteSpec struct {
//
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:MaxItems=16
// +kubebuilder:validation:XValidation:message="Route name must be unique within the route",rule="self.all(l1, !has(l1.name) || self.exists_one(l2, has(l2.name) && l1.name == l2.name))"
// +kubebuilder:validation:XValidation:message="Rule name must be unique within the route",rule="self.all(l1, !has(l1.name) || self.exists_one(l2, has(l2.name) && l1.name == l2.name))"
Rules []UDPRouteRule `json:"rules"`
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions config/crd/standard/gateway.networking.k8s.io_grpcroutes.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions config/crd/standard/gateway.networking.k8s.io_httproutes.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion pkg/test/cel/httproute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,7 @@ func TestHTTPRouteRule(t *testing.T) {
},
{
name: "invalid because multiple names are repeated",
wantErrors: []string{"Route name must be unique within the route"},
wantErrors: []string{"Rule name must be unique within the route"},
rules: []gatewayv1.HTTPRouteRule{
{
Name: ptrTo(gatewayv1.SectionName("name1")),
Expand All @@ -1221,6 +1221,17 @@ func TestHTTPRouteRule(t *testing.T) {
},
},
},
{
name: "valid because names are unique",
wantErrors: nil,
rules: []gatewayv1.HTTPRouteRule{
// Ok to have multiple nil
{Name: nil},
{Name: nil},
{Name: ptrTo(gatewayv1.SectionName("name1"))},
{Name: ptrTo(gatewayv1.SectionName("name2"))},
},
},
}

for _, tc := range tests {
Expand Down

0 comments on commit 689d741

Please sign in to comment.