Skip to content

Commit 73a906e

Browse files
committed
chore: upgrade golangci-lint to version 2
Upgrade Golang to version to 1.25
1 parent 324f3d9 commit 73a906e

33 files changed

+194
-127
lines changed

.github/workflows/static.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ jobs:
1010
- name: Set up Go 1.x
1111
uses: actions/setup-go@v5
1212
with:
13-
go-version: ^1.19
13+
go-version: ^1.25
1414
- uses: actions/checkout@master
1515
- name: Run linter
16-
uses: golangci/golangci-lint-action@v6
16+
uses: golangci/golangci-lint-action@v8
1717
with:
18-
version: v1.64
18+
version: v2.4
1919
args: -E=gofmt,unused,ineffassign,revive,misspell,copyloopvar,asciicheck,bodyclose,contextcheck,dogsled,durationcheck,errname,forbidigo -D=staticcheck --timeout=30m0s

.golangci.yml

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,40 @@
1-
linters-settings:
2-
depguard:
3-
rules:
4-
main:
5-
files:
6-
- $all
7-
- "!$test"
8-
allow:
9-
- $gostd
10-
- k8s.io
11-
- sigs.k8s.io
12-
- github.com
1+
version: "2"
2+
3+
linters:
4+
settings:
5+
depguard:
6+
rules:
7+
main:
8+
files:
9+
- $all
10+
- '!$test'
11+
allow:
12+
- $gostd
13+
- k8s.io
14+
- sigs.k8s.io
15+
- github.com
16+
exclusions:
17+
generated: lax
18+
presets:
19+
- comments
20+
- common-false-positives
21+
- legacy
22+
- std-error-handling
23+
paths:
24+
- third_party$
25+
- builtin$
26+
- examples$
27+
- test/utils/azure/azure_helpers.go
28+
- vendor$
29+
formatters:
30+
enable:
31+
- gofmt
32+
- goimports
33+
- gofumpt
34+
exclusions:
35+
generated: lax
36+
paths:
37+
- third_party$
38+
- builtin$
39+
- examples$
40+
- vendor$

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/kubernetes-csi/csi-driver-smb
22

3-
go 1.24
3+
go 1.25
44

55
godebug winsymlink=0
66

