Skip to content

Commit e8c71e0

Browse files
authored
chore: Migrate to golangci-lint v2 (#9547)
1 parent 384d7c0 commit e8c71e0

File tree

59 files changed

+350
-330
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+350
-330
lines changed

.github/workflows/lint-azclient.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ jobs:
3737
cache-dependency-path: |
3838
pkg/azclient/go.sum
3939
- name: golangci-lint
40-
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.2
40+
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
4141
with:
4242
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
43-
version: v1.64
43+
version: v2.5.0
4444
args: -v
4545
verify: true

.github/workflows/lint.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ jobs:
5151
cache-dependency-path: |
5252
go.sum
5353
- name: golangci-lint
54-
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.2
54+
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
5555
with:
5656
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
57-
version: v1.64
57+
version: v2.5.0
5858
args: -v
5959
install-mode: goinstall
6060
verify: true

.golangci.yml

Lines changed: 52 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,65 @@
1+
version: "2"
12
run:
2-
timeout: 30m
3+
modules-download-mode: mod
34
tests: true
4-
modules-download-mode: vendor
55
linters:
6-
disable-all: true
6+
default: none
77
enable:
8+
- asasalint
9+
- asciicheck
10+
- bidichk
811
- errcheck
9-
- gosimple
10-
- govet
11-
- ineffassign
12-
- staticcheck
13-
- unused
12+
- errorlint
1413
- goconst
15-
- goimports
16-
- revive
1714
- gosec
15+
- govet
16+
- ineffassign
17+
- loggercheck
1818
- misspell
1919
- nakedret
20-
- typecheck
20+
- revive
21+
- staticcheck
2122
- unconvert
22-
- asasalint
23-
- asciicheck
24-
- bidichk
25-
- errorlint
26-
- loggercheck
27-
fast: false
23+
- unused
24+
settings:
25+
goconst:
26+
min-occurrences: 10
27+
gosec:
28+
excludes:
29+
- G114
30+
- G115
31+
staticcheck:
32+
checks:
33+
- all
34+
- -SA1019
35+
exclusions:
36+
generated: lax
37+
presets:
38+
- comments
39+
- common-false-positives
40+
- legacy
41+
- std-error-handling
42+
rules:
43+
- linters:
44+
- revive
45+
path: tests/e2e
46+
paths:
47+
- third_party$
48+
- builtin$
49+
- examples$
2850
issues:
29-
exclude-rules:
30-
- path: tests/e2e
31-
linters:
32-
- revive
3351
max-issues-per-linter: 0
3452
max-same-issues: 0
35-
linters-settings:
36-
staticcheck:
37-
checks: ["all", "-SA1019"]
38-
gosec:
39-
excludes:
40-
- G114
41-
- G115
42-
goimports:
43-
local-prefixes: sigs.k8s.io/cloud-provider-azure
44-
goconst:
45-
min-occurrences: 10
46-
47-
53+
formatters:
54+
enable:
55+
- goimports
56+
settings:
57+
goimports:
58+
local-prefixes:
59+
- sigs.k8s.io/cloud-provider-azure
60+
exclusions:
61+
generated: lax
62+
paths:
63+
- third_party$
64+
- builtin$
65+
- examples$

cmd/acr-credential-provider/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func main() {
4545
Long: `The acr credential provider is responsible for providing ACR credentials for kubelet`,
4646
Args: func(_ *cobra.Command, args []string) error {
4747
if len(args) == 0 {
48-
return errors.New("Config file is not specified")
48+
return errors.New("config file is not specified")
4949
}
5050
if len(args) > 1 {
5151
return fmt.Errorf("expected exactly one argument (config file); Got arguments: %v", args)

cmd/cloud-controller-manager/app/options/options.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func (o *CloudControllerManagerOptions) ApplyTo(
209209
return err
210210
}
211211
c.Kubeconfig.DisableCompression = true
212-
c.Kubeconfig.ContentConfig.ContentType = o.Generic.ClientConnection.ContentType
212+
c.Kubeconfig.ContentType = o.Generic.ClientConnection.ContentType
213213
c.Kubeconfig.QPS = o.Generic.ClientConnection.QPS
214214
c.Kubeconfig.Burst = int(o.Generic.ClientConnection.Burst)
215215

cmd/cloud-node-manager/app/options/options.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func (o *CloudNodeManagerOptions) ApplyTo(c *cloudnodeconfig.Config, userAgent s
163163
return err
164164
}
165165
c.Kubeconfig.DisableCompression = true
166-
c.Kubeconfig.ContentConfig.ContentType = o.ClientConnection.ContentType
166+
c.Kubeconfig.ContentType = o.ClientConnection.ContentType
167167
c.Kubeconfig.QPS = o.ClientConnection.QPS
168168
c.Kubeconfig.Burst = int(o.ClientConnection.Burst)
169169
c.WaitForRoutes = o.WaitForRoutes

pkg/azclient/.golangci.yml

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,64 @@
1+
version: "2"
12
run:
2-
timeout: 30m
3+
modules-download-mode: mod
34
tests: true
45
linters:
5-
disable-all: true
6+
default: none
67
enable:
8+
- asasalint
9+
- asciicheck
10+
- bidichk
711
- errcheck
8-
- gosimple
9-
- govet
10-
- ineffassign
11-
- staticcheck
12-
- unused
12+
- errorlint
1313
- goconst
14-
- goimports
15-
- revive
1614
- gosec
15+
- govet
16+
- ineffassign
17+
- loggercheck
1718
- misspell
1819
- nakedret
19-
- typecheck
20+
- revive
21+
- staticcheck
2022
- unconvert
21-
- asasalint
22-
- asciicheck
23-
- bidichk
24-
- errorlint
25-
- loggercheck
26-
fast: false
23+
- unused
24+
settings:
25+
goconst:
26+
min-occurrences: 10
27+
gosec:
28+
excludes:
29+
- G114
30+
- G115
31+
staticcheck:
32+
checks:
33+
- all
34+
- -SA1019
35+
revive:
36+
rules:
37+
- name: var-naming
38+
disabled: true
39+
exclusions:
40+
generated: lax
41+
presets:
42+
- comments
43+
- common-false-positives
44+
- legacy
45+
- std-error-handling
46+
paths:
47+
- third_party$
48+
- builtin$
49+
- examples$
2750
issues:
2851
max-issues-per-linter: 0
2952
max-same-issues: 0
30-
linters-settings:
31-
staticcheck:
32-
checks: ["all", "-SA1019"]
33-
gosec:
34-
excludes:
35-
- G114
36-
- G115
37-
goimports:
38-
local-prefixes: sigs.k8s.io/cloud-provider-azure/pkg/azclient
39-
goconst:
40-
min-occurrences: 10
41-
42-
53+
formatters:
54+
enable:
55+
- goimports
56+
settings:
57+
goimports:
58+
local-prefixes:
59+
- sigs.k8s.io/cloud-provider-azure/pkg/azclient
60+
exclusions:
61+
generated: lax
62+
paths:
63+
- third_party$
64+
- builtin$

pkg/azclient/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
146146
.PHONY: golangci-lint
147147
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
148148
$(GOLANGCI_LINT): $(LOCALBIN)
149-
test -s $(LOCALBIN)/golangci-lint || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(LOCALBIN) v1.64.8
149+
test -s $(LOCALBIN)/golangci-lint || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(LOCALBIN) v2.5.0
150150

151151
GOIMPORTS ?= $(LOCALBIN)/goimports
152152
.PHONY: goimports

pkg/azclient/auth_func_test.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -395,16 +395,17 @@ func TestNewAuthProviderWithServicePrincipalClientSecret(t *testing.T) {
395395
assert.Equal(t, testAADClientSecret, clientSecret)
396396
assert.Equal(t, *testClientOption, options.ClientOptions)
397397

398-
if tenantID == testNetworkTenantID {
398+
switch tenantID {
399+
case testNetworkTenantID:
399400
assert.Empty(t, options.AdditionallyAllowedTenants)
400401
return testFakeNetworkTokenCredential, nil
401-
} else if tenantID == testTenantID {
402+
case testTenantID:
402403
assert.Contains(t, options.AdditionallyAllowedTenants, testNetworkTenantID)
403404
return testFakeComputeTokenCredential, nil
405+
default:
406+
t.Fatalf("unexpected tenant ID: %s", tenantID)
407+
return nil, nil
404408
}
405-
406-
t.Fatalf("unexpected tenant ID: %s", tenantID)
407-
return nil, nil
408409
},
409410
},
410411
Assertions: []AuthProviderAssertions{
@@ -656,16 +657,17 @@ func TestNewAuthProviderWithServicePrincipalClientCertificate(t *testing.T) {
656657
assert.Equal(t, *testClientOption, options.ClientOptions)
657658
assert.True(t, options.SendCertificateChain)
658659

659-
if tenantID == testNetworkTenantID {
660+
switch tenantID {
661+
case testNetworkTenantID:
660662
assert.Empty(t, options.AdditionallyAllowedTenants)
661663
return testFakeNetworkTokenCredential, nil
662-
} else if tenantID == testTenantID {
664+
case testTenantID:
663665
assert.Contains(t, options.AdditionallyAllowedTenants, testNetworkTenantID)
664666
return testFakeComputeTokenCredential, nil
667+
default:
668+
t.Fatalf("unexpected tenant ID: %s", tenantID)
669+
return nil, nil
665670
}
666-
667-
t.Fatalf("unexpected tenant ID: %s", tenantID)
668-
return nil, nil
669671
},
670672
},
671673
Assertions: []AuthProviderAssertions{

pkg/azclient/auth_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func TestNewAuthProvider(t *testing.T) {
146146
assert.Equal(t, testTenantID, tenantID)
147147
assert.Equal(t, testAADClientID, clientID)
148148
assert.Equal(t, testAADClientSecret, clientSecret)
149-
assert.Equal(t, testCloudConfig, options.ClientOptions.Cloud)
149+
assert.Equal(t, testCloudConfig, options.Cloud)
150150
return testFakeComputeTokenCredential, nil
151151
}
152152
},
@@ -181,7 +181,7 @@ func TestNewAuthProvider(t *testing.T) {
181181
option.NewClientCertificateCredentialFn = func(tenantID, clientID string, _ []*x509.Certificate, _ crypto.PrivateKey, options *azidentity.ClientCertificateCredentialOptions) (azcore.TokenCredential, error) {
182182
assert.Equal(t, testTenantID, tenantID)
183183
assert.Equal(t, testAADClientID, clientID)
184-
assert.Equal(t, testCloudConfig, options.ClientOptions.Cloud)
184+
assert.Equal(t, testCloudConfig, options.Cloud)
185185
return testFakeComputeTokenCredential, nil
186186
}
187187
},
@@ -227,7 +227,7 @@ func TestNewAuthProvider(t *testing.T) {
227227
assert.Equal(t, testTenantID, tenantID)
228228
assert.Equal(t, testAADClientID, clientID)
229229
assert.Equal(t, testAADClientSecret, clientSecret)
230-
assert.Equal(t, testCloudConfig, options.ClientOptions.Cloud)
230+
assert.Equal(t, testCloudConfig, options.Cloud)
231231
return testFakeComputeTokenCredential, nil
232232
}
233233
},
@@ -257,14 +257,14 @@ func TestNewAuthProvider(t *testing.T) {
257257
assert.Equal(t, testNetworkTenantID, tenantID)
258258
assert.Equal(t, testAADClientID, clientID)
259259
assert.Equal(t, testAADClientSecret, clientSecret)
260-
assert.Equal(t, testCloudConfig, options.ClientOptions.Cloud)
260+
assert.Equal(t, testCloudConfig, options.Cloud)
261261
return testFakeNetworkTokenCredential, nil
262262
}
263263

264264
assert.Equal(t, testTenantID, tenantID)
265265
assert.Equal(t, testAADClientID, clientID)
266266
assert.Equal(t, testAADClientSecret, clientSecret)
267-
assert.Equal(t, testCloudConfig, options.ClientOptions.Cloud)
267+
assert.Equal(t, testCloudConfig, options.Cloud)
268268
return testFakeComputeTokenCredential, nil
269269
}
270270
},

0 commit comments

Comments
 (0)