Skip to content

Commit 5f4e391

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

File tree

12 files changed

+69
-42
lines changed

12 files changed

+69
-42
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: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,36 @@
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+
exclusions:
31+
generated: lax
32+
paths:
33+
- third_party$
34+
- builtin$
35+
- examples$
36+
- 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/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func ParseEndpoint(ep string) (string, string, error) {
3535
return s[0], s[1], nil
3636
}
3737
}
38-
return "", "", fmt.Errorf("Invalid endpoint: %v", ep)
38+
return "", "", fmt.Errorf("invalid endpoint: %v", ep)
3939
}
4040

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

pkg/smb/nodeserver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ func getCredUID(mountFlags []string) (int, error) {
516516
return strconv.Atoi(strings.TrimPrefix(mountFlag, cruidPrefix))
517517
}
518518
}
519-
return -1, fmt.Errorf("Can't find credUid in mount flags")
519+
return -1, fmt.Errorf("can't find credUid in mount flags")
520520
}
521521

522522
func getKrb5CcacheName(krb5Prefix string, credUID int) string {

pkg/smb/nodeserver_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,12 @@ func TestNodeStageVolume(t *testing.T) {
179179
skipOnWindows: true,
180180
flakyWindowsErrorMessage: fmt.Sprintf("rpc error: code = Internal desc = volume(vol_1##) mount \"%s\" on %#v failed "+
181181
"with NewSmbGlobalMapping(%s, %s) failed with error: rpc error: code = Unknown desc = NewSmbGlobalMapping failed.",
182-
strings.Replace(testSource, "\\", "\\\\", -1), errorMountSensSource, testSource, errorMountSensSource),
182+
strings.ReplaceAll(testSource, "\\", "\\\\"), errorMountSensSource, testSource, errorMountSensSource),
183183
expectedErr: testutil.TestError{
184184
DefaultError: status.Errorf(codes.Internal,
185185
"volume(vol_1##) mount \"%s\" on \"%s\" failed with fake "+
186186
"MountSensitive: target error",
187-
strings.Replace(testSource, "\\", "\\\\", -1), errorMountSensSource),
187+
strings.ReplaceAll(testSource, "\\", "\\\\"), errorMountSensSource),
188188
},
189189
},
190190
{
@@ -196,12 +196,12 @@ func TestNodeStageVolume(t *testing.T) {
196196
skipOnWindows: true,
197197
flakyWindowsErrorMessage: fmt.Sprintf("rpc error: code = Internal desc = volume(vol_1##) mount \"%s\" on %#v failed "+
198198
"with NewSmbGlobalMapping(%s, %s) failed with error: rpc error: code = Unknown desc = NewSmbGlobalMapping failed.",
199-
strings.Replace(testSource, "\\", "\\\\", -1), errorMountSensSource, testSource, errorMountSensSource),
199+
strings.ReplaceAll(testSource, "\\", "\\\\"), errorMountSensSource, testSource, errorMountSensSource),
200200
expectedErr: testutil.TestError{
201201
DefaultError: status.Errorf(codes.Internal,
202202
"volume(vol_1##) mount \"%s\" on \"%s\" failed with fake "+
203203
"MountSensitive: target error",
204-
strings.Replace(testSource, "\\", "\\\\", -1), errorMountSensSource),
204+
strings.ReplaceAll(testSource, "\\", "\\\\"), errorMountSensSource),
205205
},
206206
},
207207
{
@@ -213,7 +213,7 @@ func TestNodeStageVolume(t *testing.T) {
213213
skipOnWindows: true,
214214
flakyWindowsErrorMessage: fmt.Sprintf("rpc error: code = Internal desc = volume(vol_1##) mount \"%s\" on %#v failed with "+
215215
"NewSmbGlobalMapping(%s, %s) failed with error: rpc error: code = Unknown desc = NewSmbGlobalMapping failed.",
216-
strings.Replace(testSource, "\\", "\\\\", -1), sourceTest, testSource, sourceTest),
216+
strings.ReplaceAll(testSource, "\\", "\\\\"), sourceTest, testSource, sourceTest),
217217
expectedErr: testutil.TestError{},
218218
},
219219
{
@@ -225,7 +225,7 @@ func TestNodeStageVolume(t *testing.T) {
225225
skipOnWindows: true,
226226
flakyWindowsErrorMessage: fmt.Sprintf("rpc error: code = Internal desc = volume(vol_1##) mount \"%s\" on %#v failed with "+
227227
"NewSmbGlobalMapping(%s, %s) failed with error: rpc error: code = Unknown desc = NewSmbGlobalMapping failed.",
228-
strings.Replace(testSource, "\\", "\\\\", -1), sourceTest, testSource, sourceTest),
228+
strings.ReplaceAll(testSource, "\\", "\\\\"), sourceTest, testSource, sourceTest),
229229
expectedErr: testutil.TestError{},
230230
},
231231
{
@@ -237,7 +237,7 @@ func TestNodeStageVolume(t *testing.T) {
237237
skipOnWindows: true,
238238
flakyWindowsErrorMessage: fmt.Sprintf("rpc error: code = Internal desc = volume(vol_1##) mount \"%s\" on %#v failed with "+
239239
"NewSmbGlobalMapping(%s, %s) failed with error: rpc error: code = Unknown desc = NewSmbGlobalMapping failed.",
240-
strings.Replace(testSource, "\\", "\\\\", -1), sourceTest, testSource, sourceTest),
240+
strings.ReplaceAll(testSource, "\\", "\\\\"), sourceTest, testSource, sourceTest),
241241
expectedErr: testutil.TestError{},
242242
},
243243
{
@@ -249,7 +249,7 @@ func TestNodeStageVolume(t *testing.T) {
249249
skipOnWindows: true,
250250
flakyWindowsErrorMessage: fmt.Sprintf("rpc error: code = Internal desc = volume(vol_1##) mount \"%s\" on %#v failed with "+
251251
"NewSmbGlobalMapping(%s, %s) failed with error: rpc error: code = Unknown desc = NewSmbGlobalMapping failed.",
252-
strings.Replace(testSource, "\\", "\\\\", -1), sourceTest, testSource, sourceTest),
252+
strings.ReplaceAll(testSource, "\\", "\\\\"), sourceTest, testSource, sourceTest),
253253
expectedErr: testutil.TestError{},
254254
},
255255
}
@@ -478,7 +478,7 @@ func TestNodePublishVolume(t *testing.T) {
478478
d.mounter = mounter
479479

480480
for _, test := range tests {
481-
if !(test.skipOnWindows && runtime.GOOS == "windows") {
481+
if !test.skipOnWindows || runtime.GOOS != "windows" {
482482
if test.setup != nil {
483483
test.setup(d)
484484
}
@@ -543,7 +543,7 @@ func TestNodeUnpublishVolume(t *testing.T) {
543543
d.mounter = mounter
544544

545545
for _, test := range tests {
546-
if !(test.skipOnWindows && runtime.GOOS == "windows") {
546+
if !test.skipOnWindows || runtime.GOOS != "windows" {
547547
if test.setup != nil {
548548
test.setup(d)
549549
}
@@ -619,7 +619,7 @@ func TestNodeUnstageVolume(t *testing.T) {
619619
d.mounter = mounter
620620

621621
for _, test := range tests {
622-
if !(test.skipOnWindows && runtime.GOOS == "windows") {
622+
if !test.skipOnWindows || runtime.GOOS != "windows" {
623623
if test.setup != nil {
624624
test.setup(d)
625625
}

pkg/smb/volume_lock.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ const (
2929
// VolumeLocks implements a map with atomic operations. It stores a set of all volume IDs
3030
// with an ongoing operation.
3131
type volumeLocks struct {
32-
locks sets.String
32+
locks sets.Set[string]
3333
mux sync.Mutex
3434
}
3535

3636
func newVolumeLocks() *volumeLocks {
3737
return &volumeLocks{
38-
locks: sets.NewString(),
38+
locks: sets.New[string](),
3939
}
4040
}
4141

test/e2e/suite_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030

3131
"github.com/kubernetes-csi/csi-driver-smb/pkg/smb"
3232
"github.com/onsi/ginkgo/v2"
33-
"github.com/onsi/ginkgo/v2/reporters"
3433
"github.com/onsi/gomega"
3534
"github.com/pborman/uuid"
3635
"k8s.io/kubernetes/test/e2e/framework"
@@ -271,8 +270,10 @@ func TestE2E(t *testing.T) {
271270
if reportDir == "" {
272271
reportDir = defaultReportDir
273272
}
274-
r := []ginkgo.Reporter{reporters.NewJUnitReporter(path.Join(reportDir, "junit_01.xml"))}
275-
ginkgo.RunSpecsWithDefaultAndCustomReporters(t, "SMB CSI Driver End-to-End Tests", r)
273+
// Set the GINKGO_JUNIT_REPORT environment variable to enable JUnit reporting
274+
os.Setenv("GINKGO_JUNIT_REPORT", path.Join(reportDir, "junit_01.xml"))
275+
276+
ginkgo.RunSpecs(t, "SMB CSI Driver End-to-End Tests")
276277
}
277278

278279
func execTestCmd(cmds []testCmd) {

test/e2e/testsuites/dynamically_provisioned_resize_volume_tester.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (t *DynamicallyProvisionedResizeVolumeTest) Run(ctx context.Context, client
5555
ginkgo.By("checking that the pods command exits with no error")
5656
tpod.WaitForSuccess(ctx)
5757

58-
pvcName := tpod.pod.Spec.Volumes[0].VolumeSource.PersistentVolumeClaim.ClaimName
58+
pvcName := tpod.pod.Spec.Volumes[0].PersistentVolumeClaim.ClaimName
5959
pvc, err := client.CoreV1().PersistentVolumeClaims(namespace.Name).Get(ctx, pvcName, metav1.GetOptions{})
6060
if err != nil {
6161
framework.ExpectNoError(err, fmt.Sprintf("fail to get original pvc(%s): %v", pvcName, err))
@@ -78,7 +78,7 @@ func (t *DynamicallyProvisionedResizeVolumeTest) Run(ctx context.Context, client
7878
time.Sleep(30 * time.Second)
7979

8080
ginkgo.By("checking the resizing result")
81-
newPvc, err := client.CoreV1().PersistentVolumeClaims(namespace.Name).Get(ctx, tpod.pod.Spec.Volumes[0].VolumeSource.PersistentVolumeClaim.ClaimName, metav1.GetOptions{})
81+
newPvc, err := client.CoreV1().PersistentVolumeClaims(namespace.Name).Get(ctx, tpod.pod.Spec.Volumes[0].PersistentVolumeClaim.ClaimName, metav1.GetOptions{})
8282
if err != nil {
8383
framework.ExpectNoError(err, fmt.Sprintf("fail to get new pvc(%s): %v", pvcName, err))
8484
}

test/e2e/testsuites/dynamically_provisioned_volume_cloning_tester.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (t *DynamicallyProvisionedVolumeCloningTest) Run(ctx context.Context, clien
5959
ginkgo.By("cloning existing volume")
6060
clonedVolume := t.Pod.Volumes[0]
6161
clonedVolume.DataSource = &DataSource{
62-
Name: tpod.pod.Spec.Volumes[0].VolumeSource.PersistentVolumeClaim.ClaimName,
62+
Name: tpod.pod.Spec.Volumes[0].PersistentVolumeClaim.ClaimName,
6363
Kind: VolumePVCKind,
6464
}
6565
clonedVolume.StorageClass = tsc.storageClass

0 commit comments

Comments
 (0)