Skip to content

Commit

Permalink
chore: Output of gofumpt and remove deprecated reference (#3464)
Browse files Browse the repository at this point in the history
Output of gofumpt and remove deprecated references
  • Loading branch information
ciarams87 authored Jan 23, 2023
1 parent acc233d commit 1c7be73
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 47 deletions.
2 changes: 1 addition & 1 deletion internal/certmanager/test_files/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

//nolint
// nolint
package test

import (
Expand Down
2 changes: 1 addition & 1 deletion internal/certmanager/test_files/context_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

//nolint
// nolint
package test

import (
Expand Down
2 changes: 1 addition & 1 deletion internal/certmanager/test_files/reactors.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

//nolint
// nolint
package test

import (
Expand Down
2 changes: 1 addition & 1 deletion internal/certmanager/test_files/recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

//nolint
// nolint
package test

import (
Expand Down
2 changes: 1 addition & 1 deletion internal/certmanager/test_files/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

//nolint
// nolint
package test

import (
Expand Down
2 changes: 1 addition & 1 deletion internal/k8s/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"), ""))
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/configuration/validation/globalconfiguration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/configuration/validation/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}

Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/configuration/validation/transportserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 == "" {
Expand Down
8 changes: 4 additions & 4 deletions pkg/apis/configuration/validation/transportserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
{
Expand Down Expand Up @@ -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
}{
{
Expand All @@ -125,7 +125,7 @@ func TestValidateTransportServerUpstreamsFails(t *testing.T) {
Port: 80,
},
},
expectedUpstreamNames: sets.String{},
expectedUpstreamNames: sets.Set[string]{},
msg: "invalid upstream name",
},
{
Expand Down
28 changes: 14 additions & 14 deletions pkg/apis/configuration/validation/virtualserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
Expand All @@ -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"))...)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand All @@ -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)...)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
36 changes: 18 additions & 18 deletions pkg/apis/configuration/validation/virtualserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
{
Expand Down Expand Up @@ -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
}{
{
Expand All @@ -472,7 +472,7 @@ func TestValidateUpstreamsFails(t *testing.T) {
ProxyNextUpstreamTries: 5,
},
},
expectedUpstreamNames: sets.String{},
expectedUpstreamNames: sets.Set[string]{},
msg: "invalid upstream name",
},
{
Expand Down Expand Up @@ -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",
},
{
Expand Down Expand Up @@ -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
}{
{
Expand Down Expand Up @@ -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
}{
Expand Down Expand Up @@ -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
}{
Expand All @@ -990,7 +990,7 @@ func TestValidateRouteFails(t *testing.T) {
Pass: "-test",
},
},
upstreamNames: sets.String{},
upstreamNames: sets.Set[string]{},
isRouteFieldForbidden: false,
msg: "invalid pass action",
},
Expand All @@ -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",
},
Expand Down Expand Up @@ -1419,7 +1419,7 @@ func TestValidateUpstreamFails(t *testing.T) {
t.Parallel()
tests := []struct {
upstream string
upstreamNames sets.String
upstreamNames sets.Set[string]
msg string
}{
{
Expand Down Expand Up @@ -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
}{
{
Expand Down Expand Up @@ -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
}{
{
Expand Down Expand Up @@ -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
}{
{
Expand Down Expand Up @@ -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",
},
Expand Down Expand Up @@ -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
}{
Expand Down

0 comments on commit 1c7be73

Please sign in to comment.