Skip to content

Commit

Permalink
fixed for loops alias
Browse files Browse the repository at this point in the history
aliasing in for loops no longer needed as per https://go.dev/blog/loopvar-preview

Signed-off-by: Mattia Lavacca <lavacca.mattia@gmail.com>
  • Loading branch information
mlavacca committed Sep 5, 2024
1 parent 56da781 commit 7112d14
Show file tree
Hide file tree
Showing 11 changed files with 0 additions and 19 deletions.
1 change: 0 additions & 1 deletion apis/v1/util/validation/gatewayclass_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func TestIsControllerNameValid(t *testing.T) {
}

for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
isValid := validationtutils.IsControllerNameValid(tc.controllerName)
if isValid != tc.isvalid {
Expand Down
1 change: 0 additions & 1 deletion apis/v1beta1/util/validation/gatewayclass_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func TestIsControllerNameValid(t *testing.T) {
}

for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
isValid := validationtutils.IsControllerNameValid(tc.controllerName)
if isValid != tc.isvalid {
Expand Down
1 change: 0 additions & 1 deletion conformance/tests/gateway-invalid-tls-configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ var GatewayInvalidTLSConfiguration = suite.ConformanceTest{
}

for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
kubernetes.GatewayStatusMustHaveListeners(t, s.Client, s.TimeoutConfig, tc.gatewayNamespacedName, listeners)
Expand Down
2 changes: 0 additions & 2 deletions conformance/utils/kubernetes/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,6 @@ func (a Applier) prepareResources(t *testing.T, decoder *yaml.YAMLOrJSONDecoder)

func (a Applier) MustApplyObjectsWithCleanup(t *testing.T, c client.Client, timeoutConfig config.TimeoutConfig, resources []client.Object, cleanup bool) {
for _, resource := range resources {
resource := resource

ctx, cancel := context.WithTimeout(context.Background(), timeoutConfig.CreateTimeout)
defer cancel()

Expand Down
3 changes: 0 additions & 3 deletions conformance/utils/kubernetes/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ func NamespacesMustBeReady(t *testing.T, c client.Client, timeoutConfig config.T
tlog.Errorf(t, "Error listing Gateways: %v", err)
}
for _, gw := range gwList.Items {
gw := gw

if val, ok := gw.Annotations[GatewayExcludedFromReadinessChecks]; ok && val == "true" {
tlog.Logf(t, "Gateway %s is skipped for setup and wont be tested", client.ObjectKeyFromObject(&gw))
Expand Down Expand Up @@ -237,7 +236,6 @@ func NamespacesMustBeReady(t *testing.T, c client.Client, timeoutConfig config.T
tlog.Errorf(t, "Error listing Pods: %v", err)
}
for _, pod := range podList.Items {
pod := pod
if !findPodConditionInList(t, pod.Status.Conditions, "Ready", "True") &&
pod.Status.Phase != v1.PodSucceeded &&
pod.DeletionTimestamp == nil {
Expand Down Expand Up @@ -309,7 +307,6 @@ func MeshNamespacesMustBeReady(t *testing.T, c client.Client, timeoutConfig conf
tlog.Errorf(t, "Error listing Pods: %v", err)
}
for _, pod := range podList.Items {
pod := pod
if !findPodConditionInList(t, pod.Status.Conditions, "Ready", "True") &&
pod.Status.Phase != v1.PodSucceeded &&
pod.DeletionTimestamp == nil {
Expand Down
1 change: 0 additions & 1 deletion conformance/utils/kubernetes/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ func Test_listenersMatch(t *testing.T) {
}

for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
assert.Equal(t, test.want, listenersMatch(t, test.expected, test.actual))
})
Expand Down
1 change: 0 additions & 1 deletion conformance/utils/suite/reports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ func TestBuildSummary(t *testing.T) {

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
tc := tc
summary := buildSummary(tc.report)
require.Equal(t, tc.expectedSummary, summary)
})
Expand Down
1 change: 0 additions & 1 deletion conformance/utils/suite/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ func TestGetAPIVersionAndChannel(t *testing.T) {
}

for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
version, channel, err := getAPIVersionAndChannel(tc.crds)
assert.Equal(t, tc.expectedVersion, version)
Expand Down
1 change: 0 additions & 1 deletion gwctl/pkg/printer/gatewayclasses_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ Events: <none>
}

for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
k8sClients := common.MustClientsForTest(t, tc.objects...)
policyManager := utils.MustPolicyManagerForTest(t, k8sClients)
Expand Down
6 changes: 0 additions & 6 deletions gwctl/pkg/resourcediscovery/resourcemodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ func (rm *ResourceModel) addGatewayClasses(gatewayClasses ...gatewayv1.GatewayCl
rm.GatewayClasses = make(map[gatewayClassID]*GatewayClassNode)
}
for _, gatewayClass := range gatewayClasses {
gatewayClass := gatewayClass
gatewayClassNode := NewGatewayClassNode(&gatewayClass)
if _, ok := rm.GatewayClasses[gatewayClassNode.ID()]; !ok {
rm.GatewayClasses[gatewayClassNode.ID()] = gatewayClassNode
Expand All @@ -82,7 +81,6 @@ func (rm *ResourceModel) addGateways(gateways ...gatewayv1.Gateway) {
rm.Gateways = make(map[gatewayID]*GatewayNode)
}
for _, gateway := range gateways {
gateway := gateway
gatewayNode := NewGatewayNode(&gateway)
if _, ok := rm.Gateways[gatewayNode.ID()]; !ok {
rm.Gateways[gatewayNode.ID()] = gatewayNode
Expand All @@ -96,7 +94,6 @@ func (rm *ResourceModel) addHTTPRoutes(httpRoutes ...gatewayv1.HTTPRoute) {
rm.HTTPRoutes = make(map[httpRouteID]*HTTPRouteNode)
}
for _, httpRoute := range httpRoutes {
httpRoute := httpRoute
httpRouteNode := NewHTTPRouteNode(&httpRoute)
if _, ok := rm.HTTPRoutes[httpRouteNode.ID()]; !ok {
rm.HTTPRoutes[httpRouteNode.ID()] = httpRouteNode
Expand All @@ -110,7 +107,6 @@ func (rm *ResourceModel) addBackends(backends ...unstructured.Unstructured) {
rm.Backends = make(map[backendID]*BackendNode)
}
for _, backend := range backends {
backend := backend
backendNode := NewBackendNode(&backend)
if _, ok := rm.Backends[backendNode.ID()]; !ok {
rm.Backends[backendNode.ID()] = backendNode
Expand All @@ -124,7 +120,6 @@ func (rm *ResourceModel) addReferenceGrants(referenceGrants ...gatewayv1beta1.Re
rm.ReferenceGrants = make(map[referenceGrantID]*ReferenceGrantNode)
}
for _, referenceGrant := range referenceGrants {
referenceGrant := referenceGrant
referenceGrantNode := NewReferenceGrantNode(&referenceGrant)
if _, ok := rm.ReferenceGrants[referenceGrantNode.ID()]; !ok {
rm.ReferenceGrants[referenceGrantNode.ID()] = referenceGrantNode
Expand All @@ -140,7 +135,6 @@ func (rm *ResourceModel) addPolicyIfTargetExists(policies ...policymanager.Polic
rm.Policies = make(map[policyID]*PolicyNode)
}
for _, policy := range policies {
policy := policy
policyNode := NewPolicyNode(&policy)

switch {
Expand Down
1 change: 0 additions & 1 deletion pkg/test/cel/grpcroute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ func TestGRPCMethodMatch(t *testing.T) {
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
route := gatewayv1.GRPCRoute{
ObjectMeta: metav1.ObjectMeta{
Expand Down

0 comments on commit 7112d14

Please sign in to comment.