diff --git a/.github/workflows/static.yaml b/.github/workflows/static.yaml index d88926adf8..b59c459821 100644 --- a/.github/workflows/static.yaml +++ b/.github/workflows/static.yaml @@ -15,5 +15,5 @@ jobs: - name: Run linter uses: golangci/golangci-lint-action@v6 with: - version: v1.54 + version: v1.60 args: -E=gofmt,unused,ineffassign,revive,misspell,exportloopref,asciicheck,bodyclose,depguard,dogsled,dupl,durationcheck,errname,forbidigo -D=staticcheck --timeout=30m0s diff --git a/pkg/azurefile/azurefile.go b/pkg/azurefile/azurefile.go index 0fd7a085ff..bf54615ace 100644 --- a/pkg/azurefile/azurefile.go +++ b/pkg/azurefile/azurefile.go @@ -310,7 +310,7 @@ func NewDriver(options *DriverOptions) *Driver { driver.endpoint = options.Endpoint var err error - getter := func(key string) (interface{}, error) { return nil, nil } + getter := func(_ string) (interface{}, error) { return nil, nil } if driver.secretCacheMap, err = azcache.NewTimedCache(time.Minute, getter, false); err != nil { klog.Fatalf("%v", err) diff --git a/pkg/azurefile/azurefile_options_test.go b/pkg/azurefile/azurefile_options_test.go index 42425d737d..04415c97c2 100644 --- a/pkg/azurefile/azurefile_options_test.go +++ b/pkg/azurefile/azurefile_options_test.go @@ -28,7 +28,7 @@ func TestDriverOptions_AddFlags(t *testing.T) { got := o.AddFlags() count := 0 - got.VisitAll(func(f *flag.Flag) { + got.VisitAll(func(_ *flag.Flag) { count++ }) if count != typeInfo.NumField() { diff --git a/pkg/azurefile/controllerserver.go b/pkg/azurefile/controllerserver.go index 00b14c6219..328107285b 100644 --- a/pkg/azurefile/controllerserver.go +++ b/pkg/azurefile/controllerserver.go @@ -174,7 +174,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) case selectRandomMatchingAccountField: value, err := strconv.ParseBool(v) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid %s: %s in storage class", selectRandomMatchingAccountField, v)) + return nil, status.Errorf(codes.InvalidArgument, "invalid %s: %s in storage class", selectRandomMatchingAccountField, v) } selectRandomMatchingAccount = value case secretNameField: @@ -194,7 +194,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) case enableLargeFileSharesField: value, err := strconv.ParseBool(v) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid %s: %s in storage class", enableLargeFileSharesField, v)) + return nil, status.Errorf(codes.InvalidArgument, "invalid %s: %s in storage class", enableLargeFileSharesField, v) } enableLFS = &value case useDataPlaneAPIField: @@ -202,7 +202,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) case disableDeleteRetentionPolicyField: value, err := strconv.ParseBool(v) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid %s: %s in storage class", disableDeleteRetentionPolicyField, v)) + return nil, status.Errorf(codes.InvalidArgument, "invalid %s: %s in storage class", disableDeleteRetentionPolicyField, v) } disableDeleteRetentionPolicy = &value case pvcNamespaceKey: @@ -223,13 +223,13 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) case allowBlobPublicAccessField: value, err := strconv.ParseBool(v) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid %s: %s in storage class", allowBlobPublicAccessField, v)) + return nil, status.Errorf(codes.InvalidArgument, "invalid %s: %s in storage class", allowBlobPublicAccessField, v) } allowBlobPublicAccess = &value case allowSharedKeyAccessField: value, err := strconv.ParseBool(v) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid %s: %s in storage class", allowSharedKeyAccessField, v)) + return nil, status.Errorf(codes.InvalidArgument, "invalid %s: %s in storage class", allowSharedKeyAccessField, v) } allowSharedKeyAccess = &value case pvcNameKey: @@ -245,7 +245,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) case mountPermissionsField: // only do validations here, used in NodeStageVolume, NodePublishVolume if _, err := strconv.ParseUint(v, 8, 32); err != nil { - return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid mountPermissions %s in storage class", v)) + return nil, status.Errorf(codes.InvalidArgument, "invalid mountPermissions %s in storage class", v) } case vnetResourceGroupField: vnetResourceGroup = v @@ -258,41 +258,41 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) case requireInfraEncryptionField: value, err := strconv.ParseBool(v) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid %s: %s in storage class", requireInfraEncryptionField, v)) + return nil, status.Errorf(codes.InvalidArgument, "invalid %s: %s in storage class", requireInfraEncryptionField, v) } requireInfraEncryption = &value case enableMultichannelField: value, err := strconv.ParseBool(v) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid %s: %s in storage class", enableMultichannelField, v)) + return nil, status.Errorf(codes.InvalidArgument, "invalid %s: %s in storage class", enableMultichannelField, v) } isMultichannelEnabled = &value case getLatestAccountKeyField: value, err := strconv.ParseBool(v) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid %s: %s in storage class", getLatestAccountKeyField, v)) + return nil, status.Errorf(codes.InvalidArgument, "invalid %s: %s in storage class", getLatestAccountKeyField, v) } getLatestAccountKey = value case accountQuotaField: value, err := strconv.ParseInt(v, 10, 32) if err != nil || value < minimumAccountQuota { - return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid accountQuota %s in storage class, minimum quota: %d", v, minimumAccountQuota)) + return nil, status.Errorf(codes.InvalidArgument, "invalid accountQuota %s in storage class, minimum quota: %d", v, minimumAccountQuota) } accountQuota = int32(value) case tagValueDelimiterField: tagValueDelimiter = v default: - return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid parameter %q in storage class", k)) + return nil, status.Errorf(codes.InvalidArgument, "invalid parameter %q in storage class", k) } } if matchTags && account != "" { - return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("matchTags must set as false when storageAccount(%s) is provided", account)) + return nil, status.Errorf(codes.InvalidArgument, "matchTags must set as false when storageAccount(%s) is provided", account) } if subsID != "" && subsID != d.cloud.SubscriptionID { if resourceGroup == "" { - return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("resourceGroup must be provided in cross subscription(%s)", subsID)) + return nil, status.Errorf(codes.InvalidArgument, "resourceGroup must be provided in cross subscription(%s)", subsID) } } @@ -433,7 +433,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) tags, err := ConvertTagsToMap(customTags, tagValueDelimiter) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, err.Error()) + return nil, status.Errorf(codes.InvalidArgument, "%v", err) } if strings.TrimSpace(storageEndpointSuffix) == "" { @@ -497,7 +497,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) // search in cache first cache, err := d.accountSearchCache.Get(lockKey, azcache.CacheReadTypeDefault) if err != nil { - return nil, status.Errorf(codes.Internal, err.Error()) + return nil, status.Errorf(codes.Internal, "%v", err) } if cache != nil { accountName = cache.(string) @@ -553,7 +553,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) // skip validating file share quota if useDataPlaneAPI } else { if quota, err := d.getFileShareQuota(ctx, subsID, resourceGroup, accountName, validFileShareName, secret); err != nil { - return nil, status.Errorf(codes.Internal, err.Error()) + return nil, status.Errorf(codes.Internal, "%v", err) } else if quota != -1 && quota < fileShareSize { return nil, status.Errorf(codes.AlreadyExists, "request file share(%s) already exists, but its capacity %d is smaller than %d", validFileShareName, quota, fileShareSize) } @@ -581,7 +581,7 @@ func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) d.volumeLocks.Release(volName) // clean search cache if err := d.accountSearchCache.Delete(lockKey); err != nil { - return nil, status.Errorf(codes.Internal, err.Error()) + return nil, status.Errorf(codes.Internal, "%v", err) } // remove the volName from the volMap to stop matching the same storage account d.volMap.Delete(volName) @@ -857,7 +857,7 @@ func (d *Driver) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequ case useDataPlaneAPIField: useDataPlaneAPI = strings.EqualFold(v, trueValue) default: - return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid parameter %q in storage class", k)) + return nil, status.Errorf(codes.InvalidArgument, "invalid parameter %q in storage class", k) } } @@ -1358,7 +1358,7 @@ func (d *Driver) authorizeAzcopyWithIdentity() ([]string, error) { authAzcopyEnv = append(authAzcopyEnv, fmt.Sprintf("%s=%s", azcopySPAApplicationID, azureAuthConfig.AADClientID)) authAzcopyEnv = append(authAzcopyEnv, fmt.Sprintf("%s=%s", azcopySPAClientSecret, azureAuthConfig.AADClientSecret)) authAzcopyEnv = append(authAzcopyEnv, fmt.Sprintf("%s=%s", azcopyTenantID, azureAuthConfig.TenantID)) - klog.V(2).Infof(fmt.Sprintf("set AZCOPY_SPA_APPLICATION_ID=%s, AZCOPY_TENANT_ID=%s successfully", azureAuthConfig.AADClientID, azureAuthConfig.TenantID)) + klog.V(2).Infof("set AZCOPY_SPA_APPLICATION_ID=%s, AZCOPY_TENANT_ID=%s successfully", azureAuthConfig.AADClientID, azureAuthConfig.TenantID) return authAzcopyEnv, nil } @@ -1411,13 +1411,13 @@ func (d *Driver) generateSASToken(accountName, accountKey, storageEndpointSuffix credential, err := service.NewSharedKeyCredential(accountName, accountKey) if err != nil { - return "", status.Errorf(codes.Internal, fmt.Sprintf("failed to generate sas token in creating new shared key credential, accountName: %s, err: %s", accountName, err.Error())) + return "", status.Errorf(codes.Internal, "failed to generate sas token in creating new shared key credential, accountName: %s, err: %s", accountName, err.Error()) } clientOptions := service.ClientOptions{} clientOptions.InsecureAllowCredentialWithHTTP = true serviceClient, err := service.NewClientWithSharedKeyCredential(fmt.Sprintf("https://%s.file.%s/", accountName, storageEndpointSuffix), credential, &clientOptions) if err != nil { - return "", status.Errorf(codes.Internal, fmt.Sprintf("failed to generate sas token in creating new client with shared key credential, accountName: %s, err: %s", accountName, err.Error())) + return "", status.Errorf(codes.Internal, "failed to generate sas token in creating new client with shared key credential, accountName: %s, err: %s", accountName, err.Error()) } nowTime := time.Now() sasURL, err := serviceClient.GetSASURL( diff --git a/pkg/azurefile/controllerserver_test.go b/pkg/azurefile/controllerserver_test.go index 471feee489..e13f01516e 100644 --- a/pkg/azurefile/controllerserver_test.go +++ b/pkg/azurefile/controllerserver_test.go @@ -396,7 +396,7 @@ func TestCreateVolume(t *testing.T) { d := NewFakeDriver() - expectedErr := status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid accountQuota %d in storage class, minimum quota: %d", 10, minimumAccountQuota)) + expectedErr := status.Errorf(codes.InvalidArgument, "invalid accountQuota %d in storage class, minimum quota: %d", 10, minimumAccountQuota) _, err := d.CreateVolume(ctx, req) if !reflect.DeepEqual(err, expectedErr) { t.Errorf("Unexpected error: %v", err) @@ -428,7 +428,7 @@ func TestCreateVolume(t *testing.T) { d := NewFakeDriver() - expectedErr := status.Errorf(codes.InvalidArgument, fmt.Errorf("Tags 'tags' are invalid, the format should like: 'key1=value1,key2=value2'").Error()) + expectedErr := status.Errorf(codes.InvalidArgument, "Tags 'tags' are invalid, the format should like: 'key1=value1,key2=value2'") _, err := d.CreateVolume(ctx, req) if !reflect.DeepEqual(err, expectedErr) { t.Errorf("Unexpected error: %v", err) @@ -1235,7 +1235,7 @@ func TestCreateVolume(t *testing.T) { mockStorageAccountsClient.EXPECT().Create(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() mockFileClient.EXPECT().GetFileShare(context.TODO(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(storage.FileShare{FileShareProperties: &storage.FileShareProperties{ShareQuota: &fakeShareQuota}}, nil).AnyTimes() - expectedErr := status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid %s %s in storage class", "mountPermissions", "0abc")) + expectedErr := status.Errorf(codes.InvalidArgument, "invalid %s %s in storage class", "mountPermissions", "0abc") _, err := d.CreateVolume(ctx, req) if !reflect.DeepEqual(err, expectedErr) { t.Errorf("Unexpected error: %v", err) @@ -1290,7 +1290,7 @@ func TestCreateVolume(t *testing.T) { mockStorageAccountsClient.EXPECT().Create(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes() mockFileClient.EXPECT().GetFileShare(context.TODO(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(storage.FileShare{FileShareProperties: &storage.FileShareProperties{ShareQuota: &fakeShareQuota}}, nil).AnyTimes() - expectedErr := status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid parameter %q in storage class", "invalidparameter")) + expectedErr := status.Errorf(codes.InvalidArgument, "invalid parameter %q in storage class", "invalidparameter") _, err := d.CreateVolume(ctx, req) if !reflect.DeepEqual(err, expectedErr) { t.Errorf("Unexpected error: %v", err) @@ -1625,7 +1625,7 @@ func TestDeleteVolume(t *testing.T) { }, }, } - d.dataPlaneAPIAccountCache, _ = azcache.NewTimedCache(10*time.Minute, func(key string) (interface{}, error) { return nil, nil }, false) + d.dataPlaneAPIAccountCache, _ = azcache.NewTimedCache(10*time.Minute, func(_ string) (interface{}, error) { return nil, nil }, false) d.dataPlaneAPIAccountCache.Set("f5713de20cde511e8ba4900", "1") d.cloud = &azure.Cloud{} @@ -2426,7 +2426,7 @@ func TestControllerExpandVolume(t *testing.T) { ResourceGroup: "vol_2", }, } - d.dataPlaneAPIAccountCache, _ = azcache.NewTimedCache(10*time.Minute, func(key string) (interface{}, error) { return nil, nil }, false) + d.dataPlaneAPIAccountCache, _ = azcache.NewTimedCache(10*time.Minute, func(_ string) (interface{}, error) { return nil, nil }, false) d.dataPlaneAPIAccountCache.Set("f5713de20cde511e8ba4900", "1") ctrl := gomock.NewController(t) defer ctrl.Finish() @@ -2799,7 +2799,7 @@ func TestGenerateSASToken(t *testing.T) { accountName: "unit-test", accountKey: "fakeValue", want: "", - expectedErr: status.Errorf(codes.Internal, fmt.Sprintf("failed to generate sas token in creating new shared key credential, accountName: %s, err: %s", "unit-test", "decode account key: illegal base64 data at input byte 8")), + expectedErr: status.Errorf(codes.Internal, "failed to generate sas token in creating new shared key credential, accountName: %s, err: %s", "unit-test", "decode account key: illegal base64 data at input byte 8"), }, } for _, tt := range tests { @@ -2986,7 +2986,7 @@ func TestGetAzcopyAuth(t *testing.T) { ctx := context.Background() expectedAccountSASToken := "" - expectedErr := status.Errorf(codes.Internal, fmt.Sprintf("failed to generate sas token in creating new shared key credential, accountName: %s, err: %s", "accountName", "decode account key: illegal base64 data at input byte 8")) + expectedErr := status.Errorf(codes.Internal, "failed to generate sas token in creating new shared key credential, accountName: %s, err: %s", "accountName", "decode account key: illegal base64 data at input byte 8") accountSASToken, authAzcopyEnv, err := d.getAzcopyAuth(ctx, "accountName", "", "core.windows.net", &azure.AccountOptions{}, secrets, "secretsName", "secretsNamespace", false) if !reflect.DeepEqual(err, expectedErr) || authAzcopyEnv != nil || !reflect.DeepEqual(accountSASToken, expectedAccountSASToken) { t.Errorf("Unexpected accountSASToken: %s, Unexpected authAzcopyEnv: %v, Unexpected error: %v", accountSASToken, authAzcopyEnv, err) diff --git a/pkg/azurefile/nodeserver.go b/pkg/azurefile/nodeserver.go index bbeee2973c..36c44adc5c 100644 --- a/pkg/azurefile/nodeserver.go +++ b/pkg/azurefile/nodeserver.go @@ -92,7 +92,7 @@ func (d *Driver) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolu if perm := getValueInMap(context, mountPermissionsField); perm != "" { var err error if mountPermissions, err = strconv.ParseUint(perm, 8, 32); err != nil { - return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid mountPermissions %s", perm)) + return nil, status.Errorf(codes.InvalidArgument, "invalid mountPermissions %s", perm) } } } @@ -237,7 +237,7 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe var err error var perm uint64 if perm, err = strconv.ParseUint(v, 8, 32); err != nil { - return nil, status.Errorf(codes.InvalidArgument, fmt.Sprintf("invalid mountPermissions %s", v)) + return nil, status.Errorf(codes.InvalidArgument, "invalid mountPermissions %s", v) } if perm == 0 { performChmodOp = false @@ -472,7 +472,7 @@ func (d *Driver) NodeGetVolumeStats(_ context.Context, req *csi.NodeGetVolumeSta // check if the volume stats is cached cache, err := d.volStatsCache.Get(req.VolumeId, azcache.CacheReadTypeDefault) if err != nil { - return nil, status.Errorf(codes.Internal, err.Error()) + return nil, status.Errorf(codes.Internal, "%v", err) } if cache != nil { resp := cache.(csi.NodeGetVolumeStatsResponse) @@ -494,7 +494,7 @@ func (d *Driver) NodeGetVolumeStats(_ context.Context, req *csi.NodeGetVolumeSta } if cache, err = d.volStatsCache.Get(newVolID, azcache.CacheReadTypeDefault); err != nil { - return nil, status.Errorf(codes.Internal, err.Error()) + return nil, status.Errorf(codes.Internal, "%v", err) } if cache != nil { resp := cache.(csi.NodeGetVolumeStatsResponse) diff --git a/pkg/azurefile/nodeserver_test.go b/pkg/azurefile/nodeserver_test.go index c441101ab5..51fa6de733 100644 --- a/pkg/azurefile/nodeserver_test.go +++ b/pkg/azurefile/nodeserver_test.go @@ -166,8 +166,8 @@ func TestNodePublishVolume(t *testing.T) { StagingTargetPath: sourceTest, Readonly: true}, expectedErr: testutil.TestError{ - DefaultError: status.Errorf(codes.Internal, fmt.Sprintf("Could not mount target %s: mkdir %s: not a directory", azureFile, azureFile)), - WindowsError: status.Errorf(codes.Internal, fmt.Sprintf("Could not mount target %v: mkdir %s: The system cannot find the path specified.", azureFile, azureFile)), + DefaultError: status.Errorf(codes.Internal, "Could not mount target %s: mkdir %s: not a directory", azureFile, azureFile), + WindowsError: status.Errorf(codes.Internal, "Could not mount target %v: mkdir %s: The system cannot find the path specified.", azureFile, azureFile), }, }, { @@ -178,7 +178,7 @@ func TestNodePublishVolume(t *testing.T) { StagingTargetPath: errorMountSource, Readonly: true}, expectedErr: testutil.TestError{ - DefaultError: status.Errorf(codes.Internal, fmt.Sprintf("Could not mount %s at %s: fake Mount: source error", errorMountSource, targetTest)), + DefaultError: status.Errorf(codes.Internal, "Could not mount %s at %s: fake Mount: source error", errorMountSource, targetTest), }, }, { @@ -241,7 +241,7 @@ func TestNodePublishVolume(t *testing.T) { _ = makeDir(alreadyMountedTarget, 0755) mounter, err := NewFakeMounter() if err != nil { - t.Fatalf(fmt.Sprintf("failed to get fake mounter: %v", err)) + t.Fatalf("failed to get fake mounter: %v", err) } if runtime.GOOS != "windows" { mounter.Exec = &testingexec.FakeExec{ExactOrder: true} @@ -314,7 +314,7 @@ func TestNodeUnpublishVolume(t *testing.T) { _ = makeDir(errorTarget, 0755) mounter, err := NewFakeMounter() if err != nil { - t.Fatalf(fmt.Sprintf("failed to get fake mounter: %v", err)) + t.Fatalf("failed to get fake mounter: %v", err) } if runtime.GOOS != "windows" { mounter.Exec = &testingexec.FakeExec{ExactOrder: true} @@ -555,7 +555,7 @@ func TestNodeStageVolume(t *testing.T) { VolumeContext: volContextEmptyDiskName, Secrets: secrets}, expectedErr: testutil.TestError{ - DefaultError: status.Errorf(codes.Internal, fmt.Sprintf("diskname could not be empty, targetPath: %s", sourceTest)), + DefaultError: status.Errorf(codes.Internal, "diskname could not be empty, targetPath: %s", sourceTest), }, }, { @@ -596,7 +596,7 @@ func TestNodeStageVolume(t *testing.T) { "with smb mapping failed with error: rpc error: code = Unknown desc = NewSmbGlobalMapping failed.", errorSource, errorMountSensSource), expectedErr: testutil.TestError{ - DefaultError: status.Errorf(codes.Internal, fmt.Sprintf("volume(vol_1##) mount //test_servername/test_sharename on %v failed with fake MountSensitive: target error", errorMountSensSource)), + DefaultError: status.Errorf(codes.Internal, "volume(vol_1##) mount //test_servername/test_sharename on %v failed with fake MountSensitive: target error", errorMountSensSource), }, }, { @@ -716,7 +716,7 @@ func TestNodeStageVolume(t *testing.T) { } mounter, err := NewFakeMounter() if err != nil { - t.Fatalf(fmt.Sprintf("failed to get fake mounter: %v", err)) + t.Fatalf("failed to get fake mounter: %v", err) } if runtime.GOOS != "windows" { @@ -822,7 +822,7 @@ func TestNodeUnstageVolume(t *testing.T) { _ = makeDir(errorTarget, 0755) mounter, err := NewFakeMounter() if err != nil { - t.Fatalf(fmt.Sprintf("failed to get fake mounter: %v", err)) + t.Fatalf("failed to get fake mounter: %v", err) } if runtime.GOOS != "windows" { mounter.Exec = &testingexec.FakeExec{ExactOrder: true} @@ -1066,9 +1066,8 @@ func TestNodePublishVolumeIdempotentMount(t *testing.T) { func makeFakeCmd(fakeCmd *testingexec.FakeCmd, cmd string, args ...string) testingexec.FakeCommandAction { c := cmd a := args - return func(cmd string, args ...string) exec.Cmd { - command := testingexec.InitFakeCmd(fakeCmd, c, a...) - return command + return func(_ string, _ ...string) exec.Cmd { + return testingexec.InitFakeCmd(fakeCmd, c, a...) } } diff --git a/pkg/csi-common/utils_test.go b/pkg/csi-common/utils_test.go index 7ab9c7c2c0..94c8601d19 100644 --- a/pkg/csi-common/utils_test.go +++ b/pkg/csi-common/utils_test.go @@ -98,7 +98,7 @@ func TestLogGRPC(t *testing.T) { buf := new(bytes.Buffer) klog.SetOutput(buf) - handler := func(ctx context.Context, req interface{}) (interface{}, error) { return nil, nil } + handler := func(_ context.Context, _ interface{}) (interface{}, error) { return nil, nil } info := grpc.UnaryServerInfo{ FullMethod: "fake", } diff --git a/test/e2e/dynamic_provisioning_test.go b/test/e2e/dynamic_provisioning_test.go index eebf84ac99..235b9b2823 100644 --- a/test/e2e/dynamic_provisioning_test.go +++ b/test/e2e/dynamic_provisioning_test.go @@ -50,7 +50,7 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() { testDriver driver.PVTestDriver ) - ginkgo.BeforeEach(func(ctx ginkgo.SpecContext) { + ginkgo.BeforeEach(func(_ ginkgo.SpecContext) { checkPodsRestart := testCmd{ command: "bash", args: []string{"test/utils/check_driver_pods_restart.sh"}, diff --git a/test/e2e/pre_provisioning_test.go b/test/e2e/pre_provisioning_test.go index 7a4d641d01..21f32a70d7 100644 --- a/test/e2e/pre_provisioning_test.go +++ b/test/e2e/pre_provisioning_test.go @@ -49,7 +49,7 @@ var _ = ginkgo.Describe("Pre-Provisioned", func() { skipManuallyDeletingVolume bool ) - ginkgo.BeforeEach(func(ctx ginkgo.SpecContext) { + ginkgo.BeforeEach(func(_ ginkgo.SpecContext) { checkPodsRestart := testCmd{ command: "bash", args: []string{"test/utils/check_driver_pods_restart.sh"},