mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-29 11:16:08 +00:00
chore: enable use-any from revive
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
@@ -36,9 +36,9 @@ import (
|
||||
|
||||
func TestBackupPVAction(t *testing.T) {
|
||||
pvc := &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
"spec": map[string]interface{}{},
|
||||
"status": map[string]interface{}{},
|
||||
Object: map[string]any{
|
||||
"spec": map[string]any{},
|
||||
"status": map[string]any{},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func TestBackupPVAction(t *testing.T) {
|
||||
|
||||
// empty spec.volumeName should result in no error
|
||||
// and no additional items
|
||||
pvc.Object["spec"].(map[string]interface{})["volumeName"] = ""
|
||||
pvc.Object["spec"].(map[string]any)["volumeName"] = ""
|
||||
_, additional, err = a.Execute(pvc, backup)
|
||||
assert.NoError(t, err)
|
||||
assert.Empty(t, additional)
|
||||
@@ -116,28 +116,28 @@ func TestBackupPVAction(t *testing.T) {
|
||||
|
||||
// non-empty spec.volumeName when status.phase is empty
|
||||
// should result in no error and no additional items
|
||||
pvc.Object["spec"].(map[string]interface{})["volumeName"] = "myVolume"
|
||||
pvc.Object["spec"].(map[string]any)["volumeName"] = "myVolume"
|
||||
_, additional, err = a.Execute(pvc, backup)
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, additional)
|
||||
|
||||
// non-empty spec.volumeName when status.phase is 'Pending'
|
||||
// should result in no error and no additional items
|
||||
pvc.Object["status"].(map[string]interface{})["phase"] = corev1api.ClaimPending
|
||||
pvc.Object["status"].(map[string]any)["phase"] = corev1api.ClaimPending
|
||||
_, additional, err = a.Execute(pvc, backup)
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, additional)
|
||||
|
||||
// non-empty spec.volumeName when status.phase is 'Lost'
|
||||
// should result in no error and no additional items
|
||||
pvc.Object["status"].(map[string]interface{})["phase"] = corev1api.ClaimLost
|
||||
pvc.Object["status"].(map[string]any)["phase"] = corev1api.ClaimLost
|
||||
_, additional, err = a.Execute(pvc, backup)
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, additional)
|
||||
|
||||
// non-empty spec.volumeName when status.phase is 'Bound'
|
||||
// should result in no error and one additional item for the PV
|
||||
pvc.Object["status"].(map[string]interface{})["phase"] = corev1api.ClaimBound
|
||||
pvc.Object["status"].(map[string]any)["phase"] = corev1api.ClaimBound
|
||||
_, additional, err = a.Execute(pvc, backup)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, additional, 1)
|
||||
@@ -145,7 +145,7 @@ func TestBackupPVAction(t *testing.T) {
|
||||
|
||||
// empty spec.volumeName when status.phase is 'Bound' should
|
||||
// result in no error and no additional items
|
||||
pvc.Object["spec"].(map[string]interface{})["volumeName"] = ""
|
||||
pvc.Object["spec"].(map[string]any)["volumeName"] = ""
|
||||
_, additional, err = a.Execute(pvc, backup)
|
||||
assert.NoError(t, err)
|
||||
assert.Empty(t, additional)
|
||||
|
||||
@@ -552,7 +552,7 @@ func cancelDataUpload(
|
||||
}
|
||||
|
||||
func NewPvcBackupItemAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
crClient, err := f.KubebuilderClient()
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
|
||||
@@ -372,7 +372,7 @@ func (p *volumeSnapshotBackupItemAction) Cancel(
|
||||
func NewVolumeSnapshotBackupItemAction(
|
||||
f client.Factory,
|
||||
) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
crClient, err := f.KubebuilderClient()
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
|
||||
@@ -119,6 +119,6 @@ func (p *volumeSnapshotClassBackupItemAction) Cancel(
|
||||
|
||||
// NewVolumeSnapshotClassBackupItemAction returns a
|
||||
// VolumeSnapshotClassBackupItemAction instance.
|
||||
func NewVolumeSnapshotClassBackupItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func NewVolumeSnapshotClassBackupItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return &volumeSnapshotClassBackupItemAction{log: logger}, nil
|
||||
}
|
||||
|
||||
@@ -136,6 +136,6 @@ func (p *volumeSnapshotContentBackupItemAction) Cancel(
|
||||
// VolumeSnapshotContentBackupItemAction instance.
|
||||
func NewVolumeSnapshotContentBackupItemAction(
|
||||
logger logrus.FieldLogger,
|
||||
) (interface{}, error) {
|
||||
) (any, error) {
|
||||
return &volumeSnapshotContentBackupItemAction{log: logger}, nil
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ func TestRemapCRDVersionActionData(t *testing.T) {
|
||||
// For ElasticSearch and Kibana, problems manifested when additionalPrinterColumns was moved from the top-level spec down to the
|
||||
// versions slice.
|
||||
if test.expectAdditionalColumns {
|
||||
_, ok := item.UnstructuredContent()["spec"].(map[string]interface{})["additionalPrinterColumns"]
|
||||
_, ok := item.UnstructuredContent()["spec"].(map[string]any)["additionalPrinterColumns"]
|
||||
assert.True(t, ok)
|
||||
}
|
||||
|
||||
|
||||
@@ -446,7 +446,7 @@ func (kb *kubernetesBackupper) BackupWithResolvers(
|
||||
var itemBlock *BackupItemBlock
|
||||
|
||||
for i := range items {
|
||||
log.WithFields(map[string]interface{}{
|
||||
log.WithFields(map[string]any{
|
||||
"progress": "",
|
||||
"resource": items[i].groupResource.String(),
|
||||
"namespace": items[i].namespace,
|
||||
@@ -507,7 +507,7 @@ func (kb *kubernetesBackupper) BackupWithResolvers(
|
||||
itemsBackedUp: backedUpItems,
|
||||
}
|
||||
|
||||
log.WithFields(map[string]interface{}{
|
||||
log.WithFields(map[string]any{
|
||||
"progress": "",
|
||||
"resource": items[i].groupResource.String(),
|
||||
"namespace": items[i].namespace,
|
||||
@@ -973,7 +973,7 @@ func (kb *kubernetesBackupper) FinalizeBackup(
|
||||
unstructuredDataUploads := make([]unstructured.Unstructured, 0)
|
||||
|
||||
for i, item := range items {
|
||||
log.WithFields(map[string]interface{}{
|
||||
log.WithFields(map[string]any{
|
||||
"progress": "",
|
||||
"resource": item.groupResource.String(),
|
||||
"namespace": item.namespace,
|
||||
@@ -1016,7 +1016,7 @@ func (kb *kubernetesBackupper) FinalizeBackup(
|
||||
backedUpItems := backupRequest.BackedUpItems.Len()
|
||||
totalItems := backedUpItems + (len(items) - (i + 1))
|
||||
|
||||
log.WithFields(map[string]interface{}{
|
||||
log.WithFields(map[string]any{
|
||||
"progress": "",
|
||||
"resource": item.groupResource.String(),
|
||||
"namespace": item.namespace,
|
||||
|
||||
@@ -1364,7 +1364,7 @@ func TestBackupItemActionsForSkippedPV(t *testing.T) {
|
||||
VolumePolicies: []resourcepolicies.VolumePolicy{
|
||||
{
|
||||
Action: resourcepolicies.Action{Type: "snapshot"},
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"storageClass": []string{"gp2"},
|
||||
},
|
||||
},
|
||||
@@ -1849,7 +1849,7 @@ func TestBackupActionModifications(t *testing.T) {
|
||||
},
|
||||
actions: []biav2.BackupItemAction{
|
||||
modifyingActionGetter(func(item *unstructured.Unstructured) {
|
||||
item.Object["spec"].(map[string]interface{})["nodeName"] = "foo"
|
||||
item.Object["spec"].(map[string]any)["nodeName"] = "foo"
|
||||
}),
|
||||
},
|
||||
want: map[string]unstructuredObject{
|
||||
@@ -4282,7 +4282,7 @@ func defaultBackup() *builder.BackupBuilder {
|
||||
return builder.ForBackup(velerov1.DefaultNamespace, "backup-1").DefaultVolumesToFsBackup(false)
|
||||
}
|
||||
|
||||
func toUnstructuredOrFail(t *testing.T, obj interface{}) map[string]interface{} {
|
||||
func toUnstructuredOrFail(t *testing.T, obj any) map[string]any {
|
||||
t.Helper()
|
||||
|
||||
res, err := runtime.DefaultUnstructuredConverter.ToUnstructured(obj)
|
||||
@@ -4318,7 +4318,7 @@ func assertTarballContents(t *testing.T, backupFile io.Reader, items ...string)
|
||||
}
|
||||
|
||||
// unstructuredObject is a type alias to improve readability.
|
||||
type unstructuredObject map[string]interface{}
|
||||
type unstructuredObject map[string]any
|
||||
|
||||
// assertTarballFileContents verifies that the gzipped tarball stored in the provided
|
||||
// backupFile contains the files specified as keys in 'want', and for each of those
|
||||
|
||||
@@ -159,7 +159,7 @@ func (ib *itemBackupper) backupItemInternal(logger logrus.FieldLogger, obj runti
|
||||
namespace := metadata.GetNamespace()
|
||||
name := metadata.GetName()
|
||||
|
||||
log := logger.WithFields(map[string]interface{}{
|
||||
log := logger.WithFields(map[string]any{
|
||||
"name": name,
|
||||
"resource": groupResource.String(),
|
||||
"namespace": namespace,
|
||||
@@ -218,7 +218,7 @@ func (ib *itemBackupper) backupItemInternal(logger logrus.FieldLogger, obj runti
|
||||
ib.podVolumeSnapshotTracker.Track(pod, volume.Name)
|
||||
|
||||
if found, pvcName := ib.podVolumeSnapshotTracker.TakenForPodVolume(pod, volume.Name); found {
|
||||
log.WithFields(map[string]interface{}{
|
||||
log.WithFields(map[string]any{
|
||||
"podVolume": volume,
|
||||
"pvcName": pvcName,
|
||||
}).Info("Pod volume uses a persistent volume claim which has already been backed up from another pod, skipping.")
|
||||
|
||||
Reference in New Issue
Block a user