Skip to content

Commit 008c2e5

Browse files
committed
bump golangci-lint to v2
Signed-off-by: Iceber Gu <[email protected]>
1 parent bab7bdd commit 008c2e5

File tree

7 files changed

+69
-47
lines changed

7 files changed

+69
-47
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ jobs:
1313
uses: actions/setup-go@v5
1414
with:
1515
go-version: '1.22'
16-
- uses: golangci/golangci-lint-action@v6
16+
- uses: golangci/golangci-lint-action@v8
1717
with:
18-
version: v1.54
18+
version: v2.1.6
1919
vertify:
2020
name: Vertify import alias, vendor, codegen, crds
2121
runs-on: ubuntu-latest

.golangci.yml

Lines changed: 53 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,66 @@
1+
version: "2"
12
run:
2-
timeout: 10m
33
modules-download-mode: vendor
44
linters:
5-
disable-all: true
5+
default: none
66
enable:
77
- bodyclose
88
- dupl
99
- errcheck
10-
- gci
11-
- gofmt
12-
- goimports
13-
- gosimple
1410
- govet
1511
- ineffassign
1612
- misspell
1713
- staticcheck
18-
- typecheck
1914
- unused
2015
- whitespace
21-
linters-settings:
22-
goimports:
23-
local-prefixes: github.com/clusterpedia-io
24-
misspell:
25-
ignore-words:
26-
- creater
27-
gci:
28-
sections:
29-
- Standard
30-
- Default
31-
- Prefix(github.com/clusterpedia-io)
32-
staticcheck:
33-
checks:
34-
- all
35-
- "-SA1019" # disable the rule SA1019(Using a deprecated function, variable, constant or field)
36-
output:
37-
sort-results: true
38-
39-
issues:
40-
exclude-rules:
41-
- path: pkg/storage/memorystorage/v2/
42-
linters: unused # memory v2 is in alpha and tolerates unused functions or fields
16+
settings:
17+
misspell:
18+
ignore-rules:
19+
- creater
20+
staticcheck:
21+
checks:
22+
- all
23+
# Poorly chosen identifier.
24+
# https://staticcheck.dev/docs/checks/#ST1003
25+
- -ST1003
26+
# Omit embedded fields from selector expression.
27+
# https://staticcheck.dev/docs/checks/#QF1008
28+
- -QF1008
29+
# Convert untagged switch to tagged switch.
30+
# https://staticcheck.dev/docs/checks/#QF1002
31+
- -QF1001
32+
exclusions:
33+
generated: lax
34+
presets:
35+
- comments
36+
- common-false-positives
37+
- legacy
38+
- std-error-handling
39+
paths:
40+
- third_party$
41+
- builtin$
42+
- examples$
43+
rules:
44+
- path: pkg/storage/memorystorage/v2/
45+
linters:
46+
- unused
47+
formatters:
48+
enable:
49+
- gci
50+
- gofmt
51+
- goimports
52+
settings:
53+
gci:
54+
sections:
55+
- Standard
56+
- Default
57+
- Prefix(github.com/clusterpedia-io)
58+
goimports:
59+
local-prefixes:
60+
- github.com/clusterpedia-io
61+
exclusions:
62+
generated: lax
63+
paths:
64+
- third_party$
65+
- builtin$
66+
- examples$

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ clean-controller-manager-manifest:
268268
.PHONY: golangci-lint
269269
golangci-lint:
270270
ifeq (, $(shell which golangci-lint))
271-
GO111MODULE=on go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54
271+
GO111MODULE=on go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6
272272
GOLANGLINT_BIN=$(shell go env GOPATH)/bin/golangci-lint
273273
else
274274
GOLANGLINT_BIN=$(shell which golangci-lint)

pkg/apiserver/registry/clusterpedia/resources/rest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (r *REST) NamespaceScoped() bool {
5353
}
5454

5555
// GetSingularName implements rest.SingularNameProvider interface
56-
func (s *REST) GetSingularName() string {
56+
func (r *REST) GetSingularName() string {
5757
return "resources"
5858
}
5959

pkg/kubeapiserver/resourcerest/proxy/subresource.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"k8s.io/apimachinery/pkg/runtime/schema"
99
"k8s.io/apimachinery/pkg/util/proxy"
1010
"k8s.io/apiserver/pkg/registry/rest"
11-
registryrest "k8s.io/apiserver/pkg/registry/rest"
1211
api "k8s.io/kubernetes/pkg/apis/core"
1312
)
1413

@@ -140,6 +139,6 @@ func (r *PodSubresourceRemoteProxyREST) ConnectMethods() []string {
140139
return r.methods
141140
}
142141

143-
func (r *PodSubresourceRemoteProxyREST) Connect(ctx context.Context, name string, opts runtime.Object, responder registryrest.Responder) (http.Handler, error) {
142+
func (r *PodSubresourceRemoteProxyREST) Connect(ctx context.Context, name string, opts runtime.Object, responder rest.Responder) (http.Handler, error) {
144143
return proxyConn(ctx, r.connGetter, r.upgradeRequired, proxy.NewErrorResponder(responder), nil)
145144
}

pkg/synchromanager/clustersynchro/cluster_synchro.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -500,31 +500,31 @@ func (s *ClusterSynchro) runner() {
500500
}
501501
}
502502

503-
func (synchro *ClusterSynchro) startRunner() {
503+
func (s *ClusterSynchro) startRunner() {
504504
select {
505-
case <-synchro.stopRunnerCh:
506-
synchro.stopRunnerCh = make(chan struct{})
505+
case <-s.stopRunnerCh:
506+
s.stopRunnerCh = make(chan struct{})
507507
default:
508508
}
509509

510510
select {
511-
case <-synchro.startRunnerCh:
511+
case <-s.startRunnerCh:
512512
default:
513-
close(synchro.startRunnerCh)
513+
close(s.startRunnerCh)
514514
}
515515
}
516516

517-
func (synchro *ClusterSynchro) stopRunner() {
517+
func (s *ClusterSynchro) stopRunner() {
518518
select {
519-
case <-synchro.startRunnerCh:
520-
synchro.startRunnerCh = make(chan struct{})
519+
case <-s.startRunnerCh:
520+
s.startRunnerCh = make(chan struct{})
521521
default:
522522
}
523523

524524
select {
525-
case <-synchro.stopRunnerCh:
525+
case <-s.stopRunnerCh:
526526
default:
527-
close(synchro.stopRunnerCh)
527+
close(s.stopRunnerCh)
528528
}
529529
}
530530

pkg/synchromanager/clustersynchro_manager.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
metricsstore "k8s.io/kube-state-metrics/v2/pkg/metrics_store"
2727
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
2828

29-
"github.com/clusterpedia-io/api/cluster/v1alpha2"
3029
clusterv1alpha2 "github.com/clusterpedia-io/api/cluster/v1alpha2"
3130
"github.com/clusterpedia-io/clusterpedia/pkg/controller"
3231
crdclientset "github.com/clusterpedia-io/clusterpedia/pkg/generated/clientset/versioned"
@@ -403,7 +402,7 @@ func (manager *Manager) reconcileCluster(cluster *clusterv1alpha2.PediaCluster)
403402

404403
if from := cluster.Spec.AuthenticationFrom; from != nil {
405404
secrets := make(map[string]struct{}, 5)
406-
for _, source := range []*v1alpha2.ClusterAuthenticationSource{
405+
for _, source := range []*clusterv1alpha2.ClusterAuthenticationSource{
407406
from.KubeConfig, from.CA, from.Cert, from.Token, from.Key,
408407
} {
409408
if source != nil {

0 commit comments

Comments
 (0)