From 75dd3b21cb3fa913c41e72b48f27f9cbf90e93ee Mon Sep 17 00:00:00 2001 From: Carlisia Thompson Date: Wed, 17 Aug 2022 10:20:32 -0700 Subject: [PATCH 1/5] Add converter pkg to house type conversion helpers --- apis/v1alpha2/converter/httproute.go | 33 +++++++++ apis/v1alpha2/converter/httproute_test.go | 61 +++++++++++++++++ apis/v1alpha2/converter/shared_types.go | 27 ++++++++ apis/v1alpha2/converter/shared_types_test.go | 70 ++++++++++++++++++++ apis/v1beta1/converter/httproute.go | 33 +++++++++ apis/v1beta1/converter/httproute_test.go | 61 +++++++++++++++++ apis/v1beta1/converter/shared_types.go | 27 ++++++++ apis/v1beta1/converter/shared_types_test.go | 70 ++++++++++++++++++++ 8 files changed, 382 insertions(+) create mode 100644 apis/v1alpha2/converter/httproute.go create mode 100644 apis/v1alpha2/converter/httproute_test.go create mode 100644 apis/v1alpha2/converter/shared_types.go create mode 100644 apis/v1alpha2/converter/shared_types_test.go create mode 100644 apis/v1beta1/converter/httproute.go create mode 100644 apis/v1beta1/converter/httproute_test.go create mode 100644 apis/v1beta1/converter/shared_types.go create mode 100644 apis/v1beta1/converter/shared_types_test.go diff --git a/apis/v1alpha2/converter/httproute.go b/apis/v1alpha2/converter/httproute.go new file mode 100644 index 0000000000..32a43dc096 --- /dev/null +++ b/apis/v1alpha2/converter/httproute.go @@ -0,0 +1,33 @@ +/* +Copyright 2022 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 converter + +import ( + gatewayv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" +) + +// HeaderMatchTypePtr translates a string to *PathMatchType +func HeaderMatchTypePtr(s string) *gatewayv1a2.HeaderMatchType { + result := gatewayv1a2.HeaderMatchType(s) + return &result +} + +// PathMatchTypePtr translates a string to *PathMatchType +func PathMatchTypePtr(s string) *gatewayv1a2.PathMatchType { + result := gatewayv1a2.PathMatchType(s) + return &result +} diff --git a/apis/v1alpha2/converter/httproute_test.go b/apis/v1alpha2/converter/httproute_test.go new file mode 100644 index 0000000000..7ca7a342ba --- /dev/null +++ b/apis/v1alpha2/converter/httproute_test.go @@ -0,0 +1,61 @@ +/* +Copyright 2022 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 converter + +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/converter/shared_types.go b/apis/v1alpha2/converter/shared_types.go new file mode 100644 index 0000000000..3834ee8e5f --- /dev/null +++ b/apis/v1alpha2/converter/shared_types.go @@ -0,0 +1,27 @@ +/* +Copyright 2022 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 converter + +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/converter/shared_types_test.go b/apis/v1alpha2/converter/shared_types_test.go new file mode 100644 index 0000000000..ab476dd19f --- /dev/null +++ b/apis/v1alpha2/converter/shared_types_test.go @@ -0,0 +1,70 @@ +/* +Copyright 2022 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 converter + +import ( + "testing" + + gatewayv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" +) + +func Test_PortNumberPtr(t *testing.T) { + var exportedPort65535 gatewayv1a2.PortNumber = 65535 + var exportedPort1 gatewayv1a2.PortNumber = 1 + var exportedPort0 gatewayv1a2.PortNumber + var exportedPort65536 gatewayv1a2.PortNumber = 65536 + + portNumberPtrTests := []struct { + name string + port int + expectedPort *gatewayv1a2.PortNumber + }{ + { + name: "invalid port number", + port: 0, + expectedPort: &exportedPort0, + }, + { + name: "valid port number", + port: 65535, + expectedPort: &exportedPort65535, + }, + { + name: "invalid port number", + port: 65536, + expectedPort: &exportedPort65536, + }, + { + name: "valid port number", + port: 1, + expectedPort: &exportedPort1, + }, + } + + for _, tc := range portNumberPtrTests { + t.Run(tc.name, func(t *testing.T) { + port := PortNumberPtr(tc.port) + if port == nil || tc.expectedPort == nil { + if port != tc.expectedPort { + t.Errorf("Expected port %d, got %d", tc.expectedPort, port) + } + } else if *port != *tc.expectedPort { + t.Errorf("Expected port %d, got %d", *tc.expectedPort, *port) + } + }) + } +} diff --git a/apis/v1beta1/converter/httproute.go b/apis/v1beta1/converter/httproute.go new file mode 100644 index 0000000000..274c5f17f2 --- /dev/null +++ b/apis/v1beta1/converter/httproute.go @@ -0,0 +1,33 @@ +/* +Copyright 2022 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 converter + +import ( + gatewayv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" +) + +// HeaderMatchTypePtr translates a string to *PathMatchType +func HeaderMatchTypePtr(s string) *gatewayv1b1.HeaderMatchType { + result := gatewayv1b1.HeaderMatchType(s) + return &result +} + +// PathMatchTypePtr translates a string to *PathMatchType +func PathMatchTypePtr(s string) *gatewayv1b1.PathMatchType { + result := gatewayv1b1.PathMatchType(s) + return &result +} diff --git a/apis/v1beta1/converter/httproute_test.go b/apis/v1beta1/converter/httproute_test.go new file mode 100644 index 0000000000..c5cf91d5c7 --- /dev/null +++ b/apis/v1beta1/converter/httproute_test.go @@ -0,0 +1,61 @@ +/* +Copyright 2022 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 converter + +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/converter/shared_types.go b/apis/v1beta1/converter/shared_types.go new file mode 100644 index 0000000000..ded9242fc2 --- /dev/null +++ b/apis/v1beta1/converter/shared_types.go @@ -0,0 +1,27 @@ +/* +Copyright 2022 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 converter + +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/converter/shared_types_test.go b/apis/v1beta1/converter/shared_types_test.go new file mode 100644 index 0000000000..344e05d43b --- /dev/null +++ b/apis/v1beta1/converter/shared_types_test.go @@ -0,0 +1,70 @@ +/* +Copyright 2022 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 converter + +import ( + "testing" + + gatewayv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" +) + +func Test_PortNumberPtr(t *testing.T) { + var exportedPort65535 gatewayv1b1.PortNumber = 65535 + var exportedPort1 gatewayv1b1.PortNumber = 1 + var exportedPort0 gatewayv1b1.PortNumber + var exportedPort65536 gatewayv1b1.PortNumber = 65536 + + portNumberPtrTests := []struct { + name string + port int + expectedPort *gatewayv1b1.PortNumber + }{ + { + name: "invalid port number", + port: 0, + expectedPort: &exportedPort0, + }, + { + name: "valid port number", + port: 65535, + expectedPort: &exportedPort65535, + }, + { + name: "invalid port number", + port: 65536, + expectedPort: &exportedPort65536, + }, + { + name: "valid port number", + port: 1, + expectedPort: &exportedPort1, + }, + } + + for _, tc := range portNumberPtrTests { + t.Run(tc.name, func(t *testing.T) { + port := PortNumberPtr(tc.port) + if port == nil || tc.expectedPort == nil { + if port != tc.expectedPort { + t.Errorf("Expected port %d, got %d", tc.expectedPort, port) + } + } else if *port != *tc.expectedPort { + t.Errorf("Expected port %d, got %d", *tc.expectedPort, *port) + } + }) + } +} From 02755babe6f2abe1b5921d8cfd2d24898f109c57 Mon Sep 17 00:00:00 2001 From: Carlisia Thompson Date: Wed, 17 Aug 2022 10:29:30 -0700 Subject: [PATCH 2/5] Use the conversion helper in the converter package --- apis/v1alpha2/validation/httproute_test.go | 58 +++++++++++----------- apis/v1beta1/validation/httproute_test.go | 58 +++++++++++----------- 2 files changed, 58 insertions(+), 58 deletions(-) diff --git a/apis/v1alpha2/validation/httproute_test.go b/apis/v1alpha2/validation/httproute_test.go index c72fb595a4..cd572b20c7 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/converter" ) 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: converter.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: converter.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: converter.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: converter.PortNumberPtr(8081), }, }, }, @@ -97,7 +97,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1a2.HTTPRouteMatch{ { Path: &gatewayv1a2.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: converter.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: converter.PortNumberPtr(8080), }, }, }, @@ -117,7 +117,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{ BackendRef: gatewayv1a2.BackendObjectReference{ Name: specialService, - Port: utils.PortNumberPtr(8080), + Port: converter.PortNumberPtr(8080), }, }, }, @@ -132,7 +132,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1a2.HTTPRouteMatch{ { Path: &gatewayv1a2.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: converter.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: converter.PortNumberPtr(8080), }, }, }, @@ -180,7 +180,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1a2.HTTPRouteMatch{ { Path: &gatewayv1a2.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: converter.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: converter.PortNumberPtr(8080), }, }, }, @@ -211,7 +211,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{ BackendRef: gatewayv1a2.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: converter.PortNumberPtr(8080), }, }, }, @@ -231,7 +231,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{ BackendRef: gatewayv1a2.BackendObjectReference{ Name: specialService, - Port: utils.PortNumberPtr(8080), + Port: converter.PortNumberPtr(8080), }, }, }, @@ -246,7 +246,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1a2.HTTPRouteMatch{ { Path: &gatewayv1a2.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: converter.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: converter.PortNumberPtr(8080), }, }, }, @@ -453,7 +453,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) { BackendRef: gatewayv1a2.BackendRef{ BackendObjectReference: gatewayv1a2.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: converter.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: converter.PortNumberPtr(8080), }, }, }, @@ -480,7 +480,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) { BackendRef: gatewayv1a2.BackendRef{ BackendObjectReference: gatewayv1a2.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: converter.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: converter.PortNumberPtr(8080), }, }, }, @@ -498,7 +498,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) { RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{ BackendRef: gatewayv1a2.BackendObjectReference{ Name: specialService, - Port: utils.PortNumberPtr(8080), + Port: converter.PortNumberPtr(8080), }, }, }, @@ -527,21 +527,21 @@ func TestValidateHTTPPathMatch(t *testing.T) { }{{ name: "invalid httpRoute prefix", path: &gatewayv1a2.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: converter.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/."), }, errCount: 1, }, { name: "invalid httpRoute Exact", path: &gatewayv1a2.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("Exact"), + Type: converter.PathMatchTypePtr("Exact"), Value: utilpointer.String("/foo/./bar"), }, errCount: 1, }, { name: "invalid httpRoute prefix", path: &gatewayv1a2.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: converter.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: converter.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: converter.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: converter.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: converter.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: converter.PortNumberPtr(8080), }, }, }}, diff --git a/apis/v1beta1/validation/httproute_test.go b/apis/v1beta1/validation/httproute_test.go index 231c1f4aa4..066b7a040b 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/converter" ) 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: converter.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: converter.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: converter.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: converter.PortNumberPtr(8081), }, }, }, @@ -97,7 +97,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1b1.HTTPRouteMatch{ { Path: &gatewayv1b1.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: converter.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: converter.PortNumberPtr(8080), }, }, }, @@ -117,7 +117,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1b1.HTTPRequestMirrorFilter{ BackendRef: gatewayv1b1.BackendObjectReference{ Name: specialService, - Port: utils.PortNumberPtr(8080), + Port: converter.PortNumberPtr(8080), }, }, }, @@ -132,7 +132,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1b1.HTTPRouteMatch{ { Path: &gatewayv1b1.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: converter.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: converter.PortNumberPtr(8080), }, }, }, @@ -180,7 +180,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1b1.HTTPRouteMatch{ { Path: &gatewayv1b1.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: converter.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: converter.PortNumberPtr(8080), }, }, }, @@ -211,7 +211,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1b1.HTTPRequestMirrorFilter{ BackendRef: gatewayv1b1.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: converter.PortNumberPtr(8080), }, }, }, @@ -231,7 +231,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1b1.HTTPRequestMirrorFilter{ BackendRef: gatewayv1b1.BackendObjectReference{ Name: specialService, - Port: utils.PortNumberPtr(8080), + Port: converter.PortNumberPtr(8080), }, }, }, @@ -246,7 +246,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1b1.HTTPRouteMatch{ { Path: &gatewayv1b1.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: converter.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: converter.PortNumberPtr(8080), }, }, }, @@ -453,7 +453,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) { BackendRef: gatewayv1b1.BackendRef{ BackendObjectReference: gatewayv1b1.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: converter.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: converter.PortNumberPtr(8080), }, }, }, @@ -480,7 +480,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) { BackendRef: gatewayv1b1.BackendRef{ BackendObjectReference: gatewayv1b1.BackendObjectReference{ Name: testService, - Port: utils.PortNumberPtr(8080), + Port: converter.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: converter.PortNumberPtr(8080), }, }, }, @@ -498,7 +498,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) { RequestMirror: &gatewayv1b1.HTTPRequestMirrorFilter{ BackendRef: gatewayv1b1.BackendObjectReference{ Name: specialService, - Port: utils.PortNumberPtr(8080), + Port: converter.PortNumberPtr(8080), }, }, }, @@ -527,21 +527,21 @@ func TestValidateHTTPPathMatch(t *testing.T) { }{{ name: "invalid httpRoute prefix", path: &gatewayv1b1.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: converter.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/."), }, errCount: 1, }, { name: "invalid httpRoute Exact", path: &gatewayv1b1.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("Exact"), + Type: converter.PathMatchTypePtr("Exact"), Value: utilpointer.String("/foo/./bar"), }, errCount: 1, }, { name: "invalid httpRoute prefix", path: &gatewayv1b1.HTTPPathMatch{ - Type: utils.PathMatchTypePtr("PathPrefix"), + Type: converter.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: converter.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: converter.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: converter.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: converter.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: converter.PortNumberPtr(8080), }, }, }}, From cf845c96b3f4e0e1379909aa257aef397d61e340 Mon Sep 17 00:00:00 2001 From: Carlisia Thompson Date: Wed, 17 Aug 2022 10:33:12 -0700 Subject: [PATCH 3/5] Delete conversion helpers that moved to the converter pkg --- apis/v1alpha2/validation/util/utils.go | 33 ------- apis/v1alpha2/validation/util/utils_test.go | 104 -------------------- apis/v1beta1/validation/util/utils.go | 33 ------- apis/v1beta1/validation/util/utils_test.go | 104 -------------------- 4 files changed, 274 deletions(-) delete mode 100644 apis/v1alpha2/validation/util/utils.go delete mode 100644 apis/v1alpha2/validation/util/utils_test.go delete mode 100644 apis/v1beta1/validation/util/utils.go delete mode 100644 apis/v1beta1/validation/util/utils_test.go diff --git a/apis/v1alpha2/validation/util/utils.go b/apis/v1alpha2/validation/util/utils.go deleted file mode 100644 index 9513bbff27..0000000000 --- a/apis/v1alpha2/validation/util/utils.go +++ /dev/null @@ -1,33 +0,0 @@ -/* -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 utils - -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) - return &result -} - -// 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/validation/util/utils_test.go deleted file mode 100644 index c3131343be..0000000000 --- a/apis/v1alpha2/validation/util/utils_test.go +++ /dev/null @@ -1,104 +0,0 @@ -/* -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 utils - -import ( - "testing" - - gatewayv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" -) - -func Test_PortNumberPtr(t *testing.T) { - var exportedPort65535 gatewayv1a2.PortNumber = 65535 - var exportedPort1 gatewayv1a2.PortNumber = 1 - var exportedPort0 gatewayv1a2.PortNumber - var exportedPort65536 gatewayv1a2.PortNumber = 65536 - - portNumberPtrTests := []struct { - name string - port int - expectedPort *gatewayv1a2.PortNumber - }{ - { - name: "invalid port number", - port: 0, - expectedPort: &exportedPort0, - }, - { - name: "valid port number", - port: 65535, - expectedPort: &exportedPort65535, - }, - { - name: "invalid port number", - port: 65536, - expectedPort: &exportedPort65536, - }, - { - name: "valid port number", - port: 1, - expectedPort: &exportedPort1, - }, - } - - for _, tc := range portNumberPtrTests { - t.Run(tc.name, func(t *testing.T) { - port := PortNumberPtr(tc.port) - if port == nil || tc.expectedPort == nil { - if port != tc.expectedPort { - t.Errorf("Expected port %d, got %d", tc.expectedPort, port) - } - } else if *port != *tc.expectedPort { - t.Errorf("Expected port %d, got %d", *tc.expectedPort, *port) - } - }) - } -} - -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/v1beta1/validation/util/utils.go b/apis/v1beta1/validation/util/utils.go deleted file mode 100644 index 52408574ad..0000000000 --- a/apis/v1beta1/validation/util/utils.go +++ /dev/null @@ -1,33 +0,0 @@ -/* -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 utils - -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) - return &result -} - -// 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/validation/util/utils_test.go deleted file mode 100644 index 9e0deb62da..0000000000 --- a/apis/v1beta1/validation/util/utils_test.go +++ /dev/null @@ -1,104 +0,0 @@ -/* -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 utils - -import ( - "testing" - - gatewayv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" -) - -func Test_PortNumberPtr(t *testing.T) { - var exportedPort65535 gatewayv1b1.PortNumber = 65535 - var exportedPort1 gatewayv1b1.PortNumber = 1 - var exportedPort0 gatewayv1b1.PortNumber - var exportedPort65536 gatewayv1b1.PortNumber = 65536 - - portNumberPtrTests := []struct { - name string - port int - expectedPort *gatewayv1b1.PortNumber - }{ - { - name: "invalid port number", - port: 0, - expectedPort: &exportedPort0, - }, - { - name: "valid port number", - port: 65535, - expectedPort: &exportedPort65535, - }, - { - name: "invalid port number", - port: 65536, - expectedPort: &exportedPort65536, - }, - { - name: "valid port number", - port: 1, - expectedPort: &exportedPort1, - }, - } - - for _, tc := range portNumberPtrTests { - t.Run(tc.name, func(t *testing.T) { - port := PortNumberPtr(tc.port) - if port == nil || tc.expectedPort == nil { - if port != tc.expectedPort { - t.Errorf("Expected port %d, got %d", tc.expectedPort, port) - } - } else if *port != *tc.expectedPort { - t.Errorf("Expected port %d, got %d", *tc.expectedPort, *port) - } - }) - } -} - -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) - } - }) - } -} From 970f25dee9a7a7adbf1fcd439b2ae32b6482d235 Mon Sep 17 00:00:00 2001 From: Carlisia Thompson Date: Thu, 18 Aug 2022 10:22:08 -0700 Subject: [PATCH 4/5] Improve name and location of type translation helpers --- .../translator}/httproute.go | 2 +- .../translator}/httproute_test.go | 2 +- .../translator}/shared_types.go | 2 +- .../translator}/shared_types_test.go | 2 +- apis/v1alpha2/validation/httproute_test.go | 58 +++++++++---------- .../translator}/httproute.go | 2 +- .../translator}/httproute_test.go | 2 +- .../translator}/shared_types.go | 2 +- .../translator}/shared_types_test.go | 2 +- apis/v1beta1/validation/httproute_test.go | 58 +++++++++---------- 10 files changed, 66 insertions(+), 66 deletions(-) rename apis/v1alpha2/{converter => util/translator}/httproute.go (98%) rename apis/v1alpha2/{converter => util/translator}/httproute_test.go (98%) rename apis/v1alpha2/{converter => util/translator}/shared_types.go (97%) rename apis/v1alpha2/{converter => util/translator}/shared_types_test.go (98%) rename apis/v1beta1/{converter => util/translator}/httproute.go (98%) rename apis/v1beta1/{converter => util/translator}/httproute_test.go (98%) rename apis/v1beta1/{converter => util/translator}/shared_types.go (97%) rename apis/v1beta1/{converter => util/translator}/shared_types_test.go (98%) diff --git a/apis/v1alpha2/converter/httproute.go b/apis/v1alpha2/util/translator/httproute.go similarity index 98% rename from apis/v1alpha2/converter/httproute.go rename to apis/v1alpha2/util/translator/httproute.go index 32a43dc096..83baafadce 100644 --- a/apis/v1alpha2/converter/httproute.go +++ b/apis/v1alpha2/util/translator/httproute.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package converter +package translator import ( gatewayv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" diff --git a/apis/v1alpha2/converter/httproute_test.go b/apis/v1alpha2/util/translator/httproute_test.go similarity index 98% rename from apis/v1alpha2/converter/httproute_test.go rename to apis/v1alpha2/util/translator/httproute_test.go index 7ca7a342ba..12127b9fa9 100644 --- a/apis/v1alpha2/converter/httproute_test.go +++ b/apis/v1alpha2/util/translator/httproute_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package converter +package translator import ( "testing" diff --git a/apis/v1alpha2/converter/shared_types.go b/apis/v1alpha2/util/translator/shared_types.go similarity index 97% rename from apis/v1alpha2/converter/shared_types.go rename to apis/v1alpha2/util/translator/shared_types.go index 3834ee8e5f..87557c6eb8 100644 --- a/apis/v1alpha2/converter/shared_types.go +++ b/apis/v1alpha2/util/translator/shared_types.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package converter +package translator import ( gatewayv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" diff --git a/apis/v1alpha2/converter/shared_types_test.go b/apis/v1alpha2/util/translator/shared_types_test.go similarity index 98% rename from apis/v1alpha2/converter/shared_types_test.go rename to apis/v1alpha2/util/translator/shared_types_test.go index ab476dd19f..f33ab7920e 100644 --- a/apis/v1alpha2/converter/shared_types_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 converter +package translator import ( "testing" diff --git a/apis/v1alpha2/validation/httproute_test.go b/apis/v1alpha2/validation/httproute_test.go index cd572b20c7..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" - "sigs.k8s.io/gateway-api/apis/v1alpha2/converter" + "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: converter.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: converter.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: converter.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: converter.PortNumberPtr(8081), + Port: translator.PortNumberPtr(8081), }, }, }, @@ -97,7 +97,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1a2.HTTPRouteMatch{ { Path: &gatewayv1a2.HTTPPathMatch{ - Type: converter.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: converter.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -117,7 +117,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{ BackendRef: gatewayv1a2.BackendObjectReference{ Name: specialService, - Port: converter.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -132,7 +132,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1a2.HTTPRouteMatch{ { Path: &gatewayv1a2.HTTPPathMatch{ - Type: converter.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: converter.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -180,7 +180,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1a2.HTTPRouteMatch{ { Path: &gatewayv1a2.HTTPPathMatch{ - Type: converter.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: converter.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -211,7 +211,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{ BackendRef: gatewayv1a2.BackendObjectReference{ Name: testService, - Port: converter.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -231,7 +231,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{ BackendRef: gatewayv1a2.BackendObjectReference{ Name: specialService, - Port: converter.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -246,7 +246,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1a2.HTTPRouteMatch{ { Path: &gatewayv1a2.HTTPPathMatch{ - Type: converter.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: converter.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -453,7 +453,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) { BackendRef: gatewayv1a2.BackendRef{ BackendObjectReference: gatewayv1a2.BackendObjectReference{ Name: testService, - Port: converter.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: converter.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -480,7 +480,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) { BackendRef: gatewayv1a2.BackendRef{ BackendObjectReference: gatewayv1a2.BackendObjectReference{ Name: testService, - Port: converter.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: converter.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -498,7 +498,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) { RequestMirror: &gatewayv1a2.HTTPRequestMirrorFilter{ BackendRef: gatewayv1a2.BackendObjectReference{ Name: specialService, - Port: converter.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -527,21 +527,21 @@ func TestValidateHTTPPathMatch(t *testing.T) { }{{ name: "invalid httpRoute prefix", path: &gatewayv1a2.HTTPPathMatch{ - Type: converter.PathMatchTypePtr("PathPrefix"), + Type: translator.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/."), }, errCount: 1, }, { name: "invalid httpRoute Exact", path: &gatewayv1a2.HTTPPathMatch{ - Type: converter.PathMatchTypePtr("Exact"), + Type: translator.PathMatchTypePtr("Exact"), Value: utilpointer.String("/foo/./bar"), }, errCount: 1, }, { name: "invalid httpRoute prefix", path: &gatewayv1a2.HTTPPathMatch{ - Type: converter.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: converter.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: converter.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: converter.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: converter.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: converter.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }}, diff --git a/apis/v1beta1/converter/httproute.go b/apis/v1beta1/util/translator/httproute.go similarity index 98% rename from apis/v1beta1/converter/httproute.go rename to apis/v1beta1/util/translator/httproute.go index 274c5f17f2..b491806692 100644 --- a/apis/v1beta1/converter/httproute.go +++ b/apis/v1beta1/util/translator/httproute.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package converter +package translator import ( gatewayv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" diff --git a/apis/v1beta1/converter/httproute_test.go b/apis/v1beta1/util/translator/httproute_test.go similarity index 98% rename from apis/v1beta1/converter/httproute_test.go rename to apis/v1beta1/util/translator/httproute_test.go index c5cf91d5c7..4cd0e29d75 100644 --- a/apis/v1beta1/converter/httproute_test.go +++ b/apis/v1beta1/util/translator/httproute_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package converter +package translator import ( "testing" diff --git a/apis/v1beta1/converter/shared_types.go b/apis/v1beta1/util/translator/shared_types.go similarity index 97% rename from apis/v1beta1/converter/shared_types.go rename to apis/v1beta1/util/translator/shared_types.go index ded9242fc2..4da4eabf44 100644 --- a/apis/v1beta1/converter/shared_types.go +++ b/apis/v1beta1/util/translator/shared_types.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package converter +package translator import ( gatewayv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" diff --git a/apis/v1beta1/converter/shared_types_test.go b/apis/v1beta1/util/translator/shared_types_test.go similarity index 98% rename from apis/v1beta1/converter/shared_types_test.go rename to apis/v1beta1/util/translator/shared_types_test.go index 344e05d43b..4093db30c3 100644 --- a/apis/v1beta1/converter/shared_types_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 converter +package translator import ( "testing" diff --git a/apis/v1beta1/validation/httproute_test.go b/apis/v1beta1/validation/httproute_test.go index 066b7a040b..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" - "sigs.k8s.io/gateway-api/apis/v1beta1/converter" + "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: converter.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: converter.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: converter.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: converter.PortNumberPtr(8081), + Port: translator.PortNumberPtr(8081), }, }, }, @@ -97,7 +97,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1b1.HTTPRouteMatch{ { Path: &gatewayv1b1.HTTPPathMatch{ - Type: converter.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: converter.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -117,7 +117,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1b1.HTTPRequestMirrorFilter{ BackendRef: gatewayv1b1.BackendObjectReference{ Name: specialService, - Port: converter.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -132,7 +132,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1b1.HTTPRouteMatch{ { Path: &gatewayv1b1.HTTPPathMatch{ - Type: converter.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: converter.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -180,7 +180,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1b1.HTTPRouteMatch{ { Path: &gatewayv1b1.HTTPPathMatch{ - Type: converter.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: converter.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -211,7 +211,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1b1.HTTPRequestMirrorFilter{ BackendRef: gatewayv1b1.BackendObjectReference{ Name: testService, - Port: converter.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -231,7 +231,7 @@ func TestValidateHTTPRoute(t *testing.T) { RequestMirror: &gatewayv1b1.HTTPRequestMirrorFilter{ BackendRef: gatewayv1b1.BackendObjectReference{ Name: specialService, - Port: converter.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -246,7 +246,7 @@ func TestValidateHTTPRoute(t *testing.T) { Matches: []gatewayv1b1.HTTPRouteMatch{ { Path: &gatewayv1b1.HTTPPathMatch{ - Type: converter.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: converter.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -453,7 +453,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) { BackendRef: gatewayv1b1.BackendRef{ BackendObjectReference: gatewayv1b1.BackendObjectReference{ Name: testService, - Port: converter.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: converter.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -480,7 +480,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) { BackendRef: gatewayv1b1.BackendRef{ BackendObjectReference: gatewayv1b1.BackendObjectReference{ Name: testService, - Port: converter.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: converter.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -498,7 +498,7 @@ func TestValidateHTTPBackendUniqueFilters(t *testing.T) { RequestMirror: &gatewayv1b1.HTTPRequestMirrorFilter{ BackendRef: gatewayv1b1.BackendObjectReference{ Name: specialService, - Port: converter.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }, @@ -527,21 +527,21 @@ func TestValidateHTTPPathMatch(t *testing.T) { }{{ name: "invalid httpRoute prefix", path: &gatewayv1b1.HTTPPathMatch{ - Type: converter.PathMatchTypePtr("PathPrefix"), + Type: translator.PathMatchTypePtr("PathPrefix"), Value: utilpointer.String("/."), }, errCount: 1, }, { name: "invalid httpRoute Exact", path: &gatewayv1b1.HTTPPathMatch{ - Type: converter.PathMatchTypePtr("Exact"), + Type: translator.PathMatchTypePtr("Exact"), Value: utilpointer.String("/foo/./bar"), }, errCount: 1, }, { name: "invalid httpRoute prefix", path: &gatewayv1b1.HTTPPathMatch{ - Type: converter.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: converter.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: converter.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: converter.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: converter.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: converter.PortNumberPtr(8080), + Port: translator.PortNumberPtr(8080), }, }, }}, From 94e6982f6785fe9a85ecfdba267ce23bb554bc9d Mon Sep 17 00:00:00 2001 From: Carlisia Thompson Date: Thu, 18 Aug 2022 10:25:37 -0700 Subject: [PATCH 5/5] Keep year coded was authored --- apis/v1alpha2/util/translator/httproute.go | 2 +- apis/v1alpha2/util/translator/httproute_test.go | 2 +- apis/v1alpha2/util/translator/shared_types.go | 2 +- apis/v1alpha2/util/translator/shared_types_test.go | 2 +- apis/v1beta1/util/translator/httproute.go | 4 ++-- apis/v1beta1/util/translator/httproute_test.go | 2 +- apis/v1beta1/util/translator/shared_types.go | 2 +- apis/v1beta1/util/translator/shared_types_test.go | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apis/v1alpha2/util/translator/httproute.go b/apis/v1alpha2/util/translator/httproute.go index 83baafadce..be5db9e095 100644 --- a/apis/v1alpha2/util/translator/httproute.go +++ b/apis/v1alpha2/util/translator/httproute.go @@ -1,5 +1,5 @@ /* -Copyright 2022 The Kubernetes Authors. +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. diff --git a/apis/v1alpha2/util/translator/httproute_test.go b/apis/v1alpha2/util/translator/httproute_test.go index 12127b9fa9..0b6986e2b2 100644 --- a/apis/v1alpha2/util/translator/httproute_test.go +++ b/apis/v1alpha2/util/translator/httproute_test.go @@ -1,5 +1,5 @@ /* -Copyright 2022 The Kubernetes Authors. +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. diff --git a/apis/v1alpha2/util/translator/shared_types.go b/apis/v1alpha2/util/translator/shared_types.go index 87557c6eb8..92813e70c9 100644 --- a/apis/v1alpha2/util/translator/shared_types.go +++ b/apis/v1alpha2/util/translator/shared_types.go @@ -1,5 +1,5 @@ /* -Copyright 2022 The Kubernetes Authors. +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. diff --git a/apis/v1alpha2/util/translator/shared_types_test.go b/apis/v1alpha2/util/translator/shared_types_test.go index f33ab7920e..5967049a94 100644 --- a/apis/v1alpha2/util/translator/shared_types_test.go +++ b/apis/v1alpha2/util/translator/shared_types_test.go @@ -1,5 +1,5 @@ /* -Copyright 2022 The Kubernetes Authors. +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. diff --git a/apis/v1beta1/util/translator/httproute.go b/apis/v1beta1/util/translator/httproute.go index b491806692..1603781d87 100644 --- a/apis/v1beta1/util/translator/httproute.go +++ b/apis/v1beta1/util/translator/httproute.go @@ -1,5 +1,5 @@ /* -Copyright 2022 The Kubernetes Authors. +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. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package translator +package translator import ( gatewayv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1" diff --git a/apis/v1beta1/util/translator/httproute_test.go b/apis/v1beta1/util/translator/httproute_test.go index 4cd0e29d75..8c1e002530 100644 --- a/apis/v1beta1/util/translator/httproute_test.go +++ b/apis/v1beta1/util/translator/httproute_test.go @@ -1,5 +1,5 @@ /* -Copyright 2022 The Kubernetes Authors. +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. diff --git a/apis/v1beta1/util/translator/shared_types.go b/apis/v1beta1/util/translator/shared_types.go index 4da4eabf44..e9fed02021 100644 --- a/apis/v1beta1/util/translator/shared_types.go +++ b/apis/v1beta1/util/translator/shared_types.go @@ -1,5 +1,5 @@ /* -Copyright 2022 The Kubernetes Authors. +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. diff --git a/apis/v1beta1/util/translator/shared_types_test.go b/apis/v1beta1/util/translator/shared_types_test.go index 4093db30c3..ba98514079 100644 --- a/apis/v1beta1/util/translator/shared_types_test.go +++ b/apis/v1beta1/util/translator/shared_types_test.go @@ -1,5 +1,5 @@ /* -Copyright 2022 The Kubernetes Authors. +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.