Skip to content

Commit

Permalink
Clean up unnecessary convert (#5819)
Browse files Browse the repository at this point in the history
Signed-off-by: Fish-pro <zechun.chen@daocloud.io>
  • Loading branch information
Fish-pro authored Feb 6, 2023
1 parent 0b6b841 commit 843c709
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion internal/hook/item_hook_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/backup/remap_crd_version_action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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{})
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/cli/bug/bug.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func getKubectlVersion() (string, error) {
}
}
versionOut := outbuf.String()
kubectlVersion := strings.TrimSpace(string(versionOut))
kubectlVersion := strings.TrimSpace(versionOut)
return kubectlVersion, nil
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/backup_repository_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions pkg/plugin/clientmgmt/restartable_item_snapshotter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions pkg/repository/udmrepo/kopialib/lib_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -505,9 +505,9 @@ func getManifestEntriesFromKopia(kMani []*manifest.EntryMetadata) []*udmrepo.Man
}

func (lt *logThrottle) shouldLog() bool {
nextOutputTime := atomic.LoadInt64((*int64)(&lt.lastTime))
nextOutputTime := atomic.LoadInt64(&lt.lastTime)
if nowNano := time.Now().UnixNano(); nowNano > nextOutputTime {
if atomic.CompareAndSwapInt64((*int64)(&lt.lastTime), nextOutputTime, nowNano+lt.interval.Nanoseconds()) {
if atomic.CompareAndSwapInt64(&lt.lastTime, nextOutputTime, nowNano+lt.interval.Nanoseconds()) {
return true
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/restic/exec_commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/backups/sync_backups.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/backups/ttl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

}

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/privilegesmgmt/ssr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/util/k8s/persistentvolumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/util/velero/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 843c709

Please sign in to comment.