diff --git a/golangci.yaml b/golangci.yaml index 97ee4229da..358c5834f3 100644 --- a/golangci.yaml +++ b/golangci.yaml @@ -19,24 +19,12 @@ run: # "/" will be replaced by current OS file path separator to properly work # on Windows. skip-dirs: - - test/* - pkg/plugin/generated/* - # - autogenerated_by_my_lib # default is true. Enables skipping of directories: # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ skip-dirs-use-default: true - # which files to skip: they will be analyzed, but issues from them - # won't be reported. Default value is empty list, but there is - # no need to include all autogenerated files, we confidently recognize - # autogenerated files. If it's not please let us know. - # "/" will be replaced by current OS file path separator to properly work - # on Windows. - skip-files: - - ".*_test.go$" - # - lib/bad.go - # by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules": # If invoked with -mod=readonly, the go command is disallowed from the implicit # automatic updating of go.mod described above. Instead, it fails when any changes @@ -364,6 +352,35 @@ issues: - linters: - staticcheck text: "DefaultVolumesToRestic" # No need to report deprecate for DefaultVolumesToRestic. + - path: ".*_test.go$" + linters: + - dupword + - errcheck + - ginkgolinter + - goconst + - gosec + - govet + - staticcheck + - stylecheck + - unconvert + - unparam + - unused + - path: test/ + linters: + - bodyclose + - dupword + - errcheck + - goconst + - gosec + - gosimple + - ginkgolinter + - nilerr + - noctx + - staticcheck + - stylecheck + - unconvert + - unparam + - unused # The list of ids of default excludes to include or disable. By default it's empty. include: diff --git a/internal/hook/hook_tracker_test.go b/internal/hook/hook_tracker_test.go index 9e6ca95d33..dde7b85210 100644 --- a/internal/hook/hook_tracker_test.go +++ b/internal/hook/hook_tracker_test.go @@ -67,7 +67,6 @@ func TestHookTracker_Record(t *testing.T) { err = tracker.Record("ns2", "pod2", "container1", HookSourceAnnotation, "h1", PhasePre, true) assert.NotNil(t, err) - } func TestHookTracker_Stat(t *testing.T) { diff --git a/internal/hook/item_hook_handler_test.go b/internal/hook/item_hook_handler_test.go index 8b73572b64..6ab9b1528f 100644 --- a/internal/hook/item_hook_handler_test.go +++ b/internal/hook/item_hook_handler_test.go @@ -2351,14 +2351,12 @@ func TestBackupHookTracker(t *testing.T) { } } h.HandleHooks(velerotest.NewLogger(), groupResource, pod.item, pod.hooks, test.phase, hookTracker) - } actualAtemptted, actualFailed := hookTracker.Stat() assert.Equal(t, test.expectedHookAttempted, actualAtemptted) assert.Equal(t, test.expectedHookFailed, actualFailed) }) } - } func TestRestoreHookTrackerAdd(t *testing.T) { diff --git a/internal/hook/wait_exec_hook_handler_test.go b/internal/hook/wait_exec_hook_handler_test.go index 3f23542744..2f8d7ad7ac 100644 --- a/internal/hook/wait_exec_hook_handler_test.go +++ b/internal/hook/wait_exec_hook_handler_test.go @@ -710,7 +710,6 @@ func TestWaitExecHandleHooks(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - source := fcache.NewFakeControllerSource() go func() { // This is the state of the pod that will be seen by the AddFunc handler. @@ -1251,7 +1250,6 @@ func TestRestoreHookTrackerUpdate(t *testing.T) { for _, test := range tests1 { t.Run(test.name, func(t *testing.T) { - source := fcache.NewFakeControllerSource() go func() { // This is the state of the pod that will be seen by the AddFunc handler. diff --git a/internal/resourcemodifiers/resource_modifiers_test.go b/internal/resourcemodifiers/resource_modifiers_test.go index 648d827be9..8b4384ef1e 100644 --- a/internal/resourcemodifiers/resource_modifiers_test.go +++ b/internal/resourcemodifiers/resource_modifiers_test.go @@ -428,7 +428,6 @@ func TestGetResourceModifiersFromConfig(t *testing.T) { } func TestResourceModifiers_ApplyResourceModifierRules(t *testing.T) { - pvcStandardSc := &unstructured.Unstructured{ Object: map[string]interface{}{ "apiVersion": "v1", diff --git a/internal/resourcepolicies/volume_resources_test.go b/internal/resourcepolicies/volume_resources_test.go index c73bb692d8..f852baff3b 100644 --- a/internal/resourcepolicies/volume_resources_test.go +++ b/internal/resourcepolicies/volume_resources_test.go @@ -86,7 +86,6 @@ func TestCapacityIsInRange(t *testing.T) { actual := test.capacity.isInRange(test.quantity) assert.Equal(t, test.isInRange, actual) - }) } } @@ -141,7 +140,6 @@ func TestStorageClassConditionMatch(t *testing.T) { } func TestNFSConditionMatch(t *testing.T) { - tests := []struct { name string condition *nfsCondition @@ -196,7 +194,6 @@ func TestNFSConditionMatch(t *testing.T) { } func TestCSIConditionMatch(t *testing.T) { - tests := []struct { name string condition *csiCondition diff --git a/internal/velero/images_test.go b/internal/velero/images_test.go index 7d6bdf8cd9..ad73452930 100644 --- a/internal/velero/images_test.go +++ b/internal/velero/images_test.go @@ -128,7 +128,6 @@ func testDefaultImage(t *testing.T, defaultImageFn func() string, imageName stri assert.Equal(t, tc.want, defaultImageFn()) }) } - } func TestDefaultVeleroImage(t *testing.T) { diff --git a/pkg/backup/backup_test.go b/pkg/backup/backup_test.go index 32270c8cf9..0ceb0572a6 100644 --- a/pkg/backup/backup_test.go +++ b/pkg/backup/backup_test.go @@ -154,8 +154,8 @@ func TestBackupProgressIsUpdated(t *testing.T) { h.backupper.Backup(h.log, req, backupFile, nil, nil) require.NotNil(t, req.Status.Progress) - assert.Equal(t, len(req.BackedUpItems), req.Status.Progress.TotalItems) - assert.Equal(t, len(req.BackedUpItems), req.Status.Progress.ItemsBackedUp) + assert.Len(t, req.BackedUpItems, req.Status.Progress.TotalItems) + assert.Len(t, req.BackedUpItems, req.Status.Progress.ItemsBackedUp) } // TestBackupResourceFiltering runs backups with different combinations diff --git a/pkg/backup/item_collector_test.go b/pkg/backup/item_collector_test.go index f44743dfb5..467ce96a75 100644 --- a/pkg/backup/item_collector_test.go +++ b/pkg/backup/item_collector_test.go @@ -76,5 +76,4 @@ func TestSortOrderedResource(t *testing.T) { } sortedPvResources := sortResourcesByOrder(log, pvResources, pvOrder) assert.Equal(t, sortedPvResources, expectedPvResources) - } diff --git a/pkg/backup/remap_crd_version_action_test.go b/pkg/backup/remap_crd_version_action_test.go index bbcedd32b9..b50f82de4b 100644 --- a/pkg/backup/remap_crd_version_action_test.go +++ b/pkg/backup/remap_crd_version_action_test.go @@ -136,7 +136,6 @@ func TestRemapCRDVersionAction(t *testing.T) { // set it back to the default one a.discoveryHelper = fakeDiscoveryHelper() }) - } // TestRemapCRDVersionActionData tests the RemapCRDVersionAction plugin against actual CRD to confirm that the v1beta1 version is returned when the v1 version is passed in to the plugin. @@ -217,7 +216,6 @@ func TestRemapCRDVersionActionData(t *testing.T) { betaClient.Delete(context.TODO(), crd.Name, metav1.DeleteOptions{}) }) } - } func fakeDiscoveryHelper() velerodiscovery.Helper { diff --git a/pkg/backup/service_account_action_test.go b/pkg/backup/service_account_action_test.go index b17b9748cb..9bb813d6d5 100644 --- a/pkg/backup/service_account_action_test.go +++ b/pkg/backup/service_account_action_test.go @@ -400,7 +400,6 @@ func TestServiceAccountActionExecute(t *testing.T) { assert.Equal(t, test.expectedAdditionalItems, additional) }) } - } func TestServiceAccountActionExecuteOnBeta1(t *testing.T) { @@ -608,5 +607,4 @@ func TestServiceAccountActionExecuteOnBeta1(t *testing.T) { assert.Equal(t, test.expectedAdditionalItems, additional) }) } - } diff --git a/pkg/buildinfo/buildinfo_test.go b/pkg/buildinfo/buildinfo_test.go index 40631525a1..be12bdcab6 100644 --- a/pkg/buildinfo/buildinfo_test.go +++ b/pkg/buildinfo/buildinfo_test.go @@ -49,5 +49,4 @@ func TestFormattedGitSHA(t *testing.T) { assert.Equal(t, FormattedGitSHA(), test.expected) }) } - } diff --git a/pkg/client/config_test.go b/pkg/client/config_test.go index 56b198f793..b8e593d216 100644 --- a/pkg/client/config_test.go +++ b/pkg/client/config_test.go @@ -48,7 +48,6 @@ func removeConfigfileName() error { return nil } func TestConfigOperations(t *testing.T) { - preHomeEnv := "" prevEnv := os.Environ() for _, entry := range prevEnv { diff --git a/pkg/cmd/cli/backup/create_test.go b/pkg/cmd/cli/backup/create_test.go index e115bbd199..084d67becb 100644 --- a/pkg/cmd/cli/backup/create_test.go +++ b/pkg/cmd/cli/backup/create_test.go @@ -148,7 +148,6 @@ func TestCreateOptions_OrderedResources(t *testing.T) { "persistentvolumes": "pv1,pv2", } assert.Equal(t, orderedResources, expectedMixedResources) - } func TestCreateCommand(t *testing.T) { @@ -156,7 +155,6 @@ func TestCreateCommand(t *testing.T) { args := []string{name} t.Run("create a backup create command with full options except fromSchedule and wait, then run by create option", func(t *testing.T) { - // create a factory f := &factorymocks.Factory{} diff --git a/pkg/cmd/cli/backup/get_test.go b/pkg/cmd/cli/backup/get_test.go index af37953522..628b92e627 100644 --- a/pkg/cmd/cli/backup/get_test.go +++ b/pkg/cmd/cli/backup/get_test.go @@ -77,7 +77,7 @@ func TestNewGetCommand(t *testing.T) { i++ } } - assert.Equal(t, len(args), i) + assert.Len(t, args, i) } d := NewGetCommand(f, "velero backup get") @@ -98,6 +98,6 @@ func TestNewGetCommand(t *testing.T) { i++ } } - assert.Equal(t, len(args), i) + assert.Len(t, args, i) } } diff --git a/pkg/cmd/cli/backuplocation/delete_test.go b/pkg/cmd/cli/backuplocation/delete_test.go index 0ed5d3130b..2ebddca80a 100644 --- a/pkg/cmd/cli/backuplocation/delete_test.go +++ b/pkg/cmd/cli/backuplocation/delete_test.go @@ -35,7 +35,6 @@ import ( ) func TestNewDeleteCommand(t *testing.T) { - // create a factory f := &factorymocks.Factory{} kbclient := velerotest.NewFakeControllerRuntimeClient(t) @@ -75,7 +74,6 @@ func TestNewDeleteCommand(t *testing.T) { return } t.Fatalf("process ran with err %v, want backups by get()", err) - } func TestDeleteFunctions(t *testing.T) { //t.Run("create the other create command with fromSchedule option for Run() other branches", func(t *testing.T) { diff --git a/pkg/cmd/cli/restore/create_test.go b/pkg/cmd/cli/restore/create_test.go index 6a68018c47..4fbe7f3723 100644 --- a/pkg/cmd/cli/restore/create_test.go +++ b/pkg/cmd/cli/restore/create_test.go @@ -59,7 +59,6 @@ func TestCreateCommand(t *testing.T) { args := []string{name} t.Run("create a backup create command with full options except fromSchedule and wait, then run by create option", func(t *testing.T) { - // create a factory f := &factorymocks.Factory{} diff --git a/pkg/cmd/cli/restore/get_test.go b/pkg/cmd/cli/restore/get_test.go index 211550087b..fcb5a04c42 100644 --- a/pkg/cmd/cli/restore/get_test.go +++ b/pkg/cmd/cli/restore/get_test.go @@ -76,6 +76,6 @@ func TestNewGetCommand(t *testing.T) { i++ } } - require.Equal(t, len(args), i) + require.Len(t, args, i) } } diff --git a/pkg/cmd/util/flag/map_test.go b/pkg/cmd/util/flag/map_test.go index c0a1dee7ef..70a71fbb18 100644 --- a/pkg/cmd/util/flag/map_test.go +++ b/pkg/cmd/util/flag/map_test.go @@ -71,7 +71,6 @@ func TestSetOfMap(t *testing.T) { assert.EqualValues(t, c.expected, m.Data()) }) } - } func TestStringOfMap(t *testing.T) { diff --git a/pkg/cmd/util/output/backup_structured_describer_test.go b/pkg/cmd/util/output/backup_structured_describer_test.go index afddec0a2a..58a141cd9c 100644 --- a/pkg/cmd/util/output/backup_structured_describer_test.go +++ b/pkg/cmd/util/output/backup_structured_describer_test.go @@ -618,5 +618,4 @@ func TestDescribeDeleteBackupRequestsInSF(t *testing.T) { assert.True(tt, reflect.DeepEqual(sd.output, tc.expect)) }) } - } diff --git a/pkg/controller/backup_controller_test.go b/pkg/controller/backup_controller_test.go index 7dd3922996..37caf839e4 100644 --- a/pkg/controller/backup_controller_test.go +++ b/pkg/controller/backup_controller_test.go @@ -435,7 +435,6 @@ func TestDefaultBackupTTL(t *testing.T) { ) t.Run(test.name, func(t *testing.T) { - apiServer := velerotest.NewAPIServer(t) discoveryHelper, err := discovery.NewHelper(apiServer.DiscoveryClient, logger) require.NoError(t, err) @@ -1735,6 +1734,5 @@ func TestPatchResourceWorksWithStatus(t *testing.T) { t.Error(cmp.Diff(fromCluster, tt.args.updated)) } }) - } } diff --git a/pkg/controller/backup_deletion_controller_test.go b/pkg/controller/backup_deletion_controller_test.go index a524b1adf6..cc83c29f2e 100644 --- a/pkg/controller/backup_deletion_controller_test.go +++ b/pkg/controller/backup_deletion_controller_test.go @@ -75,7 +75,6 @@ func defaultTestDbr() *velerov1api.DeleteBackupRequest { } func setupBackupDeletionControllerTest(t *testing.T, req *velerov1api.DeleteBackupRequest, objects ...runtime.Object) *backupDeletionControllerTestData { - var ( fakeClient = velerotest.NewFakeControllerRuntimeClient(t, append(objects, req)...) volumeSnapshotter = &velerotest.FakeVolumeSnapshotter{SnapshotsTaken: sets.NewString()} @@ -215,7 +214,6 @@ func TestBackupDeletionControllerReconcile(t *testing.T) { }) t.Run("unable to find backup", func(t *testing.T) { - td := setupBackupDeletionControllerTest(t, defaultTestDbr()) _, err := td.controller.Reconcile(context.TODO(), td.req) @@ -261,7 +259,6 @@ func TestBackupDeletionControllerReconcile(t *testing.T) { assert.Equal(t, "cannot delete backup because backup storage location default is currently in read-only mode", res.Status.Errors[0]) }) t.Run("full delete, no errors", func(t *testing.T) { - input := defaultTestDbr() // Clear out resource labels to make sure the controller adds them and does not @@ -668,7 +665,6 @@ func TestBackupDeletionControllerReconcile(t *testing.T) { err = td.fakeClient.Get(ctx, td.req.NamespacedName, res) assert.True(t, apierrors.IsNotFound(err), "Expected not found error, but actual value of error: %v", err) td.backupStore.AssertNotCalled(t, "DeleteBackup", mock.Anything) - }) t.Run("Expired request will not be deleted if the status is not processed", func(t *testing.T) { @@ -690,7 +686,6 @@ func TestBackupDeletionControllerReconcile(t *testing.T) { assert.Equal(t, "Processed", string(res.Status.Phase)) assert.Len(t, res.Status.Errors, 1) assert.Equal(t, "backup not found", res.Status.Errors[0]) - }) } diff --git a/pkg/controller/backup_repository_controller_test.go b/pkg/controller/backup_repository_controller_test.go index a80a2da2b3..4c8f5fedc8 100644 --- a/pkg/controller/backup_repository_controller_test.go +++ b/pkg/controller/backup_repository_controller_test.go @@ -57,7 +57,6 @@ func mockBackupRepositoryCR() *velerov1api.BackupRepository { MaintenanceFrequency: metav1.Duration{Duration: testMaintenanceFrequency}, }, } - } func TestPatchBackupRepository(t *testing.T) { diff --git a/pkg/controller/data_download_controller_test.go b/pkg/controller/data_download_controller_test.go index e65b2afff1..b0abc7a395 100644 --- a/pkg/controller/data_download_controller_test.go +++ b/pkg/controller/data_download_controller_test.go @@ -526,7 +526,6 @@ func TestOnDataDownloadCompleted(t *testing.T) { ep := exposermockes.NewGenericRestoreExposer(t) if test.rebindVolumeErr { ep.On("RebindVolume", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(errors.New("Error to rebind volume")) - } else { ep.On("RebindVolume", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil) } @@ -813,7 +812,6 @@ func TestTryCancelDataDownload(t *testing.T) { } func TestUpdateDataDownloadWithRetry(t *testing.T) { - namespacedName := types.NamespacedName{ Name: dataDownloadName, Namespace: "velero", @@ -1026,7 +1024,7 @@ func TestAttemptDataDownloadResume(t *testing.T) { } else { assert.NoError(t, err) - // Verify DataDownload marked as Cancelled + // Verify DataDownload marked as Canceled for _, duName := range test.cancelledDataDownloads { dataUpload := &velerov2alpha1api.DataDownload{} err := r.client.Get(context.Background(), types.NamespacedName{Namespace: "velero", Name: duName}, dataUpload) diff --git a/pkg/controller/data_upload_controller_test.go b/pkg/controller/data_upload_controller_test.go index bf9a5674d1..eb440c7686 100644 --- a/pkg/controller/data_upload_controller_test.go +++ b/pkg/controller/data_upload_controller_test.go @@ -885,7 +885,6 @@ func TestTryCancelDataUpload(t *testing.T) { } func TestUpdateDataUploadWithRetry(t *testing.T) { - namespacedName := types.NamespacedName{ Name: dataUploadName, Namespace: "velero", @@ -1097,7 +1096,7 @@ func TestAttemptDataUploadResume(t *testing.T) { } else { assert.NoError(t, err) - // Verify DataUploads marked as Cancelled + // Verify DataUploads marked as Canceled for _, duName := range test.cancelledDataUploads { dataUpload := &velerov2alpha1api.DataUpload{} err := r.client.Get(context.Background(), types.NamespacedName{Namespace: "velero", Name: duName}, dataUpload) diff --git a/pkg/controller/restore_controller_test.go b/pkg/controller/restore_controller_test.go index 7b67aa5693..95628c3cf2 100644 --- a/pkg/controller/restore_controller_test.go +++ b/pkg/controller/restore_controller_test.go @@ -53,7 +53,6 @@ import ( ) func TestFetchBackupInfo(t *testing.T) { - tests := []struct { name string backupName string @@ -206,7 +205,6 @@ func TestProcessQueueItemSkips(t *testing.T) { } func TestRestoreReconcile(t *testing.T) { - defaultStorageLocation := builder.ForBackupStorageLocation("velero", "default").Provider("myCloud").Bucket("bucket").Result() now, err := time.Parse(time.RFC1123Z, time.RFC1123Z) diff --git a/pkg/controller/restore_finalizer_controller_test.go b/pkg/controller/restore_finalizer_controller_test.go index 5bc25fca36..76f4d295f5 100644 --- a/pkg/controller/restore_finalizer_controller_test.go +++ b/pkg/controller/restore_finalizer_controller_test.go @@ -178,7 +178,6 @@ func TestRestoreFinalizerReconcile(t *testing.T) { } }) } - } func TestUpdateResult(t *testing.T) { @@ -453,7 +452,6 @@ func TestPatchDynamicPVWithVolumeInfo(t *testing.T) { assert.Equal(t, expectedPVInfo.ReclaimPolicy, string(pv.Spec.PersistentVolumeReclaimPolicy)) assert.Equal(t, expectedPVInfo.Labels, pv.Labels) } - } } @@ -489,5 +487,4 @@ func TestGetRestoredPVCFromRestoredResourceList(t *testing.T) { } actual = getRestoredPVCFromRestoredResourceList(restoredResourceList) assert.Equal(t, expected, actual) - } diff --git a/pkg/exposer/csi_snapshot_test.go b/pkg/exposer/csi_snapshot_test.go index fe75026372..85e8e96da1 100644 --- a/pkg/exposer/csi_snapshot_test.go +++ b/pkg/exposer/csi_snapshot_test.go @@ -440,7 +440,6 @@ func TestExpose(t *testing.T) { } else { assert.EqualError(t, err, test.err) } - }) } } diff --git a/pkg/persistence/object_store_test.go b/pkg/persistence/object_store_test.go index de3da29f1a..a63d31825c 100644 --- a/pkg/persistence/object_store_test.go +++ b/pkg/persistence/object_store_test.go @@ -1142,7 +1142,6 @@ func TestGetBackupVolumeInfos(t *testing.T) { if len(tc.expectedResult) > 0 { require.Equal(t, tc.expectedResult, result) } - }) } } diff --git a/pkg/plugin/clientmgmt/process/client_builder_test.go b/pkg/plugin/clientmgmt/process/client_builder_test.go index d822d43cbd..a8bf3ad46e 100644 --- a/pkg/plugin/clientmgmt/process/client_builder_test.go +++ b/pkg/plugin/clientmgmt/process/client_builder_test.go @@ -51,7 +51,6 @@ func TestNewClientBuilder(t *testing.T) { assert.Equal(t, []string{"run-plugins", "--log-level", "info", "--features", "feature1,feature2"}, cb.commandArgs) // Clear the features list in case other tests run in the same process. features.NewFeatureFlagSet() - } func TestClientConfig(t *testing.T) { diff --git a/pkg/podvolume/backupper_test.go b/pkg/podvolume/backupper_test.go index 618d380aa4..bf563bdd55 100644 --- a/pkg/podvolume/backupper_test.go +++ b/pkg/podvolume/backupper_test.go @@ -197,7 +197,6 @@ func Test_backupper_BackupPodVolumes_log_test(t *testing.T) { b.BackupPodVolumes(tt.args.backup, tt.args.pod, tt.args.volumesToBackup, tt.args.resPolicies, log) fmt.Println(logOutput.String()) assert.Contains(t, logOutput.String(), tt.wantLog) - }) } } @@ -495,7 +494,7 @@ func TestBackupPodVolumes(t *testing.T) { bsl: "fake-bsl", }, { - name: "context cancelled", + name: "context canceled", ctx: ctxWithCancel, volumes: []string{ "fake-volume-1", @@ -616,7 +615,6 @@ func TestBackupPodVolumes(t *testing.T) { for _, pvb := range test.retPVBs { bp.(*backupper).results[resultsKey(test.sourcePod.Namespace, test.sourcePod.Name)] <- pvb } - } }() diff --git a/pkg/podvolume/restorer_test.go b/pkg/podvolume/restorer_test.go index f630b0fd5f..efccc3ebc1 100644 --- a/pkg/podvolume/restorer_test.go +++ b/pkg/podvolume/restorer_test.go @@ -409,7 +409,6 @@ func TestRestorePodVolumes(t *testing.T) { for _, pvr := range test.retPVRs { rs.(*restorer).results[resultsKey(test.restoredPod.Namespace, test.restoredPod.Name)] <- pvr } - } }() diff --git a/pkg/podvolume/util_test.go b/pkg/podvolume/util_test.go index 79e68450cf..395b45a3fc 100644 --- a/pkg/podvolume/util_test.go +++ b/pkg/podvolume/util_test.go @@ -298,6 +298,5 @@ func TestVolumeHasNonRestorableSource(t *testing.T) { actual := volumeHasNonRestorableSource(tc.volumeName, tc.podVolumes) assert.Equal(t, tc.expected, actual) }) - } } diff --git a/pkg/repository/provider/unified_repo_test.go b/pkg/repository/provider/unified_repo_test.go index 44d7301c40..5d59c151b8 100644 --- a/pkg/repository/provider/unified_repo_test.go +++ b/pkg/repository/provider/unified_repo_test.go @@ -1000,7 +1000,7 @@ func TestBatchForget(t *testing.T) { }) if tc.expectedErr == nil { - assert.Equal(t, 0, len(errs)) + assert.Empty(t, errs) } else { assert.Equal(t, len(tc.expectedErr), len(errs)) diff --git a/pkg/restic/command_factory_test.go b/pkg/restic/command_factory_test.go index c0a627ad1f..75f20d47a5 100644 --- a/pkg/restic/command_factory_test.go +++ b/pkg/restic/command_factory_test.go @@ -89,7 +89,6 @@ func TestGetSnapshotCommand(t *testing.T) { assert.Equal(t, expectedFlags, actualFlags) assert.Equal(t, expectedTags, actualTags) - } func TestInitCommand(t *testing.T) { diff --git a/pkg/restore/merge_service_account_test.go b/pkg/restore/merge_service_account_test.go index e58c423744..4322ae0033 100644 --- a/pkg/restore/merge_service_account_test.go +++ b/pkg/restore/merge_service_account_test.go @@ -361,7 +361,6 @@ func TestMergeMaps(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - result := mergeMaps(tc.destination, tc.source) assert.Equal(t, tc.expected, result) diff --git a/pkg/restore/restore_test.go b/pkg/restore/restore_test.go index ee735386db..dd91382371 100644 --- a/pkg/restore/restore_test.go +++ b/pkg/restore/restore_test.go @@ -1859,7 +1859,6 @@ func TestRestoreWithAsyncOperations(t *testing.T) { UpdatedItem: obj, OperationID: obj.GetName() + "-1", }, nil - }, progressFunc: func(operationID string, restore *velerov1api.Restore) (velero.OperationProgress, error) { return velero.OperationProgress{ @@ -1881,7 +1880,6 @@ func TestRestoreWithAsyncOperations(t *testing.T) { UpdatedItem: obj, OperationID: obj.GetName() + "-1", }, nil - }, progressFunc: func(operationID string, restore *velerov1api.Restore) (velero.OperationProgress, error) { return velero.OperationProgress{ @@ -1902,7 +1900,6 @@ func TestRestoreWithAsyncOperations(t *testing.T) { return &velero.RestoreItemActionExecuteOutput{ UpdatedItem: obj, }, nil - }, } diff --git a/pkg/restore/service_action_test.go b/pkg/restore/service_action_test.go index be722fa2a0..16115e9202 100644 --- a/pkg/restore/service_action_test.go +++ b/pkg/restore/service_action_test.go @@ -65,7 +65,6 @@ func svcJSONFromUnstructured(ports ...map[string]interface{}) string { } func TestServiceActionExecute(t *testing.T) { - tests := []struct { name string obj corev1api.Service diff --git a/pkg/uploader/kopia/snapshot_test.go b/pkg/uploader/kopia/snapshot_test.go index 3021389fba..86c4e69714 100644 --- a/pkg/uploader/kopia/snapshot_test.go +++ b/pkg/uploader/kopia/snapshot_test.go @@ -79,7 +79,6 @@ func MockFuncs(s *snapshotMockes, args []mockArgs) { } func TestSnapshotSource(t *testing.T) { - ctx := context.TODO() sourceInfo := snapshot.SourceInfo{ UserName: "testUserName", diff --git a/pkg/uploader/provider/kopia_test.go b/pkg/uploader/provider/kopia_test.go index f1f16fb926..f6316c965a 100644 --- a/pkg/uploader/provider/kopia_test.go +++ b/pkg/uploader/provider/kopia_test.go @@ -228,7 +228,7 @@ func TestCheckContext(t *testing.T) { kp.CheckContext(ctx, tc.finishChan, tc.restoreChan, tc.uploader) if tc.expectCancel && tc.uploader != nil { - t.Error("Expected the uploader to be cancelled") + t.Error("Expected the uploader to be canceled") } if tc.expectBackup && tc.uploader == nil && len(tc.restoreChan) > 0 { diff --git a/pkg/uploader/provider/provider_test.go b/pkg/uploader/provider/provider_test.go index e04ff78b83..1d90c51f19 100644 --- a/pkg/uploader/provider/provider_test.go +++ b/pkg/uploader/provider/provider_test.go @@ -85,7 +85,6 @@ func TestNewUploaderProvider(t *testing.T) { mockFileGetter := &mocks.FileStore{} mockFileGetter.On("Path", &v1.SecretKeySelector{}).Return("", nil) credGetter.FromFile = mockFileGetter - } _, err := NewUploaderProvider(ctx, client, testCase.UploaderType, testCase.RequestorType, repoIdentifier, bsl, backupRepo, credGetter, repoKeySelector, log) if testCase.ExpectedError == "" { diff --git a/pkg/uploader/provider/restic_test.go b/pkg/uploader/provider/restic_test.go index c653ee1b51..7e828f948b 100644 --- a/pkg/uploader/provider/restic_test.go +++ b/pkg/uploader/provider/restic_test.go @@ -232,7 +232,6 @@ func TestResticRunRestore(t *testing.T) { require.Equal(t, true, tc.errorHandleFunc(err)) }) } - } func TestClose(t *testing.T) { diff --git a/pkg/util/azure/credential_test.go b/pkg/util/azure/credential_test.go index 16381c5cdb..bdd33eadb0 100644 --- a/pkg/util/azure/credential_test.go +++ b/pkg/util/azure/credential_test.go @@ -47,7 +47,6 @@ func TestNewCredential(t *testing.T) { } _, err = NewCredential(creds, options) require.Nil(t, err) - } func Test_newConfigCredential(t *testing.T) { diff --git a/pkg/util/collections/includes_excludes_test.go b/pkg/util/collections/includes_excludes_test.go index fe084f4884..655e3a50e3 100644 --- a/pkg/util/collections/includes_excludes_test.go +++ b/pkg/util/collections/includes_excludes_test.go @@ -729,7 +729,6 @@ func TestGetScopedResourceIncludesExcludes(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - logger := logrus.StandardLogger() nsIncludeExclude := NewIncludesExcludes() resources := GetScopeResourceIncludesExcludes(setupDiscoveryClientWithResources(tc.apiResources), logger, tc.namespaceScopedIncludes, tc.namespaceScopedExcludes, tc.clusterScopedIncludes, tc.clusterScopedExcludes, *nsIncludeExclude) diff --git a/pkg/util/csi/util_test.go b/pkg/util/csi/util_test.go index a9b0a37aa3..8a3ea3cc1c 100644 --- a/pkg/util/csi/util_test.go +++ b/pkg/util/csi/util_test.go @@ -25,7 +25,6 @@ import ( ) func TestCSIFeatureNotEnabledAndPluginIsFromCSI(t *testing.T) { - features.NewFeatureFlagSet("EnableCSI") require.False(t, ShouldSkipAction("abc")) require.False(t, ShouldSkipAction("velero.io/csi-pvc-backupper")) diff --git a/pkg/util/kube/utils_test.go b/pkg/util/kube/utils_test.go index 31110dc8c0..141fb45cee 100644 --- a/pkg/util/kube/utils_test.go +++ b/pkg/util/kube/utils_test.go @@ -138,7 +138,6 @@ func TestEnsureNamespaceExistsAndIsReady(t *testing.T) { assert.Equal(t, test.expectedCreatedResult, nsCreated) }) } - } // TestGetVolumeDirectorySuccess tests that the GetVolumeDirectory function diff --git a/test/e2e/backup/backup.go b/test/e2e/backup/backup.go index 38d3ed6878..fcbc7ee640 100644 --- a/test/e2e/backup/backup.go +++ b/test/e2e/backup/backup.go @@ -58,7 +58,6 @@ func BackupRestoreRetainedPVWithRestic() { } func BackupRestoreTest(backupRestoreTestConfig BackupRestoreTestConfig) { - var ( backupName, restoreName, kibishiiNamespace string err error diff --git a/test/e2e/backups/sync_backups.go b/test/e2e/backups/sync_backups.go index fd7e076c3c..24caace43f 100644 --- a/test/e2e/backups/sync_backups.go +++ b/test/e2e/backups/sync_backups.go @@ -73,7 +73,6 @@ func BackupsSyncTest() { Expect(VeleroUninstall(ctx, veleroCfg.VeleroCLI, veleroCfg.VeleroNamespace)).To(Succeed()) } } - }) It("Backups in object storage should be synced to a new Velero successfully", func() { diff --git a/test/e2e/backups/ttl.go b/test/e2e/backups/ttl.go index 49045266e7..409773264f 100644 --- a/test/e2e/backups/ttl.go +++ b/test/e2e/backups/ttl.go @@ -51,7 +51,6 @@ func (b *TTL) Init() { b.backupName = "backup-ttl-test-" + UUIDgen.String() b.restoreName = "restore-ttl-test-" + UUIDgen.String() b.ttl = 10 * time.Minute - } func TTLTest() { @@ -159,7 +158,6 @@ func TTLTest() { veleroCfg.CloudCredentialsFile, veleroCfg.BSLBucket, veleroCfg.BSLPrefix, veleroCfg.BSLConfig, test.restoreName, RestoreObjectsPrefix)).NotTo(HaveOccurred(), "Fail to get restore object") - }) By("Check TTL was set correctly", func() { @@ -198,7 +196,6 @@ func TTLTest() { veleroCfg.CloudCredentialsFile, veleroCfg.BSLBucket, veleroCfg.BSLPrefix, veleroCfg.BSLConfig, test.restoreName, RestoreObjectsPrefix, 5)).NotTo(HaveOccurred(), "Fail to get restore object") - }) }) } diff --git a/test/e2e/basic/api-group/enable_api_group_extentions.go b/test/e2e/basic/api-group/enable_api_group_extentions.go index 05eeb8256d..d2f7dd13a0 100644 --- a/test/e2e/basic/api-group/enable_api_group_extentions.go +++ b/test/e2e/basic/api-group/enable_api_group_extentions.go @@ -91,7 +91,6 @@ func APIExtensionsVersionsTest() { veleroCfg.ClientToInstallVelero = veleroCfg.DefaultClient }) } - }) Context("When EnableAPIGroupVersions flag is set", func() { It("Enable API Group to B/R CRD APIExtensionsVersions", func() { diff --git a/test/e2e/basic/api-group/enable_api_group_versions.go b/test/e2e/basic/api-group/enable_api_group_versions.go index 489c7edd2f..5c043f2a12 100644 --- a/test/e2e/basic/api-group/enable_api_group_versions.go +++ b/test/e2e/basic/api-group/enable_api_group_versions.go @@ -238,7 +238,6 @@ func runEnableAPIGroupVersionsTests(ctx context.Context, client TestClient, grou fmt.Println(errors.Wrapf(err, "failed to delete crd %q", crdName)) } }(fmt.Sprintf("rockband%ds.music.example.io.%d", i, i)) - } time.Sleep(6 * time.Minute) @@ -328,7 +327,6 @@ func runEnableAPIGroupVersionsTests(ctx context.Context, client TestClient, grou ) return errors.New(msg) } - } } @@ -465,7 +463,6 @@ func resourceInfo(ctx context.Context, g, v, r string, index int) (map[string]ma // are found in the haystack argument values. func containsAll(haystack, needles map[string]string) bool { for nkey, nval := range needles { - hval, ok := haystack[nkey] if !ok { return false diff --git a/test/e2e/basic/storage-class-changing.go b/test/e2e/basic/storage-class-changing.go index 5b35c91d05..fae10c9f89 100644 --- a/test/e2e/basic/storage-class-changing.go +++ b/test/e2e/basic/storage-class-changing.go @@ -83,7 +83,6 @@ func (s *StorageClasssChanging) CreateResources() error { }) By(fmt.Sprintf("Create a deployment in namespace %s", s.VeleroCfg.VeleroNamespace), func() { - pvc, err := CreatePVC(s.Client, s.namespace, s.pvcName, s.srcStorageClass, nil) Expect(err).To(Succeed()) vols := CreateVolumes(pvc.Name, []string{s.volume}) diff --git a/test/e2e/bsl-mgmt/deletion.go b/test/e2e/bsl-mgmt/deletion.go index 9dc6f8e95a..216436696c 100644 --- a/test/e2e/bsl-mgmt/deletion.go +++ b/test/e2e/bsl-mgmt/deletion.go @@ -321,7 +321,6 @@ func BslDeletionTest(useVolumeSnapshots bool) { var snapshotCheckPoint SnapshotCheckPoint snapshotCheckPoint.NamespaceBackedUp = bslDeletionTestNs By(fmt.Sprintf("Snapshot should not be deleted in cloud object store after deleting bsl %s", backupLocation_1), func() { - snapshotCheckPoint, err = GetSnapshotCheckPoint(*veleroCfg.ClientToInstallVelero, veleroCfg, 1, bslDeletionTestNs, backupName_1, []string{podName_1}) Expect(err).NotTo(HaveOccurred(), "Fail to get Azure CSI snapshot checkpoint") Expect(SnapshotsShouldBeCreatedInCloud(veleroCfg.CloudProvider, diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index 906846039f..225f8bf6a7 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -101,7 +101,6 @@ func init() { flag.StringVar(&VeleroCfg.EKSPolicyARN, "eks-policy-arn", "", "EKS plicy ARN for creating AWS IAM service account.") flag.StringVar(&VeleroCfg.DefaultCLSServiceAccountName, "default-cls-service-account-name", "", "default cluster service account name.") flag.StringVar(&VeleroCfg.StandbyCLSServiceAccountName, "standby-cls-service-account-name", "", "standby cluster service account name.") - } // Add label [SkipVanillaZfs]: diff --git a/test/e2e/migration/migration.go b/test/e2e/migration/migration.go index b85c7b347c..f84a3f7a54 100644 --- a/test/e2e/migration/migration.go +++ b/test/e2e/migration/migration.go @@ -108,7 +108,6 @@ func MigrationTest(useVolumeSnapshots bool, veleroCLI2Version VeleroCLI2Version) veleroCfg.ClusterToInstallVelero = veleroCfg.DefaultClusterName }) } - }) When("kibishii is the sample workload", func() { It("should be successfully backed up and restored to the default BackupStorageLocation", func() { diff --git a/test/e2e/pv-backup/pv-backup-filter.go b/test/e2e/pv-backup/pv-backup-filter.go index f6fd7993d0..a858743f95 100644 --- a/test/e2e/pv-backup/pv-backup-filter.go +++ b/test/e2e/pv-backup/pv-backup-filter.go @@ -55,7 +55,6 @@ func (p *PVBackupFiltering) Init() error { // annotation will be ignored, so it's only set for opt-out test if p.annotation == OPT_OUT_ANN { p.BackupArgs = append(p.BackupArgs, "--default-volumes-to-fs-backup") - } p.RestoreArgs = []string{ "create", "--namespace", p.VeleroCfg.VeleroNamespace, "restore", p.RestoreName, diff --git a/test/e2e/resource-filtering/exclude_namespaces.go b/test/e2e/resource-filtering/exclude_namespaces.go index 096ddcfb98..f4e22e852f 100644 --- a/test/e2e/resource-filtering/exclude_namespaces.go +++ b/test/e2e/resource-filtering/exclude_namespaces.go @@ -90,7 +90,6 @@ func (e *ExcludeNamespaces) Init() error { "create", "--namespace", e.VeleroCfg.VeleroNamespace, "restore", e.RestoreName, "--from-backup", e.BackupName, "--wait", } - } else { *e.NSIncluded = append(*e.NSIncluded, *e.nsExcluded...) e.BackupArgs = []string{ diff --git a/test/e2e/resource-filtering/include_namespaces.go b/test/e2e/resource-filtering/include_namespaces.go index e670d123c9..d39c2acb94 100644 --- a/test/e2e/resource-filtering/include_namespaces.go +++ b/test/e2e/resource-filtering/include_namespaces.go @@ -79,7 +79,6 @@ func (i *IncludeNamespaces) Init() error { "create", "--namespace", i.VeleroCfg.VeleroNamespace, "restore", i.RestoreName, "--from-backup", i.BackupName, "--wait", } - } else { i.BackupName = "backup-" + i.UUIDgen i.RestoreName = "restore-" + i.CaseBaseName diff --git a/test/e2e/resourcepolicies/resource_policies.go b/test/e2e/resourcepolicies/resource_policies.go index 82265da9e4..0a724f225b 100644 --- a/test/e2e/resourcepolicies/resource_policies.go +++ b/test/e2e/resourcepolicies/resource_policies.go @@ -177,7 +177,6 @@ func (r *ResourcePoliciesCase) Verify() error { } } }) - } return nil } diff --git a/test/e2e/schedule/schedule.go b/test/e2e/schedule/schedule.go index db1bc1cad3..a12eaefe35 100644 --- a/test/e2e/schedule/schedule.go +++ b/test/e2e/schedule/schedule.go @@ -200,7 +200,6 @@ func (n *ScheduleBackup) Verify() error { fmt.Printf("Restored configmap is %v\n", configmap) Expect(err).ShouldNot(HaveOccurred(), fmt.Sprintf("failed to list configmap in namespace: %q\n", ns)) } - }) return nil } diff --git a/test/e2e/upgrade/upgrade.go b/test/e2e/upgrade/upgrade.go index e6e9b16736..149ae76253 100644 --- a/test/e2e/upgrade/upgrade.go +++ b/test/e2e/upgrade/upgrade.go @@ -123,7 +123,6 @@ func BackupUpgradeRestoreTest(useVolumeSnapshots bool, veleroCLI2Version VeleroC veleroCfg.GCFrequency = "" By(fmt.Sprintf("Install the expected old version Velero (%s) for upgrade", veleroCLI2Version.VeleroVersion), func() { - //Set VeleroImage and RestoreHelperImage to blank //VeleroImage and RestoreHelperImage should be the default value in originalCli tmpCfgForOldVeleroInstall := veleroCfg @@ -230,7 +229,6 @@ func BackupUpgradeRestoreTest(useVolumeSnapshots bool, veleroCLI2Version VeleroC } By(fmt.Sprintf("Upgrade Velero by CLI %s", tmpCfg.VeleroCLI), func() { - tmpCfg.GCFrequency = "" tmpCfg.UseRestic = false tmpCfg.UseNodeAgent = !useVolumeSnapshots diff --git a/test/pkg/client/config.go b/test/pkg/client/config.go index 2302ca9c91..7546a0ac4c 100644 --- a/test/pkg/client/config.go +++ b/test/pkg/client/config.go @@ -130,7 +130,6 @@ func (c VeleroConfig) Colorized() bool { } return colorized - } func (c VeleroConfig) CACertFile() string { diff --git a/test/util/k8s/deployment.go b/test/util/k8s/deployment.go index 0fff022873..3158f8c023 100644 --- a/test/util/k8s/deployment.go +++ b/test/util/k8s/deployment.go @@ -114,7 +114,6 @@ func (d *DeploymentBuilder) WithVolume(volumes []*v1.Volume) *DeploymentBuilder MountPath: "/" + v.Name, }) d.Spec.Template.Spec.Volumes = append(d.Spec.Template.Spec.Volumes, *v) - } // NOTE here just mount volumes to the first container diff --git a/test/util/k8s/persistentvolumes.go b/test/util/k8s/persistentvolumes.go index 441c1bd108..491f394257 100644 --- a/test/util/k8s/persistentvolumes.go +++ b/test/util/k8s/persistentvolumes.go @@ -28,7 +28,6 @@ import ( ) func CreatePersistentVolume(client TestClient, name string) (*corev1.PersistentVolume, error) { - p := &corev1.PersistentVolume{ ObjectMeta: metav1.ObjectMeta{ Name: name, diff --git a/test/util/k8s/pod.go b/test/util/k8s/pod.go index 5a76382c53..84e0a6b4eb 100644 --- a/test/util/k8s/pod.go +++ b/test/util/k8s/pod.go @@ -107,7 +107,6 @@ func GetPod(ctx context.Context, client TestClient, namespace string, pod string } func AddAnnotationToPod(ctx context.Context, client TestClient, namespace, podName string, ann map[string]string) (*corev1.Pod, error) { - newPod, err := GetPod(ctx, client, namespace, podName) if err != nil { return nil, errors.Wrap(err, fmt.Sprintf("Fail to ge pod %s in namespace %s", podName, namespace)) diff --git a/test/util/k8s/rbac.go b/test/util/k8s/rbac.go index ac7cfb56d4..c6fa2559c6 100644 --- a/test/util/k8s/rbac.go +++ b/test/util/k8s/rbac.go @@ -76,7 +76,6 @@ func GetClusterRoleBinding(ctx context.Context, client TestClient, rolebinding s } func CleanupClusterRole(ctx context.Context, client TestClient, CaseBaseName string) error { - clusterroles, err := client.ClientGo.RbacV1().ClusterRoles().List(ctx, metav1.ListOptions{}) if err != nil { return errors.Wrap(err, "Could not retrieve clusterroles") @@ -95,7 +94,6 @@ func CleanupClusterRole(ctx context.Context, client TestClient, CaseBaseName str } func CleanupClusterRoleBinding(ctx context.Context, client TestClient, CaseBaseName string) error { - clusterrolebindings, err := client.ClientGo.RbacV1().ClusterRoleBindings().List(ctx, metav1.ListOptions{}) if err != nil { return errors.Wrap(err, "Could not retrieve clusterrolebindings") diff --git a/test/util/providers/aws_utils.go b/test/util/providers/aws_utils.go index 116c6b351c..d40a2bec20 100644 --- a/test/util/providers/aws_utils.go +++ b/test/util/providers/aws_utils.go @@ -128,7 +128,6 @@ func newS3Client(cfg aws.Config, url string, forcePathStyle bool) (*s3.Client, e // GetBucketRegion returns the AWS region that a bucket is in, or an error // if the region cannot be determined. func GetBucketRegion(bucket string) (string, error) { - cfg, err := config.LoadDefaultConfig(context.Background()) if err != nil { return "", errors.WithStack(err) diff --git a/test/util/providers/azure_utils.go b/test/util/providers/azure_utils.go index 06063dcfa4..4106f71a75 100644 --- a/test/util/providers/azure_utils.go +++ b/test/util/providers/azure_utils.go @@ -270,7 +270,6 @@ func (s AzureStorage) DeleteObjectsInBucket(cloudCredentialsFile, bslBucket, bsl marker = listBlob.NextMarker for _, blobInfo := range listBlob.Segment.BlobItems { - if strings.Contains(blobInfo.Name, bslPrefix+backupObject+"/") { deleteBlob(p, accountName, containerName, blobInfo.Name) if err != nil { @@ -284,7 +283,6 @@ func (s AzureStorage) DeleteObjectsInBucket(cloudCredentialsFile, bslBucket, bsl } func (s AzureStorage) IsSnapshotExisted(cloudCredentialsFile, bslConfig, backupName string, snapshotCheck SnapshotCheckPoint) error { - ctx := context.Background() if err := loadCredentialsIntoEnv(cloudCredentialsFile); err != nil { diff --git a/test/util/velero/velero_utils.go b/test/util/velero/velero_utils.go index 81c734f2ba..2e4627a81e 100644 --- a/test/util/velero/velero_utils.go +++ b/test/util/velero/velero_utils.go @@ -173,7 +173,6 @@ func getPluginsByVersion(version, cloudProvider, objectStoreProvider, feature st plugins = append(plugins, pluginsForDatamover...) } } - } return plugins, nil } @@ -181,7 +180,6 @@ func getPluginsByVersion(version, cloudProvider, objectStoreProvider, feature st // getProviderVeleroInstallOptions returns Velero InstallOptions for the provider. func getProviderVeleroInstallOptions(veleroCfg *VeleroConfig, plugins []string) (*cliinstall.Options, error) { - if veleroCfg.CloudCredentialsFile == "" && veleroCfg.ServiceAccountNameToInstall == "" { return nil, errors.Errorf("No credentials were supplied to use for E2E tests") } @@ -1184,7 +1182,6 @@ func DeleteBslResource(ctx context.Context, veleroCLI string, bslName string) er } func SnapshotCRsCountShouldBe(ctx context.Context, namespace, backupName string, expectedCount int) error { - checkSnapshotCmd := exec.CommandContext(ctx, "kubectl", "get", "-n", namespace, "snapshots.backupdriver.cnsdp.vmware.com", "-o=jsonpath='{range .items[*]}{.metadata.labels.velero\\.io\\/backup-name}{\"\\n\"}{end}'") fmt.Printf("checkSnapshotCmd cmd =%v\n", checkSnapshotCmd) @@ -1603,7 +1600,6 @@ func InstallTestStorageClasses(path string) error { } func GetPvName(ctx context.Context, client TestClient, pvcName, namespace string) (string, error) { - pvcList, err := GetPvcByPVCName(context.Background(), namespace, pvcName) if err != nil { return "", err @@ -1622,7 +1618,6 @@ func GetPvName(ctx context.Context, client TestClient, pvcName, namespace string } return pvList[0], nil - } func DeletePVs(ctx context.Context, client TestClient, pvList []string) error { for _, pv := range pvList { @@ -1637,7 +1632,6 @@ func DeletePVs(ctx context.Context, client TestClient, pvList []string) error { } func CleanAllRetainedPV(ctx context.Context, client TestClient) { - pvNameList, err := GetAllPVNames(ctx, client) if err != nil { fmt.Println("fail to list PV")