Skip to content

Commit e1f2a24

Browse files
authored
Merge pull request #765 from Zhupku/mengzezhu/upgrade-golint-version
chore: upgrade golint version
2 parents 5c22dcc + 8dbf16b commit e1f2a24

File tree

9 files changed

+30
-30
lines changed

9 files changed

+30
-30
lines changed

.github/workflows/static.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ 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 --timeout=30m0s
2020
verify-helm:
2121
name: Verify Helm

pkg/nfs/controllerserver.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
144144
if v != "" {
145145
var err error
146146
if mountPermissions, err = strconv.ParseUint(v, 8, 32); err != nil {
147-
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid mountPermissions %s in storage class", v))
147+
return nil, status.Errorf(codes.InvalidArgument, "invalid mountPermissions %s in storage class", v)
148148
}
149149
}
150150
default:
151-
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid parameter %q in storage class", k))
151+
return nil, status.Errorf(codes.InvalidArgument, "invalid parameter %q in storage class", k)
152152
}
153153
}
154154

@@ -168,24 +168,24 @@ func (cs *ControllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
168168
}
169169
// Mount nfs base share so we can create a subdirectory
170170
if err = cs.internalMount(ctx, nfsVol, parameters, volCap); err != nil {
171-
return nil, status.Errorf(codes.Internal, "failed to mount nfs server: %v", err.Error())
171+
return nil, status.Errorf(codes.Internal, "failed to mount nfs server: %v", err)
172172
}
173173
defer func() {
174174
if err = cs.internalUnmount(ctx, nfsVol); err != nil {
175-
klog.Warningf("failed to unmount nfs server: %v", err.Error())
175+
klog.Warningf("failed to unmount nfs server: %v", err)
176176
}
177177
}()
178178

179179
// Create subdirectory under base-dir
180180
internalVolumePath := getInternalVolumePath(cs.Driver.workingMountDir, nfsVol)
181181
if err = os.MkdirAll(internalVolumePath, 0777); err != nil {
182-
return nil, status.Errorf(codes.Internal, "failed to make subdirectory: %v", err.Error())
182+
return nil, status.Errorf(codes.Internal, "failed to make subdirectory: %v", err)
183183
}
184184

185185
if mountPermissions > 0 {
186186
// Reset directory permissions because of umask problems
187187
if err = os.Chmod(internalVolumePath, os.FileMode(mountPermissions)); err != nil {
188-
klog.Warningf("failed to chmod subdirectory: %v", err.Error())
188+
klog.Warningf("failed to chmod subdirectory: %v", err)
189189
}
190190
}
191191

@@ -245,19 +245,19 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
245245
// check whether volumeID is in the cache
246246
cache, err := cs.Driver.volDeletionCache.Get(volumeID, azcache.CacheReadTypeDefault)
247247
if err != nil {
248-
return nil, status.Errorf(codes.Internal, err.Error())
248+
return nil, status.Errorf(codes.Internal, "%v", err)
249249
}
250250
if cache != nil {
251251
klog.V(2).Infof("DeleteVolume: volume %s is already deleted", volumeID)
252252
return &csi.DeleteVolumeResponse{}, nil
253253
}
254254
// mount nfs base share so we can delete the subdirectory
255255
if err = cs.internalMount(ctx, nfsVol, nil, volCap); err != nil {
256-
return nil, status.Errorf(codes.Internal, "failed to mount nfs server: %v", err.Error())
256+
return nil, status.Errorf(codes.Internal, "failed to mount nfs server: %v", err)
257257
}
258258
defer func() {
259259
if err = cs.internalUnmount(ctx, nfsVol); err != nil {
260-
klog.Warningf("failed to unmount nfs server: %v", err.Error())
260+
klog.Warningf("failed to unmount nfs server: %v", err)
261261
}
262262
}()
263263

@@ -269,7 +269,7 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
269269
parentDir := filepath.Dir(archivedInternalVolumePath)
270270
klog.V(2).Infof("DeleteVolume: subdirectory(%s) contains '/', make sure the parent directory(%s) exists", nfsVol.subDir, parentDir)
271271
if err = os.MkdirAll(parentDir, 0777); err != nil {
272-
return nil, status.Errorf(codes.Internal, "create parent directory(%s) of %s failed with %v", parentDir, archivedInternalVolumePath, err.Error())
272+
return nil, status.Errorf(codes.Internal, "create parent directory(%s) of %s failed with %v", parentDir, archivedInternalVolumePath, err)
273273
}
274274
}
275275

