Skip to content

Commit 279c252

Browse files
Merge pull request #1235 from anmazzotti/bump_golangci-lint
Bump golangci-lint to v2
2 parents 190894b + af33f9f commit 279c252

File tree

12 files changed

+141
-126
lines changed

12 files changed

+141
-126
lines changed

.github/workflows/golangci-lint.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ jobs:
2525
with:
2626
go-version: '=1.23.0'
2727
- name: golangci-lint
28-
uses: golangci/golangci-lint-action@v6.5.2
28+
uses: golangci/golangci-lint-action@v7
2929
with:
30-
version: v1.64.5
30+
version: v2.0.2
3131
working-directory: ${{matrix.working-directory}}
3232
args: --timeout=5m0s
3333
skip-cache: true

.golangci.yml

Lines changed: 119 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,57 @@
1-
# Options for analysis running.
1+
version: "2"
22
run:
33
go: "1.23"
44
allow-parallel-runners: true
5-
issues:
6-
exclude-files:
7-
- ".*_test\\.go$"
8-
include:
9-
- EXC0012
10-
- EXC0014
11-
exclude-rules:
12-
- path: _test\.go
13-
linters:
14-
- testpackage
15-
- gochecknoglobals
16-
- path: internal/controllers/import_controller(_v3)?\.go
17-
linters:
18-
- dupl
19-
- path: exp/day2/controllers/.*.go
20-
linters:
21-
- dupl
22-
- text: var-naming
23-
linters:
24-
- revive
25-
- text: ST1003
26-
linters:
27-
- stylecheck
28-
- linters:
29-
- revive
30-
text: "exported: exported method .*\\.(Reconcile|SetupWithManager|SetupWebhookWithManager) should have comment or be unexported"
31-
path: exp/day2/controllers/.*.go
32-
- path: exp/day2/controllers/.*.go
33-
linters:
34-
- unused
35-
linters-settings:
36-
funlen:
37-
lines: 110
38-
statements: 60
39-
lll:
40-
line-length: 150
41-
goimports:
42-
local-prefixes: github.com/rancher/turtles
43-
gci:
44-
custom-order: true
45-
sections:
46-
- "standard"
47-
- "blank"
48-
- "dot"
49-
- "default"
50-
- "prefix(sigs.k8s.io/cluster-api)"
51-
- "prefix(github.com/rancher/turtles)"
52-
importas:
53-
no-unaliased: true
5+
linters:
6+
default: all
7+
disable:
8+
- containedctx
9+
- cyclop
10+
- depguard
11+
- err113
12+
- exhaustive
13+
- exhaustruct
14+
- funlen
15+
- gochecknoglobals
16+
- gochecknoinits
17+
- gocritic
18+
- godox
19+
- ireturn
20+
- mnd
21+
- nlreturn
22+
- nolintlint
23+
- nonamedreturns
24+
- paralleltest
25+
- rowserrcheck
26+
- sqlclosecheck
27+
- tagliatelle
28+
- varnamelen
29+
- wastedassign
30+
- wrapcheck
31+
settings:
32+
funlen:
33+
lines: 110
34+
statements: 60
35+
goheader:
36+
values:
37+
regexp:
38+
copyright_regex: 'Copyright © (\d{4})(?: - (\d{4}))? SUSE LLC'
39+
template: |-
40+
{{copyright_regex}}
41+
42+
Licensed under the Apache License, Version 2.0 (the "License");
43+
you may not use this file except in compliance with the License.
44+
You may obtain a copy of the License at
45+
46+
http://www.apache.org/licenses/LICENSE-2.0
47+
48+
Unless required by applicable law or agreed to in writing, software
49+
distributed under the License is distributed on an "AS IS" BASIS,
50+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
51+
See the License for the specific language governing permissions and
52+
limitations under the License.
53+
importas:
5454
alias:
55-
# Kubernetes
5655
- pkg: k8s.io/api/core/v1
5756
alias: corev1
5857
- pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1
@@ -65,22 +64,21 @@ linters-settings:
6564
alias: utilruntime
6665
- pkg: k8s.io/client-go/kubernetes/scheme
6766
alias: clientgoscheme
68-
# Rancher Turtles
6967
- pkg: github.com/rancher/turtles/util/naming
7068
alias: turtlesnaming
7169
- pkg: github.com/rancher/turtles/api/rancher/provisioning/v1
7270
alias: provisioningv1
7371
- pkg: github.com/rancher/turtles/api/rancher/management/v3
7472
alias: managementv3
75-
# Controller Runtime
7673
- pkg: sigs.k8s.io/controller-runtime
7774
alias: ctrl
78-
# CAPI
7975
- pkg: sigs.k8s.io/cluster-api/api/v1beta1
8076
alias: clusterv1
81-
revive:
77+
no-unaliased: true
78+
lll:
79+
line-length: 150
80+
revive:
8281
rules:
83-
# The following rules are recommended https://github.com/mgechev/revive#recommended-configuration
8482
- name: blank-imports
8583
- name: context-as-argument
8684
- name: context-keys-type
@@ -105,53 +103,70 @@ linters-settings:
105103
- name: unused-parameter
106104
- name: unreachable-code
107105
- name: redefines-builtin-id
108-
#
109-
# Rules in addition to the recommended configuration above.
110-
#
111106
- name: bool-literal-in-expr
112107
- name: constant-logical-expr
113-
goheader:
114-
values:
115-
regexp:
116-
copyright_regex: "Copyright © (\\d{4})(?: - (\\d{4}))? SUSE LLC"
117-
template: |-
118-
{{copyright_regex}}
119-
120-
Licensed under the Apache License, Version 2.0 (the "License");
121-
you may not use this file except in compliance with the License.
122-
You may obtain a copy of the License at
123-
124-
http://www.apache.org/licenses/LICENSE-2.0
125-
126-
Unless required by applicable law or agreed to in writing, software
127-
distributed under the License is distributed on an "AS IS" BASIS,
128-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
129-
See the License for the specific language governing permissions and
130-
limitations under the License.
131-
linters:
132-
enable-all: true
133-
disable:
134-
- nolintlint
135-
- tagliatelle
136-
- exhaustruct
137-
- exhaustive
138-
- funlen
139-
- wrapcheck
140-
- goerr113
141-
- paralleltest
142-
- varnamelen
143-
- cyclop
144-
- gochecknoglobals
145-
- gochecknoinits
146-
- nonamedreturns
147-
- gocritic
148-
- nlreturn
149-
- mnd
150-
- ireturn
151-
- depguard
152-
- containedctx
153-
- godox
154-
# Disabled because of generics
155-
- rowserrcheck
156-
- sqlclosecheck
157-
- wastedassign
108+
exclusions:
109+
generated: lax
110+
presets:
111+
- common-false-positives
112+
- legacy
113+
- std-error-handling
114+
rules:
115+
- linters:
116+
- gochecknoglobals
117+
- testpackage
118+
path: _test\.go
119+
- linters:
120+
- dupl
121+
path: internal/controllers/import_controller(_v3)?\.go
122+
- linters:
123+
- dupl
124+
path: exp/day2/controllers/.*.go
125+
- linters:
126+
- revive
127+
text: var-naming
128+
- linters:
129+
- staticcheck
130+
text: ST1003
131+
- linters:
132+
- revive
133+
path: exp/day2/controllers/.*.go
134+
text: 'exported: exported method .*\.(Reconcile|SetupWithManager|SetupWebhookWithManager) should have comment or be unexported'
135+
- linters:
136+
- unused
137+
path: exp/day2/controllers/.*.go
138+
- linters:
139+
- revive
140+
text: 'package-comments: should have a package comment'
141+
paths:
142+
- examples/examples.go
143+
- .*_test\.go$
144+
- third_party$
145+
- builtin$
146+
- examples$
147+
formatters:
148+
enable:
149+
- gci
150+
- gofmt
151+
- gofumpt
152+
- goimports
153+
settings:
154+
gci:
155+
sections:
156+
- standard
157+
- blank
158+
- dot
159+
- default
160+
- prefix(sigs.k8s.io/cluster-api)
161+
- prefix(github.com/rancher/turtles)
162+
custom-order: true
163+
goimports:
164+
local-prefixes:
165+
- github.com/rancher/turtles
166+
exclusions:
167+
generated: lax
168+
paths:
169+
- .*_test\.go$
170+
- third_party$
171+
- builtin$
172+
- examples$

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ CLUSTERCTL := $(TOOLS_BIN_DIR)/$(CLUSTERCTL_BIN)-$(CLUSTERCTL_VER)
160160
GOLANGCI_LINT_BIN := golangci-lint
161161
GOLANGCI_LINT_VER := $(shell cat .github/workflows/golangci-lint.yaml | grep [[:space:]]version: | sed 's/.*version: //')
162162
GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER))
163-
GOLANGCI_LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint
163+
GOLANGCI_LINT_PKG := github.com/golangci/golangci-lint/v2/cmd/golangci-lint
164164

