From a3bad78dcfe0b0334124e30af437ab875f4c5938 Mon Sep 17 00:00:00 2001 From: Ciara Stacke <18287516+ciarams87@users.noreply.github.com> Date: Fri, 20 Jan 2023 14:26:08 +0000 Subject: [PATCH] Output of gofumpt and remove deprecated references --- internal/certmanager/test_files/actions.go | 2 +- .../certmanager/test_files/context_builder.go | 2 +- internal/certmanager/test_files/reactors.go | 2 +- internal/certmanager/test_files/recorder.go | 2 +- internal/certmanager/test_files/util.go | 2 +- internal/k8s/validation.go | 2 +- .../validation/globalconfiguration.go | 4 +-- pkg/apis/configuration/validation/policy.go | 1 + .../validation/transportserver.go | 6 ++-- .../validation/transportserver_test.go | 8 ++--- .../configuration/validation/virtualserver.go | 28 +++++++-------- .../validation/virtualserver_test.go | 36 +++++++++---------- 12 files changed, 48 insertions(+), 47 deletions(-) diff --git a/internal/certmanager/test_files/actions.go b/internal/certmanager/test_files/actions.go index ab9f2e9518..66469ed7da 100644 --- a/internal/certmanager/test_files/actions.go +++ b/internal/certmanager/test_files/actions.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -//nolint +// nolint package test import ( diff --git a/internal/certmanager/test_files/context_builder.go b/internal/certmanager/test_files/context_builder.go index adc4e56d74..3caa3c70a7 100644 --- a/internal/certmanager/test_files/context_builder.go +++ b/internal/certmanager/test_files/context_builder.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -//nolint +// nolint package test import ( diff --git a/internal/certmanager/test_files/reactors.go b/internal/certmanager/test_files/reactors.go index 97e6f2ade0..8dcdcfb81e 100644 --- a/internal/certmanager/test_files/reactors.go +++ b/internal/certmanager/test_files/reactors.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -//nolint +// nolint package test import ( diff --git a/internal/certmanager/test_files/recorder.go b/internal/certmanager/test_files/recorder.go index 15e2db93d2..46484d8512 100644 --- a/internal/certmanager/test_files/recorder.go +++ b/internal/certmanager/test_files/recorder.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -//nolint +// nolint package test import ( diff --git a/internal/certmanager/test_files/util.go b/internal/certmanager/test_files/util.go index 2c7b83526a..7dfdb27624 100644 --- a/internal/certmanager/test_files/util.go +++ b/internal/certmanager/test_files/util.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -//nolint +// nolint package test import ( diff --git a/internal/k8s/validation.go b/internal/k8s/validation.go index f5f6a5fb8e..68ec058448 100644 --- a/internal/k8s/validation.go +++ b/internal/k8s/validation.go @@ -830,7 +830,7 @@ func validateIngressSpec(spec *networking.IngressSpec, fieldPath *field.Path) fi allErrs = append(allErrs, validateBackend(spec.DefaultBackend, fieldPath.Child("defaultBackend"))...) } - allHosts := sets.String{} + allHosts := sets.Set[string]{} if len(spec.Rules) == 0 { return append(allErrs, field.Required(fieldPath.Child("rules"), "")) diff --git a/pkg/apis/configuration/validation/globalconfiguration.go b/pkg/apis/configuration/validation/globalconfiguration.go index 7abbf0550a..a4454865e1 100644 --- a/pkg/apis/configuration/validation/globalconfiguration.go +++ b/pkg/apis/configuration/validation/globalconfiguration.go @@ -34,8 +34,8 @@ func (gcv *GlobalConfigurationValidator) validateGlobalConfigurationSpec(spec *v func (gcv *GlobalConfigurationValidator) validateListeners(listeners []v1alpha1.Listener, fieldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} - listenerNames := sets.String{} - portProtocolCombinations := sets.String{} + listenerNames := sets.Set[string]{} + portProtocolCombinations := sets.Set[string]{} for i, l := range listeners { idxPath := fieldPath.Index(i) diff --git a/pkg/apis/configuration/validation/policy.go b/pkg/apis/configuration/validation/policy.go index 19a2aa792e..290103e0b9 100644 --- a/pkg/apis/configuration/validation/policy.go +++ b/pkg/apis/configuration/validation/policy.go @@ -185,6 +185,7 @@ func validateJWT(jwt *v1.JWTAuth, fieldPath *field.Path) field.ErrorList { return allErrs } + func validateBasic(basic *v1.BasicAuth, fieldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} diff --git a/pkg/apis/configuration/validation/transportserver.go b/pkg/apis/configuration/validation/transportserver.go index a681fe371f..585dd25391 100644 --- a/pkg/apis/configuration/validation/transportserver.go +++ b/pkg/apis/configuration/validation/transportserver.go @@ -151,9 +151,9 @@ func validateListenerProtocol(protocol string, fieldPath *field.Path) field.Erro return allErrs } -func validateTransportServerUpstreams(upstreams []v1alpha1.Upstream, fieldPath *field.Path, isPlus bool) (allErrs field.ErrorList, upstreamNames sets.String) { +func validateTransportServerUpstreams(upstreams []v1alpha1.Upstream, fieldPath *field.Path, isPlus bool) (allErrs field.ErrorList, upstreamNames sets.Set[string]) { allErrs = field.ErrorList{} - upstreamNames = sets.String{} + upstreamNames = sets.Set[string]{} for i, u := range upstreams { idxPath := fieldPath.Index(i) @@ -399,7 +399,7 @@ func validateUDPUpstreamParameter(parameter *int, fieldPath *field.Path, protoco return validatePositiveIntOrZeroFromPointer(parameter, fieldPath) } -func validateTransportServerAction(action *v1alpha1.Action, fieldPath *field.Path, upstreamNames sets.String) field.ErrorList { +func validateTransportServerAction(action *v1alpha1.Action, fieldPath *field.Path, upstreamNames sets.Set[string]) field.ErrorList { allErrs := field.ErrorList{} if action.Pass == "" { diff --git a/pkg/apis/configuration/validation/transportserver_test.go b/pkg/apis/configuration/validation/transportserver_test.go index 9cd8a87923..16fbed45ff 100644 --- a/pkg/apis/configuration/validation/transportserver_test.go +++ b/pkg/apis/configuration/validation/transportserver_test.go @@ -71,12 +71,12 @@ func TestValidateTransportServerFails(t *testing.T) { func TestValidateTransportServerUpstreams(t *testing.T) { tests := []struct { upstreams []v1alpha1.Upstream - expectedUpstreamNames sets.String + expectedUpstreamNames sets.Set[string] msg string }{ { upstreams: []v1alpha1.Upstream{}, - expectedUpstreamNames: sets.String{}, + expectedUpstreamNames: sets.Set[string]{}, msg: "no upstreams", }, { @@ -114,7 +114,7 @@ func TestValidateTransportServerUpstreams(t *testing.T) { func TestValidateTransportServerUpstreamsFails(t *testing.T) { tests := []struct { upstreams []v1alpha1.Upstream - expectedUpstreamNames sets.String + expectedUpstreamNames sets.Set[string] msg string }{ { @@ -125,7 +125,7 @@ func TestValidateTransportServerUpstreamsFails(t *testing.T) { Port: 80, }, }, - expectedUpstreamNames: sets.String{}, + expectedUpstreamNames: sets.Set[string]{}, msg: "invalid upstream name", }, { diff --git a/pkg/apis/configuration/validation/virtualserver.go b/pkg/apis/configuration/validation/virtualserver.go index 8a8805f690..37f6286e93 100644 --- a/pkg/apis/configuration/validation/virtualserver.go +++ b/pkg/apis/configuration/validation/virtualserver.go @@ -116,7 +116,7 @@ func validateHost(host string, fieldPath *field.Path) field.ErrorList { func validatePolicies(policies []v1.PolicyReference, fieldPath *field.Path, namespace string) field.ErrorList { allErrs := field.ErrorList{} - policyKeys := sets.String{} + policyKeys := sets.Set[string]{} for i, p := range policies { idxPath := fieldPath.Index(i) @@ -573,9 +573,9 @@ func isValidHeaderValue(s string) []string { return nil } -func (vsv *VirtualServerValidator) validateUpstreams(upstreams []v1.Upstream, fieldPath *field.Path) (allErrs field.ErrorList, upstreamNames sets.String) { +func (vsv *VirtualServerValidator) validateUpstreams(upstreams []v1.Upstream, fieldPath *field.Path) (allErrs field.ErrorList, upstreamNames sets.Set[string]) { allErrs = field.ErrorList{} - upstreamNames = sets.String{} + upstreamNames = sets.Set[string]{} for i, u := range upstreams { idxPath := fieldPath.Index(i) @@ -644,7 +644,7 @@ var validNextUpstreamParams = map[string]bool{ // validateNextUpstream checks the values given for passing queries to a upstream func validateNextUpstream(nextUpstream string, fieldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} - allParams := sets.String{} + allParams := sets.Set[string]{} if nextUpstream == "" { return allErrs } @@ -690,10 +690,10 @@ func validateDNS1035Label(name string, fieldPath *field.Path) field.ErrorList { return allErrs } -func (vsv *VirtualServerValidator) validateVirtualServerRoutes(routes []v1.Route, fieldPath *field.Path, upstreamNames sets.String, namespace string) field.ErrorList { +func (vsv *VirtualServerValidator) validateVirtualServerRoutes(routes []v1.Route, fieldPath *field.Path, upstreamNames sets.Set[string], namespace string) field.ErrorList { allErrs := field.ErrorList{} - allPaths := sets.String{} + allPaths := sets.Set[string]{} for i, r := range routes { idxPath := fieldPath.Index(i) @@ -712,7 +712,7 @@ func (vsv *VirtualServerValidator) validateVirtualServerRoutes(routes []v1.Route return allErrs } -func (vsv *VirtualServerValidator) validateRoute(route v1.Route, fieldPath *field.Path, upstreamNames sets.String, isRouteFieldForbidden bool, namespace string) field.ErrorList { +func (vsv *VirtualServerValidator) validateRoute(route v1.Route, fieldPath *field.Path, upstreamNames sets.Set[string], isRouteFieldForbidden bool, namespace string) field.ErrorList { allErrs := field.ErrorList{} allErrs = append(allErrs, validateRoutePath(route.Path, fieldPath.Child("path"))...) @@ -910,7 +910,7 @@ var validRedirectVariableNames = map[string]bool{ "host": true, } -func (vsv *VirtualServerValidator) validateAction(action *v1.Action, fieldPath *field.Path, upstreamNames sets.String, path string, internal bool) field.ErrorList { +func (vsv *VirtualServerValidator) validateAction(action *v1.Action, fieldPath *field.Path, upstreamNames sets.Set[string], path string, internal bool) field.ErrorList { allErrs := field.ErrorList{} if countActions(action) != 1 { @@ -1053,7 +1053,7 @@ func validateRouteField(value string, fieldPath *field.Path) field.ErrorList { return allErrs } -func validateReferencedUpstream(name string, fieldPath *field.Path, upstreamNames sets.String) field.ErrorList { +func validateReferencedUpstream(name string, fieldPath *field.Path, upstreamNames sets.Set[string]) field.ErrorList { allErrs := field.ErrorList{} upstreamErrs := validateUpstreamName(name, fieldPath) @@ -1066,7 +1066,7 @@ func validateReferencedUpstream(name string, fieldPath *field.Path, upstreamName return allErrs } -func (vsv *VirtualServerValidator) validateActionProxy(p *v1.ActionProxy, fieldPath *field.Path, upstreamNames sets.String, path string, internal bool) field.ErrorList { +func (vsv *VirtualServerValidator) validateActionProxy(p *v1.ActionProxy, fieldPath *field.Path, upstreamNames sets.Set[string], path string, internal bool) field.ErrorList { allErrs := field.ErrorList{} allErrs = append(allErrs, validateReferencedUpstream(p.Upstream, fieldPath.Child("upstream"), upstreamNames)...) @@ -1261,7 +1261,7 @@ func validateIgnoreHeaders(ignoreHeaders []string, fieldPath *field.Path) field. return allErrs } -func (vsv *VirtualServerValidator) validateSplits(splits []v1.Split, fieldPath *field.Path, upstreamNames sets.String, path string) field.ErrorList { +func (vsv *VirtualServerValidator) validateSplits(splits []v1.Split, fieldPath *field.Path, upstreamNames sets.Set[string], path string) field.ErrorList { allErrs := field.ErrorList{} if len(splits) < 2 { @@ -1373,7 +1373,7 @@ func validateGrpcService(service string, fieldPath *field.Path) field.ErrorList return allErrs } -func (vsv *VirtualServerValidator) validateMatch(match v1.Match, fieldPath *field.Path, upstreamNames sets.String, path string) field.ErrorList { +func (vsv *VirtualServerValidator) validateMatch(match v1.Match, fieldPath *field.Path, upstreamNames sets.Set[string], path string) field.ErrorList { allErrs := field.ErrorList{} if len(match.Conditions) == 0 { @@ -1555,10 +1555,10 @@ func isRegexOrExactMatch(path string) bool { return strings.HasPrefix(path, "~") || strings.HasPrefix(path, "=") } -func (vsv *VirtualServerValidator) validateVirtualServerRouteSubroutes(routes []v1.Route, fieldPath *field.Path, upstreamNames sets.String, vsPath string, namespace string) field.ErrorList { +func (vsv *VirtualServerValidator) validateVirtualServerRouteSubroutes(routes []v1.Route, fieldPath *field.Path, upstreamNames sets.Set[string], vsPath string, namespace string) field.ErrorList { allErrs := field.ErrorList{} - allPaths := sets.String{} + allPaths := sets.Set[string]{} if isRegexOrExactMatch(vsPath) { if len(routes) != 1 { diff --git a/pkg/apis/configuration/validation/virtualserver_test.go b/pkg/apis/configuration/validation/virtualserver_test.go index 2280e48935..39dd19ee4b 100644 --- a/pkg/apis/configuration/validation/virtualserver_test.go +++ b/pkg/apis/configuration/validation/virtualserver_test.go @@ -395,12 +395,12 @@ func TestValidateUpstreams(t *testing.T) { t.Parallel() tests := []struct { upstreams []v1.Upstream - expectedUpstreamNames sets.String + expectedUpstreamNames sets.Set[string] msg string }{ { upstreams: []v1.Upstream{}, - expectedUpstreamNames: sets.String{}, + expectedUpstreamNames: sets.Set[string]{}, msg: "no upstreams", }, { @@ -458,7 +458,7 @@ func TestValidateUpstreamsFails(t *testing.T) { t.Parallel() tests := []struct { upstreams []v1.Upstream - expectedUpstreamNames sets.String + expectedUpstreamNames sets.Set[string] msg string }{ { @@ -472,7 +472,7 @@ func TestValidateUpstreamsFails(t *testing.T) { ProxyNextUpstreamTries: 5, }, }, - expectedUpstreamNames: sets.String{}, + expectedUpstreamNames: sets.Set[string]{}, msg: "invalid upstream name", }, { @@ -783,12 +783,12 @@ func TestValidateVirtualServerRoutes(t *testing.T) { t.Parallel() tests := []struct { routes []v1.Route - upstreamNames sets.String + upstreamNames sets.Set[string] msg string }{ { routes: []v1.Route{}, - upstreamNames: sets.String{}, + upstreamNames: sets.Set[string]{}, msg: "no routes", }, { @@ -821,7 +821,7 @@ func TestValidateVirtualServerRoutesFails(t *testing.T) { t.Parallel() tests := []struct { routes []v1.Route - upstreamNames sets.String + upstreamNames sets.Set[string] msg string }{ { @@ -872,7 +872,7 @@ func TestValidateRoute(t *testing.T) { t.Parallel() tests := []struct { route v1.Route - upstreamNames sets.String + upstreamNames sets.Set[string] isRouteFieldForbidden bool msg string }{ @@ -966,7 +966,7 @@ func TestValidateRouteFails(t *testing.T) { t.Parallel() tests := []struct { route v1.Route - upstreamNames sets.String + upstreamNames sets.Set[string] isRouteFieldForbidden bool msg string }{ @@ -990,7 +990,7 @@ func TestValidateRouteFails(t *testing.T) { Pass: "-test", }, }, - upstreamNames: sets.String{}, + upstreamNames: sets.Set[string]{}, isRouteFieldForbidden: false, msg: "invalid pass action", }, @@ -1001,7 +1001,7 @@ func TestValidateRouteFails(t *testing.T) { Pass: "test", }, }, - upstreamNames: sets.String{}, + upstreamNames: sets.Set[string]{}, isRouteFieldForbidden: false, msg: "non-existing upstream in pass action", }, @@ -1419,7 +1419,7 @@ func TestValidateUpstreamFails(t *testing.T) { t.Parallel() tests := []struct { upstream string - upstreamNames sets.String + upstreamNames sets.Set[string] msg string }{ { @@ -1611,7 +1611,7 @@ func TestValidateSplitsFails(t *testing.T) { t.Parallel() tests := []struct { splits []v1.Split - upstreamNames sets.String + upstreamNames sets.Set[string] msg string }{ { @@ -1908,7 +1908,7 @@ func TestValidateMatch(t *testing.T) { t.Parallel() tests := []struct { match v1.Match - upstreamNames sets.String + upstreamNames sets.Set[string] msg string }{ { @@ -1973,7 +1973,7 @@ func TestValidateMatchFails(t *testing.T) { t.Parallel() tests := []struct { match v1.Match - upstreamNames sets.String + upstreamNames sets.Set[string] msg string }{ { @@ -2212,13 +2212,13 @@ func TestValidateVirtualServerRouteSubroutes(t *testing.T) { t.Parallel() tests := []struct { routes []v1.Route - upstreamNames sets.String + upstreamNames sets.Set[string] pathPrefix string msg string }{ { routes: []v1.Route{}, - upstreamNames: sets.String{}, + upstreamNames: sets.Set[string]{}, pathPrefix: "/", msg: "no routes", }, @@ -2254,7 +2254,7 @@ func TestValidateVirtualServerRouteSubroutesFails(t *testing.T) { t.Parallel() tests := []struct { routes []v1.Route - upstreamNames sets.String + upstreamNames sets.Set[string] pathPrefix string msg string }{