pkg/csi-common/driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func NewCSIDriver(name string, v string, nodeID string) *CSIDriver {
4848
// TODO version format and validation
4949
if len(v) == 0 {
5050
klog.Errorf("Version argument missing, now skip it")
51-
//return nil
51+
// return nil
5252
}
5353

5454
driver := CSIDriver{

pkg/csi-common/driver_test.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,9 @@ const (
3131
fakeNodeID = "fakeNodeID"
3232
)
3333

34-
var (
35-
vendorVersion = "0.3.0"
36-
)
34+
var vendorVersion = "0.3.0"
3735

3836
func NewFakeDriver() *CSIDriver {
39-
4037
driver := NewCSIDriver(fakeDriverName, vendorVersion, fakeNodeID)
4138

4239
return driver
@@ -102,7 +99,6 @@ func TestNewCSIDriver(t *testing.T) {
10299
}
103100

104101
func TestGetVolumeCapabilityAccessModes(t *testing.T) {
105-
106102
d := NewFakeDriver()
107103

108104
// Test no volume access modes.
@@ -159,7 +155,6 @@ func TestValidateControllerServiceRequest(t *testing.T) {
159155
// Test controller service clone volumes is supported
160156
err = d.ValidateControllerServiceRequest(csi.ControllerServiceCapability_RPC_CLONE_VOLUME)
161157
assert.NoError(t, err)
162-
163158
}
164159

165160
func TestValidateNodeServiceRequest(t *testing.T) {

pkg/csi-common/server.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ func (s *nonBlockingGRPCServer) ForceStop() {
6969
}
7070

7171
func (s *nonBlockingGRPCServer) serve(endpoint string, ids csi.IdentityServer, cs csi.ControllerServer, ns csi.NodeServer, testMode bool) {
72-
7372
proto, addr, err := ParseEndpoint(endpoint)
7473
if err != nil {
7574
klog.Fatal(err.Error())

pkg/csi-common/server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func TestServe(_ *testing.T) {
4242
s := nonBlockingGRPCServer{}
4343
s.server = grpc.NewServer()
4444
s.wg = sync.WaitGroup{}
45-
//need to add one here as the actual also requires one.
45+
// need to add one here as the actual also requires one.
4646
s.wg.Add(1)
4747
s.serve("tcp://127.0.0.1:0", nil, nil, nil, true)
4848
}

pkg/csi-common/utils.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ limitations under the License.
1717
package csicommon
1818

1919
import (
20+
"context"
2021
"fmt"
2122
"strings"
2223

23-
"context"
24-
2524
"github.com/container-storage-interface/spec/lib/go/csi"
2625
"github.com/kubernetes-csi/csi-lib-utils/protosanitizer"
2726
"google.golang.org/grpc"
@@ -35,7 +34,7 @@ func ParseEndpoint(ep string) (string, string, error) {
3534
return s[0], s[1], nil
3635
}
3736
}
38-
return "", "", fmt.Errorf("Invalid endpoint: %v", ep)
37+
return "", "", fmt.Errorf("invalid endpoint: %v", ep)
3938
}
4039

4140
func NewVolumeCapabilityAccessMode(mode csi.VolumeCapability_AccessMode_Mode) *csi.VolumeCapability_AccessMode {

pkg/csi-common/utils_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
)
3131

3232
func TestParseEndpoint(t *testing.T) {
33-
//Valid unix domain socket endpoint
33+
// Valid unix domain socket endpoint
3434
sockType, addr, err := ParseEndpoint("unix://fake.sock")
3535
assert.NoError(t, err)
3636
assert.Equal(t, sockType, "unix")
@@ -41,25 +41,25 @@ func TestParseEndpoint(t *testing.T) {
4141
assert.Equal(t, sockType, "unix")
4242
assert.Equal(t, addr, "/fakedir/fakedir/fake.sock")
4343

44-
//Valid unix domain socket with uppercase
44+
// Valid unix domain socket with uppercase
4545
sockType, addr, err = ParseEndpoint("UNIX://fake.sock")
4646
assert.NoError(t, err)
4747
assert.Equal(t, sockType, "UNIX")
4848
assert.Equal(t, addr, "fake.sock")
4949

50-
//Valid TCP endpoint with ip
50+
// Valid TCP endpoint with ip
5151
sockType, addr, err = ParseEndpoint("tcp://127.0.0.1:80")
5252
assert.NoError(t, err)
5353
assert.Equal(t, sockType, "tcp")
5454
assert.Equal(t, addr, "127.0.0.1:80")
5555

56-
//Valid TCP endpoint with uppercase
56+
// Valid TCP endpoint with uppercase
5757
sockType, addr, err = ParseEndpoint("TCP://127.0.0.1:80")
5858
assert.NoError(t, err)
5959
assert.Equal(t, sockType, "TCP")
6060
assert.Equal(t, addr, "127.0.0.1:80")
6161

62-
//Valid TCP endpoint with hostname
62+
// Valid TCP endpoint with hostname
6363
sockType, addr, err = ParseEndpoint("tcp://fakehost:80")
6464
assert.NoError(t, err)
6565
assert.Equal(t, sockType, "tcp")

pkg/mounter/refcounter_windows.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ import (
2828
"sync"
2929
)
3030

31-
var basePath = "c:\\csi\\smbmounts"
32-
var mutexes sync.Map
31+
var (
32+
basePath = "c:\\csi\\smbmounts"
33+
mutexes sync.Map
34+
)
3335

3436
func lock(key string) func() {
3537
value, _ := mutexes.LoadOrStore(key, &sync.Mutex{})

0 commit comments

Comments
 (0)