diff --git a/apis/v1alpha2/validation/util/utils.go b/apis/v1alpha2/util/translator/httproute.go similarity index 81% rename from apis/v1alpha2/validation/util/utils.go rename to apis/v1alpha2/util/translator/httproute.go index 9513bbff27..be5db9e095 100644 --- a/apis/v1alpha2/validation/util/utils.go +++ b/apis/v1alpha2/util/translator/httproute.go @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -package utils +package translator import ( gatewayv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" ) -// PathMatchTypePtr translates a string to *PathMatchType -func PathMatchTypePtr(s string) *gatewayv1a2.PathMatchType { - result := gatewayv1a2.PathMatchType(s) +// HeaderMatchTypePtr translates a string to *PathMatchType +func HeaderMatchTypePtr(s string) *gatewayv1a2.HeaderMatchType { + result := gatewayv1a2.HeaderMatchType(s) return &result } -// PortNumberPtr translates an int to a *PortNumber -func PortNumberPtr(p int) *gatewayv1a2.PortNumber { - result := gatewayv1a2.PortNumber(p) +// PathMatchTypePtr translates a string to *PathMatchType +func PathMatchTypePtr(s string) *gatewayv1a2.PathMatchType { + result := gatewayv1a2.PathMatchType(s) return &result } diff --git a/apis/v1alpha2/util/translator/httproute_test.go b/apis/v1alpha2/util/translator/httproute_test.go new file mode 100644 index 0000000000..0b6986e2b2 --- /dev/null +++ b/apis/v1alpha2/util/translator/httproute_test.go @@ -0,0 +1,61 @@ +/* +Copyright 2021 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package translator + +import ( + "testing" + + gatewayv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" +) + +func Test_PathMatchTypePtr(t *testing.T) { + pathMatchTypePtrTests := []struct { + name string + pathType string + expectedPath gatewayv1a2.PathMatchType + }{ + { + name: "valid path exact match", + pathType: "Exact", + expectedPath: gatewayv1a2.PathMatchExact, + }, + { + name: "valid path exact match using constant", + pathType: string(gatewayv1a2.PathMatchExact), + expectedPath: gatewayv1a2.PathMatchExact, + }, + { + name: "valid path prefix match", + pathType: "PathPrefix", + expectedPath: gatewayv1a2.PathMatchPathPrefix, + }, + { + name: "valid path regular expression match", + pathType: "RegularExpression", + expectedPath: gatewayv1a2.PathMatchRegularExpression, + }, + } + + for _, tc := range pathMatchTypePtrTests { + t.Run(tc.name, func(t *testing.T) { + path := PathMatchTypePtr(tc.pathType) + if *path != tc.expectedPath { + t.Errorf("Expected path %s, got %s", tc.expectedPath, *path) + } + }) + } +} diff --git a/apis/v1alpha2/util/translator/shared_types.go b/apis/v1alpha2/util/translator/shared_types.go new file mode 100644 index 0000000000..92813e70c9 --- /dev/null +++ b/apis/v1alpha2/util/translator/shared_types.go @@ -0,0 +1,27 @@ +/* +Copyright 2021 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package translator + +import ( + gatewayv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" +) + +// PortNumberPtr translates an int to a *PortNumber +func PortNumberPtr(p int) *gatewayv1a2.PortNumber { + result := gatewayv1a2.PortNumber(p) + return &result +} diff --git a/apis/v1alpha2/validation/util/utils_test.go b/apis/v1alpha2/util/translator/shared_types_test.go similarity index 68% rename from apis/v1alpha2/validation/util/utils_test.go rename to apis/v1alpha2/util/translator/shared_types_test.go index c3131343be..5967049a94 100644 --- a/apis/v1alpha2/validation/util/utils_test.go +++ b/apis/v1alpha2/util/translator/shared_types_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package utils +package translator import ( "testing" @@ -68,37 +68,3 @@ func Test_PortNumberPtr(t *testing.T) { }) } } - -func Test_PathMatchTypePtr(t *testing.T) { - pathMatchTypePtrTests := []struct { - name string - pathType string - expectedPath gatewayv1a2.PathMatchType - }{ - { - name: "valid path exact match", - pathType: "Exact", - expectedPath: gatewayv1a2.PathMatchExact, - }, - - { - name: "valid path prefix match", - pathType: "PathPrefix", - expectedPath: gatewayv1a2.PathMatchPathPrefix, - }, - { - name: "valid path regular expression match", - pathType: "RegularExpression", - expectedPath: gatewayv1a2.PathMatchRegularExpression, - }, - } - - for _, tc := range pathMatchTypePtrTests { - t.Run(tc.name, func(t *testing.T) { - path := PathMatchTypePtr(tc.pathType) - if *path != tc.expectedPath { - t.Errorf("Expected path %s, got %s", tc.expectedPath, *path) - } - }) - } -} diff --git a/apis/v1alpha2/validation/httproute_test.go b/apis/v1alpha2/validation/httproute_test.go index c72fb595a4..d5af02fcb0 100644 --- a/apis/v1alpha2/validation/httproute_test.go +++ b/apis/v1alpha2/validation/httproute_test.go @@ -25,7 +25,7 @@ import ( utilpointer "k8s.io/utils/pointer" gatewayv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" - utils "sigs.k8s.io/gateway-api/apis/v1alpha2/validation/util" + "sigs.k8s.io/gateway-api/apis/v1alpha2/util/translator" ) func TestValidateHTTPRoute(t *testing.T) { @@ -45,7 +45,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1a2.HTTPRouteMatch{ { Path: &gatewayv1a2.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: translator.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/"), }, }, @@ -55,7 +55,7 @@ func TestValidateHTTPRoute(t *testing.T) { BackendRef: gatewayv1a2.BackendRef{ BackendObjectReference: gatewayv1a2.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, Weight: utilpointer.Int32(100), }, @@ -71,7 +71,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1a2.HTTPRouteMatch{ { Path: &gatewayv1a2.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: translator.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/"), }, }, @@ -82,7 +82,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{ BackendRef: gatewayv1a2.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8081), + Port: translator.PortNumberPtr(8081), }, }, }, @@ -97,7 +97,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1a2.HTTPRouteMatch{ { Path: &gatewayv1a2.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: translator.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/"), }, }, @@ -108,7 +108,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{ BackendRef: gatewayv1a2.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -117,7 +117,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{ BackendRef: gatewayv1a2.BackendObjectReference{ Name: specialService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -132,7 +132,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1a2.HTTPRouteMatch{ { Path: &gatewayv1a2.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: translator.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/"), }, }, @@ -154,7 +154,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{ BackendRef: gatewayv1a2.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -180,7 +180,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1a2.HTTPRouteMatch{ { Path: &gatewayv1a2.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: translator.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/"), }, }, @@ -191,7 +191,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{ BackendRef: gatewayv1a2.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -211,7 +211,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{ BackendRef: gatewayv1a2.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -231,7 +231,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{ BackendRef: gatewayv1a2.BackendObjectReference{ Name: specialService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -246,7 +246,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1a2.HTTPRouteMatch{ { Path: &gatewayv1a2.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: translator.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/"), }, }, @@ -268,7 +268,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{ BackendRef: gatewayv1a2.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -453,7 +453,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) { BackendRef: gatewayv1a2.BackendRef{ BackendObjectReference: gatewayv1a2.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, Weight: utilpointer.Int32(100), }, @@ -463,7 +463,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) { RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{ BackendRef: gatewayv1a2.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -480,7 +480,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) { BackendRef: gatewayv1a2.BackendRef{ BackendObjectReference: gatewayv1a2.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, Filters: []gatewayv1a2.HTTPRouteFilter{ @@ -489,7 +489,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) { RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{ BackendRef: gatewayv1a2.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -498,7 +498,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) { RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{ BackendRef: gatewayv1a2.BackendObjectReference{ Name: specialService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -527,21 +527,21 @@ func TestValidateHTTPPathMatch(t *testing.T) { }{{ name: "invalid httpRoute prefix", path: &gatewayv1a2.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: translator.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/."), }, errCount: 1, }, { name: "invalid httpRoute Exact", path: &gatewayv1a2.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("Exact"), + Type: translator.PathMatchTypePtr("Exact"), Value: utilpointer.String("/foo/./bar"), }, errCount: 1, }, { name: "invalid httpRoute prefix", path: &gatewayv1a2.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: translator.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/"), }, errCount: 0, @@ -558,7 +558,7 @@ func TestValidateHTTPPathMatch(t *testing.T) { BackendRef: gatewayv1a2.BackendRef{ BackendObjectReference: gatewayv1a2.BackendObjectReference{ Name: gatewayv1a2.ObjectName("test"), - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }}, @@ -619,7 +619,7 @@ func TestValidateHTTPHeaderMatches(t *testing.T) { BackendRef: gatewayv1a2.BackendRef{ BackendObjectReference: gatewayv1a2.BackendObjectReference{ Name: gatewayv1a2.ObjectName("test"), - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }}, @@ -683,7 +683,7 @@ func TestValidateHTTPQueryParamMatches(t *testing.T) { BackendRef: gatewayv1a2.BackendRef{ BackendObjectReference: gatewayv1a2.BackendObjectReference{ Name: gatewayv1a2.ObjectName("test"), - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }}, @@ -840,7 +840,7 @@ func TestValidateHTTPRouteTypeMatchesField(t *testing.T) { Kind: new(gatewayv1a2.Kind), Name: "name", Namespace: new(gatewayv1a2.Namespace), - Port: utils.PortNumberPtr(22), + Port: translator.PortNumberPtr(22), }}, }, errCount: 0, @@ -946,7 +946,7 @@ func TestValidateHTTPRouteTypeMatchesField(t *testing.T) { BackendRef: gatewayv1a2.BackendRef{ BackendObjectReference: gatewayv1a2.BackendObjectReference{ Name: gatewayv1a2.ObjectName("test"), - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }}, diff --git a/apis/v1beta1/validation/util/utils.go b/apis/v1beta1/util/translator/httproute.go similarity index 81% rename from apis/v1beta1/validation/util/utils.go rename to apis/v1beta1/util/translator/httproute.go index 52408574ad..1603781d87 100644 --- a/apis/v1beta1/validation/util/utils.go +++ b/apis/v1beta1/util/translator/httproute.go @@ -14,20 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -package utils +package translator import ( gatewayv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" ) -// PathMatchTypePtr translates a string to *PathMatchType -func PathMatchTypePtr(s string) *gatewayv1b1.PathMatchType { - result := gatewayv1b1.PathMatchType(s) +// HeaderMatchTypePtr translates a string to *PathMatchType +func HeaderMatchTypePtr(s string) *gatewayv1b1.HeaderMatchType { + result := gatewayv1b1.HeaderMatchType(s) return &result } -// PortNumberPtr translates an int to a *PortNumber -func PortNumberPtr(p int) *gatewayv1b1.PortNumber { - result := gatewayv1b1.PortNumber(p) +// PathMatchTypePtr translates a string to *PathMatchType +func PathMatchTypePtr(s string) *gatewayv1b1.PathMatchType { + result := gatewayv1b1.PathMatchType(s) return &result } diff --git a/apis/v1beta1/util/translator/httproute_test.go b/apis/v1beta1/util/translator/httproute_test.go new file mode 100644 index 0000000000..8c1e002530 --- /dev/null +++ b/apis/v1beta1/util/translator/httproute_test.go @@ -0,0 +1,61 @@ +/* +Copyright 2021 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package translator + +import ( + "testing" + + gatewayv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" +) + +func Test_PathMatchTypePtr(t *testing.T) { + pathMatchTypePtrTests := []struct { + name string + pathType string + expectedPath gatewayv1b1.PathMatchType + }{ + { + name: "valid path exact match", + pathType: "Exact", + expectedPath: gatewayv1b1.PathMatchExact, + }, + { + name: "valid path exact match using constant", + pathType: string(gatewayv1b1.PathMatchExact), + expectedPath: gatewayv1b1.PathMatchExact, + }, + { + name: "valid path prefix match", + pathType: "PathPrefix", + expectedPath: gatewayv1b1.PathMatchPathPrefix, + }, + { + name: "valid path regular expression match", + pathType: "RegularExpression", + expectedPath: gatewayv1b1.PathMatchRegularExpression, + }, + } + + for _, tc := range pathMatchTypePtrTests { + t.Run(tc.name, func(t *testing.T) { + path := PathMatchTypePtr(tc.pathType) + if *path != tc.expectedPath { + t.Errorf("Expected path %s, got %s", tc.expectedPath, *path) + } + }) + } +} diff --git a/apis/v1beta1/util/translator/shared_types.go b/apis/v1beta1/util/translator/shared_types.go new file mode 100644 index 0000000000..e9fed02021 --- /dev/null +++ b/apis/v1beta1/util/translator/shared_types.go @@ -0,0 +1,27 @@ +/* +Copyright 2021 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package translator + +import ( + gatewayv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" +) + +// PortNumberPtr translates an int to a *PortNumber +func PortNumberPtr(p int) *gatewayv1b1.PortNumber { + result := gatewayv1b1.PortNumber(p) + return &result +} diff --git a/apis/v1beta1/validation/util/utils_test.go b/apis/v1beta1/util/translator/shared_types_test.go similarity index 68% rename from apis/v1beta1/validation/util/utils_test.go rename to apis/v1beta1/util/translator/shared_types_test.go index 9e0deb62da..ba98514079 100644 --- a/apis/v1beta1/validation/util/utils_test.go +++ b/apis/v1beta1/util/translator/shared_types_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package utils +package translator import ( "testing" @@ -68,37 +68,3 @@ func Test_PortNumberPtr(t *testing.T) { }) } } - -func Test_PathMatchTypePtr(t *testing.T) { - pathMatchTypePtrTests := []struct { - name string - pathType string - expectedPath gatewayv1b1.PathMatchType - }{ - { - name: "valid path exact match", - pathType: "Exact", - expectedPath: gatewayv1b1.PathMatchExact, - }, - - { - name: "valid path prefix match", - pathType: "PathPrefix", - expectedPath: gatewayv1b1.PathMatchPathPrefix, - }, - { - name: "valid path regular expression match", - pathType: "RegularExpression", - expectedPath: gatewayv1b1.PathMatchRegularExpression, - }, - } - - for _, tc := range pathMatchTypePtrTests { - t.Run(tc.name, func(t *testing.T) { - path := PathMatchTypePtr(tc.pathType) - if *path != tc.expectedPath { - t.Errorf("Expected path %s, got %s", tc.expectedPath, *path) - } - }) - } -} diff --git a/apis/v1beta1/validation/httproute_test.go b/apis/v1beta1/validation/httproute_test.go index 231c1f4aa4..89ada2ab46 100644 --- a/apis/v1beta1/validation/httproute_test.go +++ b/apis/v1beta1/validation/httproute_test.go @@ -25,7 +25,7 @@ import ( utilpointer "k8s.io/utils/pointer" gatewayv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" - utils "sigs.k8s.io/gateway-api/apis/v1beta1/validation/util" + "sigs.k8s.io/gateway-api/apis/v1beta1/util/translator" ) func TestValidateHTTPRoute(t *testing.T) { @@ -45,7 +45,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1b1.HTTPRouteMatch{ { Path: &gatewayv1b1.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: translator.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/"), }, }, @@ -55,7 +55,7 @@ func TestValidateHTTPRoute(t *testing.T) { BackendRef: gatewayv1b1.BackendRef{ BackendObjectReference: gatewayv1b1.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, Weight: utilpointer.Int32(100), }, @@ -71,7 +71,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1b1.HTTPRouteMatch{ { Path: &gatewayv1b1.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: translator.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/"), }, }, @@ -82,7 +82,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1b1.HTTPRequestMirrorFilter{ BackendRef: gatewayv1b1.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8081), + Port: translator.PortNumberPtr(8081), }, }, }, @@ -97,7 +97,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1b1.HTTPRouteMatch{ { Path: &gatewayv1b1.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: translator.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/"), }, }, @@ -108,7 +108,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1b1.HTTPRequestMirrorFilter{ BackendRef: gatewayv1b1.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -117,7 +117,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1b1.HTTPRequestMirrorFilter{ BackendRef: gatewayv1b1.BackendObjectReference{ Name: specialService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -132,7 +132,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1b1.HTTPRouteMatch{ { Path: &gatewayv1b1.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: translator.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/"), }, }, @@ -154,7 +154,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1b1.HTTPRequestMirrorFilter{ BackendRef: gatewayv1b1.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -180,7 +180,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1b1.HTTPRouteMatch{ { Path: &gatewayv1b1.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: translator.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/"), }, }, @@ -191,7 +191,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1b1.HTTPRequestMirrorFilter{ BackendRef: gatewayv1b1.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -211,7 +211,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1b1.HTTPRequestMirrorFilter{ BackendRef: gatewayv1b1.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -231,7 +231,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1b1.HTTPRequestMirrorFilter{ BackendRef: gatewayv1b1.BackendObjectReference{ Name: specialService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -246,7 +246,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1b1.HTTPRouteMatch{ { Path: &gatewayv1b1.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: translator.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/"), }, }, @@ -268,7 +268,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1b1.HTTPRequestMirrorFilter{ BackendRef: gatewayv1b1.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -453,7 +453,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) { BackendRef: gatewayv1b1.BackendRef{ BackendObjectReference: gatewayv1b1.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, Weight: utilpointer.Int32(100), }, @@ -463,7 +463,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) { RequestMirror: &gatewayv1b1.HTTPRequestMirrorFilter{ BackendRef: gatewayv1b1.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -480,7 +480,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) { BackendRef: gatewayv1b1.BackendRef{ BackendObjectReference: gatewayv1b1.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, Filters: []gatewayv1b1.HTTPRouteFilter{ @@ -489,7 +489,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) { RequestMirror: &gatewayv1b1.HTTPRequestMirrorFilter{ BackendRef: gatewayv1b1.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -498,7 +498,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) { RequestMirror: &gatewayv1b1.HTTPRequestMirrorFilter{ BackendRef: gatewayv1b1.BackendObjectReference{ Name: specialService, - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -527,21 +527,21 @@ func TestValidateHTTPPathMatch(t *testing.T) { }{{ name: "invalid httpRoute prefix", path: &gatewayv1b1.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: translator.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/."), }, errCount: 1, }, { name: "invalid httpRoute Exact", path: &gatewayv1b1.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("Exact"), + Type: translator.PathMatchTypePtr("Exact"), Value: utilpointer.String("/foo/./bar"), }, errCount: 1, }, { name: "invalid httpRoute prefix", path: &gatewayv1b1.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: translator.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/"), }, errCount: 0, @@ -558,7 +558,7 @@ func TestValidateHTTPPathMatch(t *testing.T) { BackendRef: gatewayv1b1.BackendRef{ BackendObjectReference: gatewayv1b1.BackendObjectReference{ Name: gatewayv1b1.ObjectName("test"), - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }}, @@ -619,7 +619,7 @@ func TestValidateHTTPHeaderMatches(t *testing.T) { BackendRef: gatewayv1b1.BackendRef{ BackendObjectReference: gatewayv1b1.BackendObjectReference{ Name: gatewayv1b1.ObjectName("test"), - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }}, @@ -683,7 +683,7 @@ func TestValidateHTTPQueryParamMatches(t *testing.T) { BackendRef: gatewayv1b1.BackendRef{ BackendObjectReference: gatewayv1b1.BackendObjectReference{ Name: gatewayv1b1.ObjectName("test"), - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }}, @@ -840,7 +840,7 @@ func TestValidateHTTPRouteTypeMatchesField(t *testing.T) { Kind: new(gatewayv1b1.Kind), Name: "name", Namespace: new(gatewayv1b1.Namespace), - Port: utils.PortNumberPtr(22), + Port: translator.PortNumberPtr(22), }}, }, errCount: 0, @@ -946,7 +946,7 @@ func TestValidateHTTPRouteTypeMatchesField(t *testing.T) { BackendRef: gatewayv1b1.BackendRef{ BackendObjectReference: gatewayv1b1.BackendObjectReference{ Name: gatewayv1b1.ObjectName("test"), - Port: utils.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }},