Skip to content

Commit aee5173

Browse files
committed
chore: upgrade golint version
1 parent e110f3d commit aee5173

File tree

9 files changed

+28
-28
lines changed

9 files changed

+28
-28
lines changed

.github/workflows/static.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ jobs:
1515
- name: Run linter
1616
uses: golangci/golangci-lint-action@v6
1717
with:
18-
version: v1.54
18+
version: v1.60
1919
args: -E=gofmt,unused,ineffassign,revive,misspell,exportloopref,asciicheck,bodyclose,contextcheck,depguard,dogsled,durationcheck,errname,forbidigo -D=staticcheck --timeout=30m0s

pkg/csi-common/utils_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func TestLogGRPC(t *testing.T) {
9898
buf := new(bytes.Buffer)
9999
klog.SetOutput(buf)
100100

101-
handler := func(ctx context.Context, req interface{}) (interface{}, error) { return nil, nil }
101+
handler := func(_ context.Context, _ interface{}) (interface{}, error) { return nil, nil }
102102
info := grpc.UnaryServerInfo{
103103
FullMethod: "fake",
104104
}

pkg/smb/controllerserver.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,18 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest)
108108
if createSubDir {
109109
// Mount smb base share so we can create a subdirectory
110110
if err := d.internalMount(ctx, smbVol, volCap, secrets); err != nil {
111-
return nil, status.Errorf(codes.Internal, "failed to mount smb server: %v", err.Error())
111+
return nil, status.Errorf(codes.Internal, "failed to mount smb server: %v", err)
112112
}
113113
defer func() {
114114
if err = d.internalUnmount(ctx, smbVol); err != nil {
115-
klog.Warningf("failed to unmount smb server: %v", err.Error())
115+
klog.Warningf("failed to unmount smb server: %v", err)
116116
}
117117
}()
118118
// Create subdirectory under base-dir
119119
// TODO: revisit permissions
120120
internalVolumePath := getInternalVolumePath(d.workingMountDir, smbVol)
121121
if err = os.MkdirAll(internalVolumePath, 0777); err != nil {
122-
return nil, status.Errorf(codes.Internal, "failed to make subdirectory: %v", err.Error())
122+
return nil, status.Errorf(codes.Internal, "failed to make subdirectory: %v", err)
123123
}
124124

125125
if req.GetVolumeContentSource() != nil {
@@ -182,7 +182,7 @@ func (d *Driver) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest)
182182
// check whether volumeID is in the cache
183183
cache, err := d.volDeletionCache.Get(volumeID, azcache.CacheReadTypeDefault)
184184
if err != nil {
185-
return nil, status.Errorf(codes.Internal, err.Error())
185+
return nil, status.Errorf(codes.Internal, "%v", err)
186186
}
187187
if cache != nil {
188188
klog.V(2).Infof("DeleteVolume: volume %s is already deleted", volumeID)
@@ -191,11 +191,11 @@ func (d *Driver) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest)
191191

192192
// mount smb base share so we can delete or archive the subdirectory
193193
if err = d.internalMount(ctx, smbVol, volCap, secrets); err != nil {
194-
return nil, status.Errorf(codes.Internal, "failed to mount smb server: %v", err.Error())
194+
return nil, status.Errorf(codes.Internal, "failed to mount smb server: %v", err)
195195
}
196196
defer func() {
197197
if err = d.internalUnmount(ctx, smbVol); err != nil {
198-
klog.Warningf("failed to unmount smb server: %v", err.Error())
198+
klog.Warningf("failed to unmount smb server: %v", err)
199199
}
200200
}()
201201

@@ -207,7 +207,7 @@ func (d *Driver) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest)
207207
parentDir := filepath.Dir(archivedInternalVolumePath)
208208
klog.V(2).Infof("DeleteVolume: subdirectory(%s) contains '/', make sure the parent directory(%s) exists", smbVol.subDir, parentDir)
209209
if err = os.MkdirAll(parentDir, 0777); err != nil {
210-
return nil, status.Errorf(codes.Internal, "create parent directory(%s) of %s failed with %v", parentDir, archivedInternalVolumePath, err.Error())
210+
return nil, status.Errorf(codes.Internal, "create parent directory(%s) of %s failed with %v", parentDir, archivedInternalVolumePath, err)
211211
}
212212
}
213213

@@ -216,16 +216,16 @@ func (d *Driver) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest)
216216
if d.removeArchivedVolumePath {
217217
klog.V(2).Infof("removing archived subdirectory at %v", archivedInternalVolumePath)
218218
if err = os.RemoveAll(archivedInternalVolumePath); err != nil {
219-
return nil, status.Errorf(codes.Internal, "failed to delete archived subdirectory %s: %v", archivedInternalVolumePath, err.Error())
219+
return nil, status.Errorf(codes.Internal, "failed to delete archived subdirectory %s: %v", archivedInternalVolumePath, err)
220220
}
221221
klog.V(2).Infof("removed archived subdirectory at %v", archivedInternalVolumePath)
222222
}
223223
if err = os.Rename(internalVolumePath, archivedInternalVolumePath); err != nil {
224-
return nil, status.Errorf(codes.Internal, "archive subdirectory(%s, %s) failed with %v", internalVolumePath, archivedInternalVolumePath, err.Error())
224+
return nil, status.Errorf(codes.Internal, "archive subdirectory(%s, %s) failed with %v", internalVolumePath, archivedInternalVolumePath, err)
225225
}
226226
} else {
227227
if _, err2 := os.Lstat(internalVolumePath); err2 == nil {
228-
err2 := filepath.WalkDir(internalVolumePath, func(path string, di fs.DirEntry, err error) error {
228+
err2 := filepath.WalkDir(internalVolumePath, func(path string, _ fs.DirEntry, _ error) error {
229229
return os.Chmod(path, 0777)
230230
})
231231
if err2 != nil {
@@ -234,7 +234,7 @@ func (d *Driver) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest)
234234
}
235235
klog.V(2).Infof("Removing subdirectory at %v", internalVolumePath)
236236
if err = os.RemoveAll(internalVolumePath); err != nil {
237-
return nil, status.Errorf(codes.Internal, "failed to delete subdirectory: %v", err.Error())
237+
return nil, status.Errorf(codes.Internal, "failed to delete subdirectory: %v", err)
238238
}
239239
}
240240
} else {

pkg/smb/controllerserver_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func TestCreateVolume(t *testing.T) {
7474
// Setup mounter
7575
mounter, err := NewFakeMounter()
7676
if err != nil {
77-
t.Fatalf(fmt.Sprintf("failed to get fake mounter: %v", err))
77+
t.Fatalf("failed to get fake mounter: %v", err)
7878
}
7979
d.mounter = mounter
8080

@@ -234,7 +234,7 @@ func TestDeleteVolume(t *testing.T) {
234234
// Setup mounter
235235
mounter, err := NewFakeMounter()
236236
if err != nil {
237-
t.Fatalf(fmt.Sprintf("failed to get fake mounter: %v", err))
237+
t.Fatalf("failed to get fake mounter: %v", err)
238238
}
239239
d.mounter = mounter
240240

@@ -762,7 +762,7 @@ func TestCopyFromVolume(t *testing.T) {
762762
// Setup mounter
763763
mounter, err := NewFakeMounter()
764764
if err != nil {
765-
t.Fatalf(fmt.Sprintf("failed to get fake mounter: %v", err))
765+
t.Fatalf("failed to get fake mounter: %v", err)
766766
}
767767
d.mounter = mounter
768768

pkg/smb/nodeserver.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ func (d *Driver) NodeGetVolumeStats(_ context.Context, req *csi.NodeGetVolumeSta
300300
// check if the volume stats is cached
301301
cache, err := d.volStatsCache.Get(req.VolumeId, azcache.CacheReadTypeDefault)
302302
if err != nil {
303-
return nil, status.Errorf(codes.Internal, err.Error())
303+
return nil, status.Errorf(codes.Internal, "%v", err)
304304
}
305305
if cache != nil {
306306
resp := cache.(csi.NodeGetVolumeStatsResponse)

pkg/smb/nodeserver_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ func TestNodeStageVolume(t *testing.T) {
162162
strings.Replace(testSource, "\\", "\\\\", -1), errorMountSensSource, testSource, errorMountSensSource),
163163
expectedErr: testutil.TestError{
164164
DefaultError: status.Errorf(codes.Internal,
165-
fmt.Sprintf("volume(vol_1##) mount \"%s\" on \"%s\" failed with fake "+
165+
"volume(vol_1##) mount \"%s\" on \"%s\" failed with fake "+
166166
"MountSensitive: target error",
167-
strings.Replace(testSource, "\\", "\\\\", -1), errorMountSensSource)),
167+
strings.Replace(testSource, "\\", "\\\\", -1), errorMountSensSource),
168168
},
169169
},
170170
{
@@ -202,7 +202,7 @@ func TestNodeStageVolume(t *testing.T) {
202202
}
203203
mounter, err := NewFakeMounter()
204204
if err != nil {
205-
t.Fatalf(fmt.Sprintf("failed to get fake mounter: %v", err))
205+
t.Fatalf("failed to get fake mounter: %v", err)
206206
}
207207
d.mounter = mounter
208208

@@ -344,7 +344,7 @@ func TestNodePublishVolume(t *testing.T) {
344344
// Once the issue is figured out, we'll remove this field
345345
skipOnWindows: true,
346346
expectedErr: testutil.TestError{
347-
DefaultError: status.Errorf(codes.Internal, fmt.Sprintf("Could not mount \"%s\" at \"%s\": fake Mount: source error", errorMountSource, targetTest)),
347+
DefaultError: status.Errorf(codes.Internal, "Could not mount \"%s\" at \"%s\": fake Mount: source error", errorMountSource, targetTest),
348348
},
349349
},
350350
{
@@ -381,7 +381,7 @@ func TestNodePublishVolume(t *testing.T) {
381381
d := NewFakeDriver()
382382
mounter, err := NewFakeMounter()
383383
if err != nil {
384-
t.Fatalf(fmt.Sprintf("failed to get fake mounter: %v", err))
384+
t.Fatalf("failed to get fake mounter: %v", err)
385385
}
386386
d.mounter = mounter
387387

@@ -446,7 +446,7 @@ func TestNodeUnpublishVolume(t *testing.T) {
446446
d := NewFakeDriver()
447447
mounter, err := NewFakeMounter()
448448
if err != nil {
449-
t.Fatalf(fmt.Sprintf("failed to get fake mounter: %v", err))
449+
t.Fatalf("failed to get fake mounter: %v", err)
450450
}
451451
d.mounter = mounter
452452

@@ -522,7 +522,7 @@ func TestNodeUnstageVolume(t *testing.T) {
522522
d := NewFakeDriver()
523523
mounter, err := NewFakeMounter()
524524
if err != nil {
525-
t.Fatalf(fmt.Sprintf("failed to get fake mounter: %v", err))
525+
t.Fatalf("failed to get fake mounter: %v", err)
526526
}
527527
d.mounter = mounter
528528

pkg/smb/smb.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func NewDriver(options *DriverOptions) *Driver {
118118
options.VolStatsCacheExpireInMinutes = 10 // default expire in 10 minutes
119119
}
120120
var err error
121-
getter := func(key string) (interface{}, error) { return nil, nil }
121+
getter := func(_ string) (interface{}, error) { return nil, nil }
122122
if driver.volStatsCache, err = azcache.NewTimedCache(time.Duration(options.VolStatsCacheExpireInMinutes)*time.Minute, getter, false); err != nil {
123123
klog.Fatalf("%v", err)
124124
}

pkg/smb/smb_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ func TestRun(t *testing.T) {
9191
}{
9292
{
9393
name: "Successful run",
94-
testFunc: func(t *testing.T) {
94+
testFunc: func(_ *testing.T) {
9595
d := NewFakeDriver()
9696
d.Run("tcp://127.0.0.1:0", "", true)
9797
},
9898
},
9999
{
100100
name: "Successful run with node ID missing",
101-
testFunc: func(t *testing.T) {
101+
testFunc: func(_ *testing.T) {
102102
d := NewFakeDriver()
103103
d.NodeID = ""
104104
d.Run("tcp://127.0.0.1:0", "", true)

test/e2e/dynamic_provisioning_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() {
4040
testDriver driver.PVTestDriver
4141
)
4242

43-
ginkgo.BeforeEach(func(ctx ginkgo.SpecContext) {
43+
ginkgo.BeforeEach(func(_ ginkgo.SpecContext) {
4444
checkPodsRestart := testCmd{
4545
command: "sh",
4646
args: []string{"test/utils/check_driver_pods_restart.sh"},

0 commit comments

Comments
 (0)