165165
NOTES_BIN := notes
166166
NOTES := $(abspath $(TOOLS_BIN_DIR)/$(NOTES_BIN))

api/rancher/management/v3/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
// Package rancher contains the rancher provisioning.cattle.io/v1 and
17+
// Package v3 rancher contains the rancher provisioning.cattle.io/v1 and
1818
// management.cattle.io/v3 API proxy implementations.
1919
package v3

api/rancher/provisioning/v1/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
// Package rancher contains the rancher provisioning.cattle.io/v1 and
17+
// Package v1 rancher contains the rancher provisioning.cattle.io/v1 and
1818
// management.cattle.io/v3 API proxy implementations.
1919
package v1

internal/controllers/clusterctlconfig_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (r *ClusterctlConfigReconciler) SetupWithManager(ctx context.Context, mgr c
7676
configMapTemplate := clusterctl.Config()
7777
configMapTemplate.Data = nil
7878

79-
err = r.Client.Patch(ctx, configMapTemplate, client.Apply, []client.PatchOption{
79+
err = r.Patch(ctx, configMapTemplate, client.Apply, []client.PatchOption{
8080
client.ForceOwnership,
8181
client.FieldOwner("clusterctl-controller"),
8282
}...)
@@ -113,7 +113,7 @@ func (r *ClusterctlConfigReconciler) Reconcile(ctx context.Context, _ reconcile.
113113
configMap := clusterctl.Config()
114114
configMap.Data["clusterctl.yaml"] = string(clusterctlYaml)
115115

116-
if err := r.Client.Patch(ctx, configMap, client.Apply, []client.PatchOption{
116+
if err := r.Patch(ctx, configMap, client.Apply, []client.PatchOption{
117117
client.ForceOwnership,
118118
client.FieldOwner("clusterctlconfig-controller"),
119119
}...); err != nil {

internal/controllers/import_controller_v3.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func (r *CAPIImportManagementV3Reconciler) Reconcile(ctx context.Context, req ct
156156

157157
log = log.WithValues("cluster", capiCluster.Name)
158158

159-
if capiCluster.ObjectMeta.DeletionTimestamp.IsZero() && !turtlesannotations.HasClusterImportAnnotation(capiCluster) &&
159+
if capiCluster.DeletionTimestamp.IsZero() && !turtlesannotations.HasClusterImportAnnotation(capiCluster) &&
160160
controllerutil.AddFinalizer(capiCluster, managementv3.CapiClusterFinalizer) {
161161
log.Info("CAPI cluster is marked for import, adding finalizer")
162162

@@ -232,7 +232,7 @@ func (r *CAPIImportManagementV3Reconciler) reconcile(ctx context.Context, capiCl
232232
rancherCluster = &rancherClusterList.Items[0]
233233
}
234234

235-
if rancherCluster != nil && !rancherCluster.ObjectMeta.DeletionTimestamp.IsZero() {
235+
if rancherCluster != nil && !rancherCluster.DeletionTimestamp.IsZero() {
236236
if err := r.reconcileDelete(ctx, capiCluster); err != nil {
237237
log.Error(err, "Removing CAPI Cluster failed, retrying")
238238
return ctrl.Result{}, err
@@ -245,7 +245,7 @@ func (r *CAPIImportManagementV3Reconciler) reconcile(ctx context.Context, capiCl
245245
}
246246
}
247247

248-
if !capiCluster.ObjectMeta.DeletionTimestamp.IsZero() {
248+
if !capiCluster.DeletionTimestamp.IsZero() {
249249
if err := r.deleteDependentRancherCluster(ctx, capiCluster); err != nil {
250250
return ctrl.Result{}, fmt.Errorf("error deleting associated managementv3.Cluster resources: %w", err)
251251
}

internal/controllers/uiplugin_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (r *UIPluginReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
7575
plugin.SetKind("UIPlugin")
7676
plugin.SetAPIVersion("catalog.cattle.io/v1")
7777

78-
if err := r.Client.Get(ctx, req.NamespacedName, plugin); err != nil {
78+
if err := r.Get(ctx, req.NamespacedName, plugin); err != nil {
7979
log.Error(err, "Unable to get UIPlugin")
8080

8181
return ctrl.Result{}, client.IgnoreNotFound(err)

internal/sync/provider_sync.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func (s *ProviderSync) SyncObjects() {
124124
}
125125

126126
func (s *ProviderSync) syncStatus() {
127-
s.DefaultSynchronizer.Source.SetProviderName()
127+
s.Source.SetProviderName()
128128

129129
switch {
130130
case conditions.IsTrue(s.Source, operatorv1.ProviderInstalledCondition):

internal/sync/secret_mapper_sync.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,9 @@ func (s *SecretMapperSync) Get(ctx context.Context) error {
289289
// Sync updates the credentials secret with required values from rancher manager secret.
290290
func (s *SecretMapperSync) Sync(ctx context.Context) error {
291291
log := log.FromContext(ctx)
292-
s.SecretSync.Secret.StringData = map[string]string{}
292+
s.Secret.StringData = map[string]string{}
293293

294-
if err := Into(s.Source.ProviderName(), s.RancherSecret.Data, s.SecretSync.Secret.StringData); err != nil {
294+
if err := Into(s.Source.ProviderName(), s.RancherSecret.Data, s.Secret.StringData); err != nil {
295295
log.Error(err, "failed to map credential keys")
296296

297297
conditions.Set(s.Source, conditions.FalseCondition(

0 commit comments

Comments
 (0)