Skip to content

Commit 11fd3a8

Browse files
chore(codebase): enable copyloopvar
1 parent 718ee66 commit 11fd3a8

18 files changed

+48
-43
lines changed

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ version: "2"
33
linters:
44
default: none
55
enable: # golangci-lint help linters
6+
- copyloopvar # A linter detects places where loop variables are copied. https://golangci-lint.run/usage/linters/#copyloopvar
67
- dogsled
78
- goprintffuncname
89
- govet

provider/ovh/ovh.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ func (p *OVHProvider) handleSingleZoneUpdate(ctx context.Context, zoneName strin
223223

224224
eg, ctxErrGroup := errgroup.WithContext(ctx)
225225
for _, change := range allChanges {
226-
change := change
227226
eg.Go(func() error {
228227
return p.change(ctxErrGroup, change)
229228
})
@@ -350,7 +349,6 @@ func (p *OVHProvider) zonesRecords(ctx context.Context) ([]string, []ovhRecord,
350349
chRecords := make(chan []ovhRecord, len(zones))
351350
eg, ctx := errgroup.WithContext(ctx)
352351
for _, zone := range zones {
353-
zone := zone
354352
eg.Go(func() error { return p.records(ctx, &zone, chRecords) })
355353
}
356354
if err := eg.Wait(); err != nil {
@@ -430,7 +428,6 @@ func (p *OVHProvider) records(ctx context.Context, zone *string, records chan<-
430428
}
431429
chRecords := make(chan ovhRecord, len(recordsIds))
432430
for _, id := range recordsIds {
433-
id := id
434431
eg.Go(func() error { return p.record(ctxErrGroup, zone, id, chRecords) })
435432
}
436433
if err := eg.Wait(); err != nil {

source/ambassador_host_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"k8s.io/apimachinery/pkg/runtime"
3333
fakeDynamic "k8s.io/client-go/dynamic/fake"
3434
fakeKube "k8s.io/client-go/kubernetes/fake"
35+
3536
"sigs.k8s.io/external-dns/endpoint"
3637
"sigs.k8s.io/external-dns/source/annotations"
3738
)
@@ -614,7 +615,7 @@ func TestAmbassadorHostSource(t *testing.T) {
614615
expected: []*endpoint.Endpoint{},
615616
},
616617
} {
617-
ti := ti
618+
618619
t.Run(ti.title, func(t *testing.T) {
619620
t.Parallel()
620621

source/connector_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func testConnectorSourceEndpoints(t *testing.T) {
119119
expectError: false,
120120
},
121121
} {
122-
ti := ti
122+
123123
t.Run(ti.title, func(t *testing.T) {
124124
t.Parallel()
125125

source/contour_httpproxy_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3232
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
3333
"k8s.io/apimachinery/pkg/runtime"
34+
3435
"sigs.k8s.io/external-dns/endpoint"
3536
)
3637

@@ -178,7 +179,7 @@ func TestNewContourHTTPProxySource(t *testing.T) {
178179
annotationFilter: "contour.heptio.com/ingress.class=contour",
179180
},
180181
} {
181-
ti := ti
182+
182183
t.Run(ti.title, func(t *testing.T) {
183184
t.Parallel()
184185

@@ -282,7 +283,7 @@ func testEndpointsFromHTTPProxy(t *testing.T) {
282283
expected: []*endpoint.Endpoint{},
283284
},
284285
} {
285-
ti := ti
286+
286287
t.Run(ti.title, func(t *testing.T) {
287288
t.Parallel()
288289

@@ -1034,7 +1035,7 @@ func testHTTPProxyEndpoints(t *testing.T) {
10341035
ignoreHostnameAnnotation: true,
10351036
},
10361037
} {
1037-
ti := ti
1038+
10381039
t.Run(ti.title, func(t *testing.T) {
10391040
t.Parallel()
10401041

source/crd_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ func testCRDSourceEndpoints(t *testing.T) {
468468
expectError: false,
469469
},
470470
} {
471-
ti := ti
471+
472472
t.Run(ti.title, func(t *testing.T) {
473473
t.Parallel()
474474

source/gateway_httproute_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ import (
2626
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2727
"k8s.io/apimachinery/pkg/labels"
2828
kubefake "k8s.io/client-go/kubernetes/fake"
29-
"sigs.k8s.io/external-dns/endpoint"
30-
"sigs.k8s.io/external-dns/internal/testutils"
31-
"sigs.k8s.io/external-dns/source/annotations"
3229
v1 "sigs.k8s.io/gateway-api/apis/v1"
3330
v1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
3431
gatewayfake "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned/fake"
32+
33+
"sigs.k8s.io/external-dns/endpoint"
34+
"sigs.k8s.io/external-dns/internal/testutils"
35+
"sigs.k8s.io/external-dns/source/annotations"
3536
)
3637

3738
func mustGetLabelSelector(s string) labels.Selector {
@@ -1581,7 +1582,7 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
15811582
},
15821583
}
15831584
for _, tt := range tests {
1584-
tt := tt
1585+
15851586
t.Run(tt.title, func(t *testing.T) {
15861587
if len(tt.logExpectations) == 0 {
15871588
t.Parallel()

source/ingress_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func TestNewIngressSource(t *testing.T) {
138138
annotationFilter: "kubernetes.io/ingress.class=nginx",
139139
},
140140
} {
141-
ti := ti
141+
142142
t.Run(ti.title, func(t *testing.T) {
143143
t.Parallel()
144144

@@ -1424,7 +1424,7 @@ func testIngressEndpoints(t *testing.T) {
14241424
expected: []*endpoint.Endpoint{},
14251425
},
14261426
} {
1427-
ti := ti
1427+
14281428
t.Run(ti.title, func(t *testing.T) {
14291429
t.Parallel()
14301430

source/istio_gateway_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func TestNewIstioGatewaySource(t *testing.T) {
160160
annotationFilter: "kubernetes.io/gateway.class=nginx",
161161
},
162162
} {
163-
ti := ti
163+
164164
t.Run(ti.title, func(t *testing.T) {
165165
t.Parallel()
166166

@@ -492,7 +492,7 @@ func testEndpointsFromGatewayConfig(t *testing.T) {
492492
},
493493
},
494494
} {
495-
ti := ti
495+
496496
t.Run(ti.title, func(t *testing.T) {
497497
t.Parallel()
498498

@@ -1473,7 +1473,7 @@ func testGatewayEndpoints(t *testing.T) {
14731473
expectError: true,
14741474
},
14751475
} {
1476-
ti := ti
1476+
14771477
t.Run(ti.title, func(t *testing.T) {
14781478
t.Parallel()
14791479

source/istio_virtualservice_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func TestNewIstioVirtualServiceSource(t *testing.T) {
184184
annotationFilter: "kubernetes.io/gateway.class=nginx",
185185
},
186186
} {
187-
ti := ti
187+
188188
t.Run(ti.title, func(t *testing.T) {
189189
t.Parallel()
190190

@@ -693,7 +693,7 @@ func testEndpointsFromVirtualServiceConfig(t *testing.T) {
693693
},
694694
},
695695
} {
696-
ti := ti
696+
697697
t.Run(ti.title, func(t *testing.T) {
698698
t.Parallel()
699699

@@ -1945,7 +1945,7 @@ func testVirtualServiceEndpoints(t *testing.T) {
19451945
fqdnTemplate: "{{.Name}}.ext-dns.test.com",
19461946
},
19471947
} {
1948-
ti := ti
1948+
19491949
t.Run(ti.title, func(t *testing.T) {
19501950
t.Parallel()
19511951

0 commit comments

Comments
 (0)