@@ -278,12 +278,12 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
278278
if cs.Driver.removeArchivedVolumePath {
279279
klog.V(2).Infof("removing archived subdirectory at %v", archivedInternalVolumePath)
280280
if err = os.RemoveAll(archivedInternalVolumePath); err != nil {
281-
return nil, status.Errorf(codes.Internal, "failed to delete archived subdirectory %s: %v", archivedInternalVolumePath, err.Error())
281+
return nil, status.Errorf(codes.Internal, "failed to delete archived subdirectory %s: %v", archivedInternalVolumePath, err)
282282
}
283283
klog.V(2).Infof("removed archived subdirectory at %v", archivedInternalVolumePath)
284284
}
285285
if err = os.Rename(internalVolumePath, archivedInternalVolumePath); err != nil {
286-
return nil, status.Errorf(codes.Internal, "archive subdirectory(%s, %s) failed with %v", internalVolumePath, archivedInternalVolumePath, err.Error())
286+
return nil, status.Errorf(codes.Internal, "archive subdirectory(%s, %s) failed with %v", internalVolumePath, archivedInternalVolumePath, err)
287287
}
288288
// make sure internalVolumePath does not exist with 1 minute timeout
289289
if err = waitForPathNotExistWithTimeout(internalVolumePath, time.Minute); err != nil {
@@ -294,7 +294,7 @@ func (cs *ControllerServer) DeleteVolume(ctx context.Context, req *csi.DeleteVol
294294
// delete subdirectory under base-dir
295295
klog.V(2).Infof("removing subdirectory at %v", internalVolumePath)
296296
if err = os.RemoveAll(internalVolumePath); err != nil {
297-
return nil, status.Errorf(codes.Internal, "delete subdirectory(%s) failed with %v", internalVolumePath, err.Error())
297+
return nil, status.Errorf(codes.Internal, "delete subdirectory(%s) failed with %v", internalVolumePath, err)
298298
}
299299
}
300300
} else {
@@ -455,7 +455,7 @@ func (cs *ControllerServer) DeleteSnapshot(ctx context.Context, req *csi.DeleteS
455455
internalVolumePath := getInternalVolumePath(cs.Driver.workingMountDir, vol)
456456
klog.V(2).Infof("Removing snapshot archive at %v", internalVolumePath)
457457
if err = os.RemoveAll(internalVolumePath); err != nil {
458-
return nil, status.Errorf(codes.Internal, "failed to delete subdirectory: %v", err.Error())
458+
return nil, status.Errorf(codes.Internal, "failed to delete subdirectory: %v", err)
459459
}
460460

461461
return &csi.DeleteSnapshotResponse{}, nil
@@ -620,7 +620,7 @@ func newNFSSnapshot(name string, params map[string]string, vol *nfsVolume) (*nfs
620620
case paramShare:
621621
baseDir = v
622622
default:
623-
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid parameter %q in snapshot storage class", k))
623+
return nil, status.Errorf(codes.InvalidArgument, "invalid parameter %q in snapshot storage class", k)
624624
}
625625
}
626626

pkg/nfs/nfs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func NewDriver(options *DriverOptions) *Driver {
117117
}
118118

119119
var err error
120-
getter := func(key string) (interface{}, error) { return nil, nil }
120+
getter := func(_ string) (interface{}, error) { return nil, nil }
121121
if n.volStatsCache, err = azcache.NewTimedCache(time.Duration(options.VolStatsCacheExpireInMinutes)*time.Minute, getter, false); err != nil {
122122
klog.Fatalf("%v", err)
123123
}

pkg/nfs/nfs_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func NewEmptyDriver(emptyField string) *Driver {
5454
}
5555
}
5656
d.volumeLocks = NewVolumeLocks()
57-
getter := func(key string) (interface{}, error) { return nil, nil }
57+
getter := func(_ string) (interface{}, error) { return nil, nil }
5858
d.volStatsCache, _ = azcache.NewTimedCache(time.Minute, getter, false)
5959
return d
6060
}
@@ -109,15 +109,15 @@ func TestRun(t *testing.T) {
109109
}{
110110
{
111111
name: "Successful run",
112-
testFunc: func(t *testing.T) {
112+
testFunc: func(_ *testing.T) {
113113
d := NewEmptyDriver("")
114114
d.endpoint = "tcp://127.0.0.1:0"
115115
d.Run(true)
116116
},
117117
},
118118
{
119119
name: "Successful run with node ID missing",
120-
testFunc: func(t *testing.T) {
120+
testFunc: func(_ *testing.T) {
121121
d := NewEmptyDriver("")
122122
d.endpoint = "tcp://127.0.0.1:0"
123123
d.nodeID = ""

pkg/nfs/nodeserver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func (ns *NodeServer) NodePublishVolume(_ context.Context, req *csi.NodePublishV
9292
if v != "" {
9393
var err error
9494
if mountPermissions, err = strconv.ParseUint(v, 8, 32); err != nil {
95-
return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid mountPermissions %s", v))
95+
return nil, status.Errorf(codes.InvalidArgument, "invalid mountPermissions %s", v)
9696
}
9797
}
9898
}
@@ -213,7 +213,7 @@ func (ns *NodeServer) NodeGetVolumeStats(_ context.Context, req *csi.NodeGetVolu
213213
// check if the volume stats is cached
214214
cache, err := ns.Driver.volStatsCache.Get(req.VolumeId, azcache.CacheReadTypeDefault)
215215
if err != nil {
216-
return nil, status.Errorf(codes.Internal, err.Error())
216+
return nil, status.Errorf(codes.Internal, "%v", err)
217217
}
218218
if cache != nil {
219219
resp := cache.(csi.NodeGetVolumeStatsResponse)

pkg/nfs/nodeserver_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const (
3939
func TestNodePublishVolume(t *testing.T) {
4040
ns, err := getTestNodeServer()
4141
if err != nil {
42-
t.Fatalf(err.Error())
42+
t.Fatalf("%v", err.Error())
4343
}
4444

4545
params := map[string]string{
@@ -208,7 +208,7 @@ func TestNodePublishVolume(t *testing.T) {
208208
func TestNodeUnpublishVolume(t *testing.T) {
209209
ns, err := getTestNodeServer()
210210
if err != nil {
211-
t.Fatalf(err.Error())
211+
t.Fatalf("%v", err.Error())
212212
}
213213

214214
errorTarget := testutil.GetWorkDirPath("error_is_likely_target", t)
@@ -276,7 +276,7 @@ func TestNodeUnpublishVolume(t *testing.T) {
276276
func TestNodeGetInfo(t *testing.T) {
277277
ns, err := getTestNodeServer()
278278
if err != nil {
279-
t.Fatalf(err.Error())
279+
t.Fatalf("%v", err.Error())
280280
}
281281

282282
// Test valid request
@@ -289,7 +289,7 @@ func TestNodeGetInfo(t *testing.T) {
289289
func TestNodeGetCapabilities(t *testing.T) {
290290
ns, err := getTestNodeServer()
291291
if err != nil {
292-
t.Fatalf(err.Error())
292+
t.Fatalf("%v", err.Error())
293293
}
294294

295295
capType := &csi.NodeServiceCapability_Rpc{
@@ -358,7 +358,7 @@ func TestNodeGetVolumeStats(t *testing.T) {
358358
_ = makeDir(fakePath)
359359
ns, err := getTestNodeServer()
360360
if err != nil {
361-
t.Fatalf(err.Error())
361+
t.Fatalf("%v", err.Error())
362362
}
363363

364364
for _, test := range tests {

pkg/nfs/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (s *nonBlockingGRPCServer) serve(endpoint string, ids csi.IdentityServer, c
7878
if proto == "unix" {
7979
addr = "/" + addr
8080
if err := os.Remove(addr); err != nil && !os.IsNotExist(err) {
81-
klog.Fatalf("Failed to remove %s, error: %s", addr, err.Error())
81+
klog.Fatalf("Failed to remove %s, error: %v", addr, err)
8282
}
8383
}
8484

test/e2e/dynamic_provisioning_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() {
3838
testDriver driver.PVTestDriver
3939
)
4040

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

test/utils/testutil/testutil.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
func GetWorkDirPath(dir string, t *testing.T) string {
2727
path, err := os.Getwd()
2828
if err != nil {
29-
t.Fatalf("failed to get working directory: %s", err)
29+
t.Fatalf("failed to get working directory: %v", err)
3030
}
3131
return fmt.Sprintf("%s%c%s", path, os.PathSeparator, dir)
3232
}

0 commit comments

Comments
 (0)