Skip to content

Commit 776e606

Browse files
committed
Remove redefinitions of loop variables in for-loops.
This pattern was made obsolete with the GoLang 1.22 semantics for the for-loop. Signed-off-by: Mads Jensen <atombrella@users.noreply.github.com>
1 parent adc3e6b commit 776e606

20 files changed

Lines changed: 0 additions & 94 deletions

plugins/ipam/dhcp/dhcp_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,6 @@ var _ = Describe("DHCP Operations", func() {
256256
})
257257

258258
for _, ver := range testutils.AllSpecVersions {
259-
// Redefine ver inside for scope so real value is picked up by each dynamically defined It()
260-
// See Gingkgo's "Patterns for dynamically generating tests" documentation.
261-
ver := ver
262-
263259
It(fmt.Sprintf("[%s] configures and deconfigures a link with ADD/DEL", ver), func() {
264260
conf := fmt.Sprintf(`{
265261
"cniVersion": "%s",
@@ -579,10 +575,6 @@ var _ = Describe("DHCP Lease Unavailable Operations", func() {
579575
})
580576

581577
for _, ver := range testutils.AllSpecVersions {
582-
// Redefine ver inside for scope so real value is picked up by each dynamically defined It()
583-
// See Gingkgo's "Patterns for dynamically generating tests" documentation.
584-
ver := ver
585-
586578
It(fmt.Sprintf("[%s] configures multiple links with multiple ADD with second lease unavailable", ver), func() {
587579
conf := fmt.Sprintf(`{
588580
"cniVersion": "%s",

plugins/ipam/host-local/host_local_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ var _ = Describe("host-local Operations", func() {
5252
})
5353

5454
for _, ver := range testutils.AllSpecVersions {
55-
// Redefine ver inside for scope so real value is picked up by each dynamically defined It()
56-
// See Gingkgo's "Patterns for dynamically generating tests" documentation.
57-
ver := ver
58-
5955
It(fmt.Sprintf("[%s] allocates and releases addresses with ADD/DEL", ver), func() {
6056
err := os.WriteFile(filepath.Join(tmpDir, "resolv.conf"), []byte("nameserver 192.0.2.3"), 0o644)
6157
Expect(err).NotTo(HaveOccurred())

plugins/ipam/static/static_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ import (
3030

3131
var _ = Describe("static Operations", func() {
3232
for _, ver := range testutils.AllSpecVersions {
33-
// Redefine ver inside for scope so real value is picked up by each dynamically defined It()
34-
// See Gingkgo's "Patterns for dynamically generating tests" documentation.
35-
ver := ver
36-
3733
It(fmt.Sprintf("[%s] allocates and releases addresses with ADD/DEL", ver), func() {
3834
const ifname string = "eth0"
3935
const nspath string = "/some/where"

plugins/main/bridge/bridge_test.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,10 +1910,6 @@ var _ = Describe("bridge Operations", func() {
19101910
)
19111911

19121912
for _, ver := range testutils.AllSpecVersions {
1913-
// Redefine ver inside for scope so real value is picked up by each dynamically defined It()
1914-
// See Gingkgo's "Patterns for dynamically generating tests" documentation.
1915-
ver := ver
1916-
19171913
It(fmt.Sprintf("[%s] creates a bridge", ver), func() {
19181914
conf := testCase{cniVersion: ver}.netConf()
19191915
err := originalNS.Do(func(ns.NetNS) error {
@@ -2012,8 +2008,6 @@ var _ = Describe("bridge Operations", func() {
20122008
resolvConf: resolvConf,
20132009
},
20142010
} {
2015-
tc := tc
2016-
i := i
20172011
It(fmt.Sprintf("[%s] (%d) configures and deconfigures a bridge and veth with default route with ADD/DEL", ver, i), func() {
20182012
tc.cniVersion = ver
20192013
cmdAddDelTest(originalNS, targetNS, tc, dataDir)
@@ -2136,8 +2130,6 @@ var _ = Describe("bridge Operations", func() {
21362130
DelErr010: "CNI version 0.1.0 does not support more than 1 address per family",
21372131
},
21382132
} {
2139-
tc := tc
2140-
i := i
21412133
It(fmt.Sprintf("[%s] (%d) configures and deconfigures a bridge, veth with default route and vlanID 100 with ADD/DEL", ver, i), func() {
21422134
tc.cniVersion = ver
21432135
cmdAddDelTest(originalNS, targetNS, tc, dataDir)
@@ -2172,8 +2164,6 @@ var _ = Describe("bridge Operations", func() {
21722164
},
21732165
},
21742166
} {
2175-
tc := tc
2176-
i := i
21772167
It(fmt.Sprintf("[%s] (%d) configures and deconfigures a bridge and veth with default route with ADD/DEL", ver, i), func() {
21782168
tc.cniVersion = ver
21792169
cmdAddDelTest(originalNS, targetNS, tc, dataDir)
@@ -2217,8 +2207,6 @@ var _ = Describe("bridge Operations", func() {
22172207
gwCIDRSecond: "fd00:1234::1/64",
22182208
},
22192209
} {
2220-
tc := tc
2221-
i := i
22222210
It(fmt.Sprintf("[%s] (%d) ensure bridge address", ver, i), func() {
22232211
conf := testCase{cniVersion: ver, isGW: true}.netConf()
22242212

@@ -2353,8 +2341,6 @@ var _ = Describe("bridge Operations", func() {
23532341
subnet: "2001:db8:42::/64",
23542342
},
23552343
} {
2356-
tc := tc
2357-
i := i
23582344
It(fmt.Sprintf("[%s] (%d) creates a bridge with a stable MAC addresses", ver, i), func() {
23592345
err := originalNS.Do(func(ns.NetNS) error {
23602346
defer GinkgoRecover()
@@ -2496,7 +2482,6 @@ var _ = Describe("bridge Operations", func() {
24962482
cniVersion: ver,
24972483
},
24982484
} {
2499-
tc := tc
25002485
It(fmt.Sprintf("[%s] configures a bridge and ipMasq rules with ipMasqBackend %q", ver, tc.ipMasqBackend), func() {
25012486
err := originalNS.Do(func(ns.NetNS) error {
25022487
defer GinkgoRecover()
@@ -2575,8 +2560,6 @@ var _ = Describe("bridge Operations", func() {
25752560
},
25762561
},
25772562
} {
2578-
tc := tc
2579-
i := i
25802563
It(fmt.Sprintf("[%s] (%d) configures and deconfigures a bridge and veth with default route with ADD/DEL/CHECK", ver, i), func() {
25812564
tc.cniVersion = ver
25822565
cmdAddDelCheckTest(originalNS, targetNS, tc, dataDir)

plugins/main/dummy/dummy_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,6 @@ var _ = Describe("dummy Operations", func() {
206206
})
207207

208208
for _, ver := range testutils.AllSpecVersions {
209-
// Redefine ver inside for scope so real value is picked up by each dynamically defined It()
210-
// See Gingkgo's "Patterns for dynamically generating tests" documentation.
211-
ver := ver
212-
213209
It(fmt.Sprintf("[%s] creates an dummy link in a non-default namespace", ver), func() {
214210
// Create dummy in other namespace
215211
err := originalNS.Do(func(ns.NetNS) error {

plugins/main/host-device/host-device_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,6 @@ var _ = Describe("base functionality", func() {
347347
})
348348

349349
for _, ver := range []string{"0.3.0", "0.3.1", "0.4.0", "1.0.0"} {
350-
// Redefine ver inside for scope so real value is picked up by each dynamically defined It()
351-
// See Gingkgo's "Patterns for dynamically generating tests" documentation.
352-
ver := ver
353-
354350
It(fmt.Sprintf("[%s] works with a valid config without IPAM", ver), func() {
355351
var origLink netlink.Link
356352

plugins/main/ipvlan/ipvlan_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,6 @@ var _ = Describe("ipvlan Operations", func() {
336336
}
337337
// for _, ver := range testutils.AllSpecVersions {
338338
for _, ver := range [...]string{"1.0.0"} {
339-
// Redefine ver inside for scope so real value is picked up by each dynamically defined It()
340-
// See Gingkgo's "Patterns for dynamically generating tests" documentation.
341-
ver := ver
342339
isInContainer := inContainer // Tests need a local var with constant value
343340

344341
It(fmt.Sprintf("[%s] creates an ipvlan link in a non-default namespace", ver), func() {

plugins/main/loopback/loopback_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ var _ = Describe("Loopback", func() {
6262
})
6363

6464
for _, ver := range testutils.AllSpecVersions {
65-
// Redefine ver inside for scope so real value is picked up by each dynamically defined It()
66-
// See Gingkgo's "Patterns for dynamically generating tests" documentation.
67-
ver := ver
68-
6965
Context("when given a network namespace", func() {
7066
It(fmt.Sprintf("[%s] sets the lo device to UP", ver), func() {
7167
command.Stdin = generateConfig(ver)

plugins/main/macvlan/macvlan_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,6 @@ var _ = Describe("macvlan Operations", func() {
258258
linkInContainer = fmt.Sprintf("\"linkInContainer\": %t,", *isInContainer)
259259
}
260260
for _, ver := range testutils.AllSpecVersions {
261-
// Redefine ver inside for scope so real value is picked up by each dynamically defined It()
262-
// See Gingkgo's "Patterns for dynamically generating tests" documentation.
263-
ver := ver
264-
265261
It(fmt.Sprintf("[%s] creates an macvlan link in a non-default namespace", ver), func() {
266262
conf := &NetConf{
267263
NetConf: types.NetConf{

plugins/main/ptp/ptp_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,6 @@ var _ = Describe("ptp Operations", func() {
346346
}
347347

348348
for _, ver := range testutils.AllSpecVersions {
349-
// Redefine ver inside for scope so real value is picked up by each dynamically defined It()
350-
// See Gingkgo's "Patterns for dynamically generating tests" documentation.
351-
ver := ver
352-
353349
It(fmt.Sprintf("[%s] configures and deconfigures a ptp link with ADD/DEL", ver), func() {
354350
dnsConf := types.DNS{
355351
Nameservers: []string{"10.1.2.123"},

0 commit comments

Comments
 (0)