diff --git a/internal/hook/item_hook_handler.go b/internal/hook/item_hook_handler.go index d84f9bcaa..8c3738050 100644 --- a/internal/hook/item_hook_handler.go +++ b/internal/hook/item_hook_handler.go @@ -277,7 +277,7 @@ func phasedKey(phase hookPhase, key string) string { if phase != "" { return fmt.Sprintf("%v.%v", phase, key) } - return string(key) + return key } func getHookAnnotation(annotations map[string]string, key string, phase hookPhase) string { diff --git a/pkg/backup/remap_crd_version_action_test.go b/pkg/backup/remap_crd_version_action_test.go index ea679ef0e..93482a6bd 100644 --- a/pkg/backup/remap_crd_version_action_test.go +++ b/pkg/backup/remap_crd_version_action_test.go @@ -178,7 +178,7 @@ func TestRemapCRDVersionActionData(t *testing.T) { require.NoError(t, err) var obj unstructured.Unstructured - err = json.Unmarshal([]byte(f), &obj) + err = json.Unmarshal(f, &obj) require.NoError(t, err) // Load a v1beta1 struct into the beta client to be returned @@ -187,7 +187,7 @@ func TestRemapCRDVersionActionData(t *testing.T) { require.NoError(t, err) var crd apiextv1beta1.CustomResourceDefinition - err = json.Unmarshal([]byte(f), &crd) + err = json.Unmarshal(f, &crd) require.NoError(t, err) _, err = betaClient.Create(context.TODO(), &crd, metav1.CreateOptions{}) diff --git a/pkg/cmd/cli/bug/bug.go b/pkg/cmd/cli/bug/bug.go index ea775ec31..c9c613b23 100644 --- a/pkg/cmd/cli/bug/bug.go +++ b/pkg/cmd/cli/bug/bug.go @@ -171,7 +171,7 @@ func getKubectlVersion() (string, error) { } } versionOut := outbuf.String() - kubectlVersion := strings.TrimSpace(string(versionOut)) + kubectlVersion := strings.TrimSpace(versionOut) return kubectlVersion, nil } diff --git a/pkg/controller/backup_repository_controller_test.go b/pkg/controller/backup_repository_controller_test.go index 0197e1f61..3288ee68d 100644 --- a/pkg/controller/backup_repository_controller_test.go +++ b/pkg/controller/backup_repository_controller_test.go @@ -203,13 +203,13 @@ func TestGetRepositoryMaintenanceFrequency(t *testing.T) { }{ { name: "user defined valid", - userDefinedFreq: time.Duration(time.Hour), - expectFreq: time.Duration(time.Hour), + userDefinedFreq: time.Hour, + expectFreq: time.Hour, }, { name: "repo return valid", - freqReturn: time.Duration(time.Hour * 2), - expectFreq: time.Duration(time.Hour * 2), + freqReturn: time.Hour * 2, + expectFreq: time.Hour * 2, }, { name: "fall to default", diff --git a/pkg/plugin/clientmgmt/restartable_item_snapshotter_test.go b/pkg/plugin/clientmgmt/restartable_item_snapshotter_test.go index 29805bc42..26f5a51db 100644 --- a/pkg/plugin/clientmgmt/restartable_item_snapshotter_test.go +++ b/pkg/plugin/clientmgmt/restartable_item_snapshotter_test.go @@ -203,8 +203,8 @@ func TestRestartableItemSnasphotterDelegatedFunctions(t *testing.T) { restartabletest.RestartableDelegateTest{ Function: "AlsoHandles", Inputs: []interface{}{&isv1.AlsoHandlesInput{}}, - ExpectedErrorOutputs: []interface{}{[]velero.ResourceIdentifier([]velero.ResourceIdentifier(nil)), errors.Errorf("reset error")}, - ExpectedDelegateOutputs: []interface{}{[]velero.ResourceIdentifier([]velero.ResourceIdentifier(nil)), errors.Errorf("delegate error")}, + ExpectedErrorOutputs: []interface{}{[]velero.ResourceIdentifier(nil), errors.Errorf("reset error")}, + ExpectedDelegateOutputs: []interface{}{[]velero.ResourceIdentifier(nil), errors.Errorf("delegate error")}, }, restartabletest.RestartableDelegateTest{ Function: "SnapshotItem", diff --git a/pkg/repository/udmrepo/kopialib/lib_repo.go b/pkg/repository/udmrepo/kopialib/lib_repo.go index 1a32560f3..0246620bc 100644 --- a/pkg/repository/udmrepo/kopialib/lib_repo.go +++ b/pkg/repository/udmrepo/kopialib/lib_repo.go @@ -74,7 +74,7 @@ type kopiaObjectWriter struct { } const ( - defaultLogInterval = time.Duration(time.Second * 10) + defaultLogInterval = time.Second * 10 defaultMaintainCheckPeriod = time.Hour overwriteFullMaintainInterval = time.Duration(0) overwriteQuickMaintainInterval = time.Duration(0) @@ -505,9 +505,9 @@ func getManifestEntriesFromKopia(kMani []*manifest.EntryMetadata) []*udmrepo.Man } func (lt *logThrottle) shouldLog() bool { - nextOutputTime := atomic.LoadInt64((*int64)(<.lastTime)) + nextOutputTime := atomic.LoadInt64(<.lastTime) if nowNano := time.Now().UnixNano(); nowNano > nextOutputTime { - if atomic.CompareAndSwapInt64((*int64)(<.lastTime), nextOutputTime, nowNano+lt.interval.Nanoseconds()) { + if atomic.CompareAndSwapInt64(<.lastTime, nextOutputTime, nowNano+lt.interval.Nanoseconds()) { return true } } diff --git a/pkg/restic/exec_commands_test.go b/pkg/restic/exec_commands_test.go index 0353f3e2c..2fdd39e88 100644 --- a/pkg/restic/exec_commands_test.go +++ b/pkg/restic/exec_commands_test.go @@ -79,7 +79,7 @@ third line } for _, tt := range tests { t.Run(tt.want, func(t *testing.T) { - assert.Equal(t, []byte(tt.want), getLastLine([]byte(tt.output))) + assert.Equal(t, []byte(tt.want), getLastLine(tt.output)) }) } } diff --git a/test/e2e/backups/sync_backups.go b/test/e2e/backups/sync_backups.go index deb9befa6..1c628ca50 100644 --- a/test/e2e/backups/sync_backups.go +++ b/test/e2e/backups/sync_backups.go @@ -47,7 +47,7 @@ func (b *SyncBackups) Init() { UUIDgen, _ = uuid.NewRandom() b.testNS = "sync-bsl-test-" + UUIDgen.String() b.backupName = "sync-bsl-test-" + UUIDgen.String() - b.ctx, _ = context.WithTimeout(context.Background(), time.Duration(time.Minute*10)) + b.ctx, _ = context.WithTimeout(context.Background(), time.Minute*10) } func BackupsSyncTest() { diff --git a/test/e2e/backups/ttl.go b/test/e2e/backups/ttl.go index 6ce8816a9..d10c3fe7f 100644 --- a/test/e2e/backups/ttl.go +++ b/test/e2e/backups/ttl.go @@ -52,8 +52,8 @@ func (b *TTL) Init() { b.testNS = "backup-ttl-test-" + UUIDgen.String() b.backupName = "backup-ttl-test-" + UUIDgen.String() b.restoreName = "restore-ttl-test-" + UUIDgen.String() - b.ctx, _ = context.WithTimeout(context.Background(), time.Duration(time.Hour)) - b.ttl = time.Duration(20 * time.Minute) + b.ctx, _ = context.WithTimeout(context.Background(), time.Hour) + b.ttl = 20 * time.Minute } diff --git a/test/e2e/privilegesmgmt/ssr.go b/test/e2e/privilegesmgmt/ssr.go index 428cacc81..00938ce8a 100644 --- a/test/e2e/privilegesmgmt/ssr.go +++ b/test/e2e/privilegesmgmt/ssr.go @@ -57,7 +57,7 @@ func SSRTest() { It(fmt.Sprintf("Should create an ssr object in the %s namespace and later removed by controller", VeleroCfg.VeleroNamespace), func() { defer DeleteNamespace(context.TODO(), *VeleroCfg.ClientToInstallVelero, testNS, false) - ctx, _ := context.WithTimeout(context.Background(), time.Duration(time.Minute*10)) + ctx, _ := context.WithTimeout(context.Background(), time.Minute*10) By(fmt.Sprintf("Create %s namespace", testNS)) Expect(CreateNamespace(ctx, *VeleroCfg.ClientToInstallVelero, testNS)).To(Succeed(), fmt.Sprintf("Failed to create %s namespace", testNS)) diff --git a/test/e2e/util/k8s/persistentvolumes.go b/test/e2e/util/k8s/persistentvolumes.go index cc7962cbe..44ee5fff1 100644 --- a/test/e2e/util/k8s/persistentvolumes.go +++ b/test/e2e/util/k8s/persistentvolumes.go @@ -36,7 +36,7 @@ func CreatePersistentVolume(client TestClient, name string) (*corev1.PersistentV Spec: corev1.PersistentVolumeSpec{ StorageClassName: "manual", AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}, - Capacity: corev1.ResourceList{corev1.ResourceName(corev1.ResourceStorage): resource.MustParse("2Gi")}, + Capacity: corev1.ResourceList{corev1.ResourceStorage: resource.MustParse("2Gi")}, PersistentVolumeSource: corev1.PersistentVolumeSource{ HostPath: &corev1.HostPathVolumeSource{ diff --git a/test/e2e/util/velero/install.go b/test/e2e/util/velero/install.go index 2c8938976..30e99b2ee 100644 --- a/test/e2e/util/velero/install.go +++ b/test/e2e/util/velero/install.go @@ -274,7 +274,7 @@ func createVelereResources(ctx context.Context, cli, namespace string, args []st resources := &unstructured.UnstructuredList{} if err := json.Unmarshal([]byte(stdout), resources); err != nil { - return errors.Wrapf(err, "failed to unmarshal the resources: %s", string(stdout)) + return errors.Wrapf(err, "failed to unmarshal the resources: %s", stdout) } if err = patchResources(ctx, resources, namespace, registryCredentialFile, VeleroCfg.RestoreHelperImage); err != nil {