Clean up unnecessary convert (#5819)
Signed-off-by: Fish-pro <zechun.chen@daocloud.io>pull/5863/head
parent
0b6b841f2a
commit
843c70959f
|
@ -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 {
|
||||
|
|
|
@ -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{})
|
||||
|
|
|
@ -171,7 +171,7 @@ func getKubectlVersion() (string, error) {
|
|||
}
|
||||
}
|
||||
versionOut := outbuf.String()
|
||||
kubectlVersion := strings.TrimSpace(string(versionOut))
|
||||
kubectlVersion := strings.TrimSpace(versionOut)
|
||||
return kubectlVersion, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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{
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue