mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-08 14:21:18 +00:00
chore: enable use-any from revive
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
@@ -257,7 +257,7 @@ func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error {
|
||||
backupInformer := cache.NewSharedInformer(&lw, &velerov1api.Backup{}, time.Second)
|
||||
_, _ = backupInformer.AddEventHandler(
|
||||
cache.FilteringResourceEventHandler{
|
||||
FilterFunc: func(obj interface{}) bool {
|
||||
FilterFunc: func(obj any) bool {
|
||||
backup, ok := obj.(*velerov1api.Backup)
|
||||
|
||||
if !ok {
|
||||
@@ -266,14 +266,14 @@ func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error {
|
||||
return backup.Name == o.Name
|
||||
},
|
||||
Handler: cache.ResourceEventHandlerFuncs{
|
||||
UpdateFunc: func(_, obj interface{}) {
|
||||
UpdateFunc: func(_, obj any) {
|
||||
backup, ok := obj.(*velerov1api.Backup)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
updates <- backup
|
||||
},
|
||||
DeleteFunc: func(obj interface{}) {
|
||||
DeleteFunc: func(obj any) {
|
||||
backup, ok := obj.(*velerov1api.Backup)
|
||||
if !ok {
|
||||
return
|
||||
|
||||
@@ -56,7 +56,7 @@ func TestExitWithMessage(t *testing.T) {
|
||||
name string
|
||||
message string
|
||||
succeed bool
|
||||
args []interface{}
|
||||
args []any
|
||||
createErr error
|
||||
writeFail bool
|
||||
expectedExitCode int
|
||||
@@ -77,7 +77,7 @@ func TestExitWithMessage(t *testing.T) {
|
||||
{
|
||||
name: "not succeed",
|
||||
message: "fake-message-1, arg-1 %s, arg-2 %v, arg-3 %v",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
"arg-1-1",
|
||||
10,
|
||||
false,
|
||||
@@ -88,7 +88,7 @@ func TestExitWithMessage(t *testing.T) {
|
||||
{
|
||||
name: "not succeed",
|
||||
message: "fake-message-2, arg-1 %s, arg-2 %v, arg-3 %v",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
"arg-1-2",
|
||||
20,
|
||||
true,
|
||||
|
||||
@@ -369,7 +369,7 @@ func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error {
|
||||
|
||||
_, _ = restoreInformer.AddEventHandler(
|
||||
cache.FilteringResourceEventHandler{
|
||||
FilterFunc: func(obj interface{}) bool {
|
||||
FilterFunc: func(obj any) bool {
|
||||
restore, ok := obj.(*api.Restore)
|
||||
if !ok {
|
||||
return false
|
||||
@@ -377,14 +377,14 @@ func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error {
|
||||
return restore.Name == o.RestoreName
|
||||
},
|
||||
Handler: cache.ResourceEventHandlerFuncs{
|
||||
UpdateFunc: func(_, obj interface{}) {
|
||||
UpdateFunc: func(_, obj any) {
|
||||
restore, ok := obj.(*api.Restore)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
updates <- restore
|
||||
},
|
||||
DeleteFunc: func(obj interface{}) {
|
||||
DeleteFunc: func(obj any) {
|
||||
restore, ok := obj.(*api.Restore)
|
||||
if !ok {
|
||||
return
|
||||
|
||||
@@ -34,7 +34,7 @@ func CheckError(err error) {
|
||||
}
|
||||
|
||||
// Exit prints msg (with optional args), plus a newline, to stderr and exits with code 1.
|
||||
func Exit(msg string, args ...interface{}) {
|
||||
func Exit(msg string, args ...any) {
|
||||
fmt.Fprintf(os.Stderr, msg+"\n", args...)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
@@ -209,16 +209,16 @@ func NewCommand(f client.Factory) *cobra.Command {
|
||||
return c
|
||||
}
|
||||
|
||||
func newPVBackupItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newPVBackupItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return bia.NewPVCAction(logger), nil
|
||||
}
|
||||
|
||||
func newPodBackupItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newPodBackupItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return bia.NewPodAction(logger), nil
|
||||
}
|
||||
|
||||
func newServiceAccountBackupItemAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
// TODO(ncdc): consider a k8s style WantsKubernetesClientSet initialization approach
|
||||
clientset, err := f.KubeClient()
|
||||
if err != nil {
|
||||
@@ -248,7 +248,7 @@ func newServiceAccountBackupItemAction(f client.Factory) plugincommon.HandlerIni
|
||||
}
|
||||
|
||||
func newRemapCRDVersionAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
config, err := f.ClientConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -272,20 +272,20 @@ func newRemapCRDVersionAction(f client.Factory) plugincommon.HandlerInitializer
|
||||
}
|
||||
}
|
||||
|
||||
func newJobRestoreItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newJobRestoreItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return ria.NewJobAction(logger), nil
|
||||
}
|
||||
|
||||
func newPodRestoreItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newPodRestoreItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return ria.NewPodAction(logger), nil
|
||||
}
|
||||
|
||||
func newInitRestoreHookPodAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newInitRestoreHookPodAction(logger logrus.FieldLogger) (any, error) {
|
||||
return ria.NewInitRestoreHookPodAction(logger), nil
|
||||
}
|
||||
|
||||
func newPodVolumeRestoreItemAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
client, err := f.KubeClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -300,28 +300,28 @@ func newPodVolumeRestoreItemAction(f client.Factory) plugincommon.HandlerInitial
|
||||
}
|
||||
}
|
||||
|
||||
func newServiceRestoreItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newServiceRestoreItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return ria.NewServiceAction(logger), nil
|
||||
}
|
||||
|
||||
func newServiceAccountRestoreItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newServiceAccountRestoreItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return ria.NewServiceAccountAction(logger), nil
|
||||
}
|
||||
|
||||
func newAddPVCFromPodRestoreItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newAddPVCFromPodRestoreItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return ria.NewAddPVCFromPodAction(logger), nil
|
||||
}
|
||||
|
||||
func newAddPVFromPVCRestoreItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newAddPVFromPVCRestoreItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return ria.NewAddPVFromPVCAction(logger), nil
|
||||
}
|
||||
|
||||
func newCRDV1PreserveUnknownFieldsItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newCRDV1PreserveUnknownFieldsItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return ria.NewCRDV1PreserveUnknownFieldsAction(logger), nil
|
||||
}
|
||||
|
||||
func newChangeStorageClassRestoreItemAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
client, err := f.KubeClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -336,7 +336,7 @@ func newChangeStorageClassRestoreItemAction(f client.Factory) plugincommon.Handl
|
||||
}
|
||||
|
||||
func newChangeImageNameRestoreItemAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
client, err := f.KubeClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -348,16 +348,16 @@ func newChangeImageNameRestoreItemAction(f client.Factory) plugincommon.HandlerI
|
||||
), nil
|
||||
}
|
||||
}
|
||||
func newRoleBindingItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newRoleBindingItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return ria.NewRoleBindingAction(logger), nil
|
||||
}
|
||||
|
||||
func newClusterRoleBindingItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newClusterRoleBindingItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return ria.NewClusterRoleBindingAction(logger), nil
|
||||
}
|
||||
|
||||
func newChangePVCNodeSelectorItemAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
client, err := f.KubeClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -371,16 +371,16 @@ func newChangePVCNodeSelectorItemAction(f client.Factory) plugincommon.HandlerIn
|
||||
}
|
||||
}
|
||||
|
||||
func newAPIServiceRestoreItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newAPIServiceRestoreItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return ria.NewAPIServiceAction(logger), nil
|
||||
}
|
||||
|
||||
func newAdmissionWebhookConfigurationAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newAdmissionWebhookConfigurationAction(logger logrus.FieldLogger) (any, error) {
|
||||
return ria.NewAdmissionWebhookConfigurationAction(logger), nil
|
||||
}
|
||||
|
||||
func newSecretRestoreItemAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
client, err := f.KubebuilderClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -390,7 +390,7 @@ func newSecretRestoreItemAction(f client.Factory) plugincommon.HandlerInitialize
|
||||
}
|
||||
|
||||
func newDataUploadRetrieveAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
client, err := f.KubebuilderClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -401,7 +401,7 @@ func newDataUploadRetrieveAction(f client.Factory) plugincommon.HandlerInitializ
|
||||
}
|
||||
|
||||
func newDateUploadDeleteItemAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
client, err := f.KubebuilderClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -422,11 +422,11 @@ func newVolumeSnapshotBackupItemAction(f client.Factory) plugincommon.HandlerIni
|
||||
return csibia.NewVolumeSnapshotBackupItemAction(f)
|
||||
}
|
||||
|
||||
func newVolumeSnapshotContentBackupItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newVolumeSnapshotContentBackupItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return csibia.NewVolumeSnapshotContentBackupItemAction(logger)
|
||||
}
|
||||
|
||||
func newVolumeSnapshotClassBackupItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newVolumeSnapshotClassBackupItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return csibia.NewVolumeSnapshotClassBackupItemAction(logger)
|
||||
}
|
||||
|
||||
@@ -450,11 +450,11 @@ func newVolumeSnapshotRestoreItemAction(f client.Factory) plugincommon.HandlerIn
|
||||
return csiria.NewVolumeSnapshotRestoreItemAction(f)
|
||||
}
|
||||
|
||||
func newVolumeSnapshotContentRestoreItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newVolumeSnapshotContentRestoreItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return csiria.NewVolumeSnapshotContentRestoreItemAction(logger)
|
||||
}
|
||||
|
||||
func newVolumeSnapshotClassRestoreItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newVolumeSnapshotClassRestoreItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return csiria.NewVolumeSnapshotClassRestoreItemAction(logger)
|
||||
}
|
||||
|
||||
@@ -464,12 +464,12 @@ func newPVCItemBlockAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
return iba.NewPVCAction(f)
|
||||
}
|
||||
|
||||
func newPodItemBlockAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newPodItemBlockAction(logger logrus.FieldLogger) (any, error) {
|
||||
return iba.NewPodAction(logger), nil
|
||||
}
|
||||
|
||||
func newServiceAccountItemBlockAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
// TODO(ncdc): consider a k8s style WantsKubernetesClientSet initialization approach
|
||||
clientset, err := f.KubeClient()
|
||||
if err != nil {
|
||||
|
||||
@@ -74,11 +74,11 @@ func DescribeBackupInSF(
|
||||
|
||||
// DescribeBackupSpecInSF describes a backup spec in structured format.
|
||||
func DescribeBackupSpecInSF(d *StructuredDescriber, spec velerov1api.BackupSpec) {
|
||||
backupSpecInfo := make(map[string]interface{})
|
||||
backupSpecInfo := make(map[string]any)
|
||||
var s string
|
||||
|
||||
// describe namespaces
|
||||
namespaceInfo := make(map[string]interface{})
|
||||
namespaceInfo := make(map[string]any)
|
||||
if len(spec.IncludedNamespaces) == 0 {
|
||||
s = "*"
|
||||
} else {
|
||||
@@ -140,10 +140,10 @@ func DescribeBackupSpecInSF(d *StructuredDescriber, spec velerov1api.BackupSpec)
|
||||
backupSpecInfo["CSISnapshotTimeout"] = spec.CSISnapshotTimeout.Duration.String()
|
||||
|
||||
// describe hooks
|
||||
hooksInfo := make(map[string]interface{})
|
||||
hooksResources := make(map[string]interface{})
|
||||
hooksInfo := make(map[string]any)
|
||||
hooksResources := make(map[string]any)
|
||||
for _, backupResourceHookSpec := range spec.Hooks.Resources {
|
||||
ResourceDetails := make(map[string]interface{})
|
||||
ResourceDetails := make(map[string]any)
|
||||
var s string
|
||||
namespaceInfo := make(map[string]string)
|
||||
if len(backupResourceHookSpec.IncludedNamespaces) == 0 {
|
||||
@@ -181,10 +181,10 @@ func DescribeBackupSpecInSF(d *StructuredDescriber, spec velerov1api.BackupSpec)
|
||||
}
|
||||
ResourceDetails["labelSelector"] = s
|
||||
|
||||
preHooks := make([]map[string]interface{}, 0)
|
||||
preHooks := make([]map[string]any, 0)
|
||||
for _, hook := range backupResourceHookSpec.PreHooks {
|
||||
if hook.Exec != nil {
|
||||
preExecHook := make(map[string]interface{})
|
||||
preExecHook := make(map[string]any)
|
||||
preExecHook["container"] = hook.Exec.Container
|
||||
preExecHook["command"] = strings.Join(hook.Exec.Command, " ")
|
||||
preExecHook["onError:"] = hook.Exec.OnError
|
||||
@@ -194,10 +194,10 @@ func DescribeBackupSpecInSF(d *StructuredDescriber, spec velerov1api.BackupSpec)
|
||||
}
|
||||
ResourceDetails["preExecHook"] = preHooks
|
||||
|
||||
postHooks := make([]map[string]interface{}, 0)
|
||||
postHooks := make([]map[string]any, 0)
|
||||
for _, hook := range backupResourceHookSpec.PostHooks {
|
||||
if hook.Exec != nil {
|
||||
postExecHook := make(map[string]interface{})
|
||||
postExecHook := make(map[string]any)
|
||||
postExecHook["container"] = hook.Exec.Container
|
||||
postExecHook["command"] = strings.Join(hook.Exec.Command, " ")
|
||||
postExecHook["onError:"] = hook.Exec.OnError
|
||||
@@ -225,7 +225,7 @@ func DescribeBackupSpecInSF(d *StructuredDescriber, spec velerov1api.BackupSpec)
|
||||
func DescribeBackupStatusInSF(ctx context.Context, kbClient kbclient.Client, d *StructuredDescriber, backup *velerov1api.Backup, details bool,
|
||||
insecureSkipTLSVerify bool, caCertPath string, podVolumeBackups []velerov1api.PodVolumeBackup) {
|
||||
status := backup.Status
|
||||
backupStatusInfo := make(map[string]interface{})
|
||||
backupStatusInfo := make(map[string]any)
|
||||
|
||||
// Status.Version has been deprecated, use Status.FormatVersion
|
||||
backupStatusInfo["backupFormatVersion"] = status.FormatVersion
|
||||
@@ -271,7 +271,7 @@ func DescribeBackupStatusInSF(ctx context.Context, kbClient kbclient.Client, d *
|
||||
}
|
||||
}
|
||||
|
||||
func describeBackupResourceListInSF(ctx context.Context, kbClient kbclient.Client, backupStatusInfo map[string]interface{}, backup *velerov1api.Backup, insecureSkipTLSVerify bool, caCertPath string) {
|
||||
func describeBackupResourceListInSF(ctx context.Context, kbClient kbclient.Client, backupStatusInfo map[string]any, backup *velerov1api.Backup, insecureSkipTLSVerify bool, caCertPath string) {
|
||||
// In consideration of decoding structured output conveniently, the two separate fields were created here(in func describeBackupResourceList, there is only one field describing either error message or resource list)
|
||||
// the field of 'errorGettingResourceList' gives specific error message when it fails to get resources list
|
||||
// the field of 'resourceList' lists the rearranged resources
|
||||
@@ -299,8 +299,8 @@ func describeBackupResourceListInSF(ctx context.Context, kbClient kbclient.Clien
|
||||
}
|
||||
|
||||
func describeBackupVolumesInSF(ctx context.Context, kbClient kbclient.Client, backup *velerov1api.Backup, details bool,
|
||||
insecureSkipTLSVerify bool, caCertPath string, podVolumeBackupCRs []velerov1api.PodVolumeBackup, backupStatusInfo map[string]interface{}) {
|
||||
backupVolumes := make(map[string]interface{})
|
||||
insecureSkipTLSVerify bool, caCertPath string, podVolumeBackupCRs []velerov1api.PodVolumeBackup, backupStatusInfo map[string]any) {
|
||||
backupVolumes := make(map[string]any)
|
||||
|
||||
nativeSnapshots := []*volume.BackupVolumeInfo{}
|
||||
csiSnapshots := []*volume.BackupVolumeInfo{}
|
||||
@@ -351,20 +351,20 @@ func describeBackupVolumesInSF(ctx context.Context, kbClient kbclient.Client, ba
|
||||
backupStatusInfo["backupVolumes"] = backupVolumes
|
||||
}
|
||||
|
||||
func describeNativeSnapshotsInSF(details bool, infos []*volume.BackupVolumeInfo, backupVolumes map[string]interface{}) {
|
||||
func describeNativeSnapshotsInSF(details bool, infos []*volume.BackupVolumeInfo, backupVolumes map[string]any) {
|
||||
if len(infos) == 0 {
|
||||
backupVolumes["nativeSnapshots"] = "<none included>"
|
||||
return
|
||||
}
|
||||
|
||||
snapshotDetails := make(map[string]interface{})
|
||||
snapshotDetails := make(map[string]any)
|
||||
for _, info := range infos {
|
||||
describNativeSnapshotInSF(details, info, snapshotDetails)
|
||||
}
|
||||
backupVolumes["nativeSnapshots"] = snapshotDetails
|
||||
}
|
||||
|
||||
func describNativeSnapshotInSF(details bool, info *volume.BackupVolumeInfo, snapshotDetails map[string]interface{}) {
|
||||
func describNativeSnapshotInSF(details bool, info *volume.BackupVolumeInfo, snapshotDetails map[string]any) {
|
||||
if details {
|
||||
snapshotInfo := make(map[string]string)
|
||||
snapshotInfo["snapshotID"] = info.NativeSnapshotInfo.SnapshotHandle
|
||||
@@ -379,7 +379,7 @@ func describNativeSnapshotInSF(details bool, info *volume.BackupVolumeInfo, snap
|
||||
}
|
||||
}
|
||||
|
||||
func describeCSISnapshotsInSF(details bool, infos []*volume.BackupVolumeInfo, backupVolumes map[string]interface{}, legacyInfoSource bool) {
|
||||
func describeCSISnapshotsInSF(details bool, infos []*volume.BackupVolumeInfo, backupVolumes map[string]any, legacyInfoSource bool) {
|
||||
if len(infos) == 0 {
|
||||
if legacyInfoSource {
|
||||
backupVolumes["csiSnapshots"] = "<none included or not detectable>"
|
||||
@@ -389,15 +389,15 @@ func describeCSISnapshotsInSF(details bool, infos []*volume.BackupVolumeInfo, ba
|
||||
return
|
||||
}
|
||||
|
||||
snapshotDetails := make(map[string]interface{})
|
||||
snapshotDetails := make(map[string]any)
|
||||
for _, info := range infos {
|
||||
describeCSISnapshotInSF(details, info, snapshotDetails)
|
||||
}
|
||||
backupVolumes["csiSnapshots"] = snapshotDetails
|
||||
}
|
||||
|
||||
func describeCSISnapshotInSF(details bool, info *volume.BackupVolumeInfo, snapshotDetails map[string]interface{}) {
|
||||
snapshotDetail := make(map[string]interface{})
|
||||
func describeCSISnapshotInSF(details bool, info *volume.BackupVolumeInfo, snapshotDetails map[string]any) {
|
||||
snapshotDetail := make(map[string]any)
|
||||
|
||||
describeLocalSnapshotInSF(details, info, snapshotDetail)
|
||||
describeDataMovementInSF(details, info, snapshotDetail)
|
||||
@@ -406,13 +406,13 @@ func describeCSISnapshotInSF(details bool, info *volume.BackupVolumeInfo, snapsh
|
||||
}
|
||||
|
||||
// describeLocalSnapshotInSF describes CSI volume snapshot contents in structured format.
|
||||
func describeLocalSnapshotInSF(details bool, info *volume.BackupVolumeInfo, snapshotDetail map[string]interface{}) {
|
||||
func describeLocalSnapshotInSF(details bool, info *volume.BackupVolumeInfo, snapshotDetail map[string]any) {
|
||||
if !info.PreserveLocalSnapshot {
|
||||
return
|
||||
}
|
||||
|
||||
if details {
|
||||
localSnapshot := make(map[string]interface{})
|
||||
localSnapshot := make(map[string]any)
|
||||
|
||||
if !info.SnapshotDataMoved {
|
||||
localSnapshot["operationID"] = info.CSISnapshotInfo.OperationID
|
||||
@@ -430,13 +430,13 @@ func describeLocalSnapshotInSF(details bool, info *volume.BackupVolumeInfo, snap
|
||||
}
|
||||
}
|
||||
|
||||
func describeDataMovementInSF(details bool, info *volume.BackupVolumeInfo, snapshotDetail map[string]interface{}) {
|
||||
func describeDataMovementInSF(details bool, info *volume.BackupVolumeInfo, snapshotDetail map[string]any) {
|
||||
if !info.SnapshotDataMoved {
|
||||
return
|
||||
}
|
||||
|
||||
if details {
|
||||
dataMovement := make(map[string]interface{})
|
||||
dataMovement := make(map[string]any)
|
||||
dataMovement["operationID"] = info.SnapshotDataMovementInfo.OperationID
|
||||
|
||||
dataMover := "velero"
|
||||
@@ -456,14 +456,14 @@ func describeDataMovementInSF(details bool, info *volume.BackupVolumeInfo, snaps
|
||||
|
||||
// DescribeDeleteBackupRequestsInSF describes delete backup requests in structured format.
|
||||
func DescribeDeleteBackupRequestsInSF(d *StructuredDescriber, requests []velerov1api.DeleteBackupRequest) {
|
||||
deletionAttempts := make(map[string]interface{})
|
||||
deletionAttempts := make(map[string]any)
|
||||
if count := failedDeletionCount(requests); count > 0 {
|
||||
deletionAttempts["failed"] = count
|
||||
}
|
||||
|
||||
deletionRequests := make([]map[string]interface{}, 0)
|
||||
deletionRequests := make([]map[string]any, 0)
|
||||
for _, req := range requests {
|
||||
deletionReq := make(map[string]interface{})
|
||||
deletionReq := make(map[string]any)
|
||||
deletionReq["creationTimestamp"] = req.CreationTimestamp.String()
|
||||
deletionReq["phase"] = req.Status.Phase
|
||||
|
||||
@@ -477,8 +477,8 @@ func DescribeDeleteBackupRequestsInSF(d *StructuredDescriber, requests []velerov
|
||||
}
|
||||
|
||||
// describePodVolumeBackupsInSF describes pod volume backups in structured format.
|
||||
func describePodVolumeBackupsInSF(backups []velerov1api.PodVolumeBackup, details bool, backupVolumes map[string]interface{}) {
|
||||
podVolumeBackupsInfo := make(map[string]interface{})
|
||||
func describePodVolumeBackupsInSF(backups []velerov1api.PodVolumeBackup, details bool, backupVolumes map[string]any) {
|
||||
podVolumeBackupsInfo := make(map[string]any)
|
||||
// Get the type of pod volume uploader. Since the uploader only comes from a single source, we can
|
||||
// take the uploader type from the first element of the array.
|
||||
var uploaderType string
|
||||
@@ -491,7 +491,7 @@ func describePodVolumeBackupsInSF(backups []velerov1api.PodVolumeBackup, details
|
||||
// type display the type of pod volume backups
|
||||
podVolumeBackupsInfo["uploderType"] = uploaderType
|
||||
|
||||
podVolumeBackupsDetails := make(map[string]interface{})
|
||||
podVolumeBackupsDetails := make(map[string]any)
|
||||
// separate backups by phase (combining <none> and New into a single group)
|
||||
backupsByPhase := groupByPhase(backups)
|
||||
|
||||
@@ -537,7 +537,7 @@ func DescribeBackupResultsInSF(ctx context.Context, kbClient kbclient.Client, d
|
||||
var buf bytes.Buffer
|
||||
var resultMap map[string]results.Result
|
||||
|
||||
errors, warnings := make(map[string]interface{}), make(map[string]interface{})
|
||||
errors, warnings := make(map[string]any), make(map[string]any)
|
||||
defer func() {
|
||||
d.Describe("errors", errors)
|
||||
d.Describe("warnings", warnings)
|
||||
@@ -572,13 +572,13 @@ func DescribeBackupResultsInSF(ctx context.Context, kbClient kbclient.Client, d
|
||||
|
||||
// DescribeResourcePoliciesInSF describes resource policies in structured format.
|
||||
func DescribeResourcePoliciesInSF(d *StructuredDescriber, resPolicies *v1.TypedLocalObjectReference) {
|
||||
policiesInfo := make(map[string]interface{})
|
||||
policiesInfo := make(map[string]any)
|
||||
policiesInfo["type"] = resPolicies.Kind
|
||||
policiesInfo["name"] = resPolicies.Name
|
||||
d.Describe("resourcePolicies", policiesInfo)
|
||||
}
|
||||
|
||||
func describeResultInSF(m map[string]interface{}, result results.Result) {
|
||||
func describeResultInSF(m map[string]any, result results.Result) {
|
||||
m["velero"], m["cluster"], m["namespace"] = []string{}, []string{}, []string{}
|
||||
|
||||
if len(result.Velero) > 0 {
|
||||
|
||||
@@ -33,7 +33,7 @@ import (
|
||||
|
||||
func TestDescribeBackupInSF(t *testing.T) {
|
||||
sd := &StructuredDescriber{
|
||||
output: make(map[string]interface{}),
|
||||
output: make(map[string]any),
|
||||
format: "",
|
||||
}
|
||||
backupBuilder1 := builder.ForBackup("test-ns", "test-backup")
|
||||
@@ -75,9 +75,9 @@ func TestDescribeBackupInSF(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
expect1 := map[string]interface{}{
|
||||
"spec": map[string]interface{}{
|
||||
"namespaces": map[string]interface{}{
|
||||
expect1 := map[string]any{
|
||||
"spec": map[string]any{
|
||||
"namespaces": map[string]any{
|
||||
"included": "inc-ns-1, inc-ns-2",
|
||||
"excluded": "exc-ns-1, exc-ns-2",
|
||||
},
|
||||
@@ -93,15 +93,15 @@ func TestDescribeBackupInSF(t *testing.T) {
|
||||
"TTL": "72h0m0s",
|
||||
"CSISnapshotTimeout": "10m0s",
|
||||
"veleroSnapshotMoveData": "auto",
|
||||
"hooks": map[string]interface{}{
|
||||
"resources": map[string]interface{}{
|
||||
"hook-1": map[string]interface{}{
|
||||
"hooks": map[string]any{
|
||||
"resources": map[string]any{
|
||||
"hook-1": map[string]any{
|
||||
"labelSelector": emptyDisplay,
|
||||
"namespaces": map[string]string{
|
||||
"included": "hook-inc-ns-1, hook-inc-ns-2",
|
||||
"excluded": "hook-exc-ns-1, hook-exc-ns-2",
|
||||
},
|
||||
"preExecHook": []map[string]interface{}{
|
||||
"preExecHook": []map[string]any{
|
||||
{
|
||||
"container": "hook-container-1",
|
||||
"command": "pre",
|
||||
@@ -109,7 +109,7 @@ func TestDescribeBackupInSF(t *testing.T) {
|
||||
"timeout": "0s",
|
||||
},
|
||||
},
|
||||
"postExecHook": []map[string]interface{}{
|
||||
"postExecHook": []map[string]any{
|
||||
{
|
||||
"container": "hook-container-1",
|
||||
"command": "post",
|
||||
@@ -160,9 +160,9 @@ func TestDescribeBackupInSF(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
expect2 := map[string]interface{}{
|
||||
"spec": map[string]interface{}{
|
||||
"namespaces": map[string]interface{}{
|
||||
expect2 := map[string]any{
|
||||
"spec": map[string]any{
|
||||
"namespaces": map[string]any{
|
||||
"included": "*",
|
||||
"excluded": emptyDisplay,
|
||||
},
|
||||
@@ -178,15 +178,15 @@ func TestDescribeBackupInSF(t *testing.T) {
|
||||
"TTL": "0s",
|
||||
"CSISnapshotTimeout": "0s",
|
||||
"veleroSnapshotMoveData": "auto",
|
||||
"hooks": map[string]interface{}{
|
||||
"resources": map[string]interface{}{
|
||||
"hook-1": map[string]interface{}{
|
||||
"hooks": map[string]any{
|
||||
"resources": map[string]any{
|
||||
"hook-1": map[string]any{
|
||||
"labelSelector": emptyDisplay,
|
||||
"namespaces": map[string]string{
|
||||
"included": "*",
|
||||
"excluded": emptyDisplay,
|
||||
},
|
||||
"preExecHook": []map[string]interface{}{
|
||||
"preExecHook": []map[string]any{
|
||||
{
|
||||
"container": "hook-container-1",
|
||||
"command": "pre",
|
||||
@@ -194,7 +194,7 @@ func TestDescribeBackupInSF(t *testing.T) {
|
||||
"timeout": "0s",
|
||||
},
|
||||
},
|
||||
"postExecHook": []map[string]interface{}{
|
||||
"postExecHook": []map[string]any{
|
||||
{
|
||||
"container": "hook-container-1",
|
||||
"command": "post",
|
||||
@@ -244,21 +244,21 @@ func TestDescribePodVolumeBackupsInSF(t *testing.T) {
|
||||
name string
|
||||
inputPVBList []velerov1api.PodVolumeBackup
|
||||
inputDetails bool
|
||||
expect map[string]interface{}
|
||||
expect map[string]any
|
||||
}{
|
||||
{
|
||||
name: "empty list",
|
||||
inputPVBList: []velerov1api.PodVolumeBackup{},
|
||||
inputDetails: false,
|
||||
expect: map[string]interface{}{"podVolumeBackups": "<none included>"},
|
||||
expect: map[string]any{"podVolumeBackups": "<none included>"},
|
||||
},
|
||||
{
|
||||
name: "2 completed pvbs",
|
||||
inputPVBList: []velerov1api.PodVolumeBackup{*pvb1, *pvb2},
|
||||
inputDetails: true,
|
||||
expect: map[string]interface{}{
|
||||
"podVolumeBackups": map[string]interface{}{
|
||||
"podVolumeBackupsDetails": map[string]interface{}{
|
||||
expect: map[string]any{
|
||||
"podVolumeBackups": map[string]any{
|
||||
"podVolumeBackupsDetails": map[string]any{
|
||||
"Completed": []map[string]string{
|
||||
{"pod-ns-1/pod-1": "vol-1"},
|
||||
{"pod-ns-1/pod-2": "vol-2"},
|
||||
@@ -271,7 +271,7 @@ func TestDescribePodVolumeBackupsInSF(t *testing.T) {
|
||||
}
|
||||
for _, tc := range testcases {
|
||||
t.Run(tc.name, func(tt *testing.T) {
|
||||
output := make(map[string]interface{})
|
||||
output := make(map[string]any)
|
||||
describePodVolumeBackupsInSF(tc.inputPVBList, tc.inputDetails, output)
|
||||
assert.True(tt, reflect.DeepEqual(output, tc.expect))
|
||||
})
|
||||
@@ -283,7 +283,7 @@ func TestDescribeNativeSnapshotsInSF(t *testing.T) {
|
||||
name string
|
||||
volumeInfo []*volume.BackupVolumeInfo
|
||||
inputDetails bool
|
||||
expect map[string]interface{}
|
||||
expect map[string]any
|
||||
}{
|
||||
{
|
||||
name: "no details",
|
||||
@@ -299,8 +299,8 @@ func TestDescribeNativeSnapshotsInSF(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
expect: map[string]interface{}{
|
||||
"nativeSnapshots": map[string]interface{}{
|
||||
expect: map[string]any{
|
||||
"nativeSnapshots": map[string]any{
|
||||
"pv-1": "specify --details for more information",
|
||||
},
|
||||
},
|
||||
@@ -321,8 +321,8 @@ func TestDescribeNativeSnapshotsInSF(t *testing.T) {
|
||||
},
|
||||
},
|
||||
inputDetails: true,
|
||||
expect: map[string]interface{}{
|
||||
"nativeSnapshots": map[string]interface{}{
|
||||
expect: map[string]any{
|
||||
"nativeSnapshots": map[string]any{
|
||||
"pv-1": map[string]string{
|
||||
"snapshotID": "snapshot-1",
|
||||
"type": "ebs",
|
||||
@@ -337,7 +337,7 @@ func TestDescribeNativeSnapshotsInSF(t *testing.T) {
|
||||
|
||||
for _, tc := range testcases {
|
||||
t.Run(tc.name, func(tt *testing.T) {
|
||||
output := make(map[string]interface{})
|
||||
output := make(map[string]any)
|
||||
describeNativeSnapshotsInSF(tc.inputDetails, tc.volumeInfo, output)
|
||||
assert.True(tt, reflect.DeepEqual(output, tc.expect))
|
||||
})
|
||||
@@ -349,13 +349,13 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) {
|
||||
name string
|
||||
volumeInfo []*volume.BackupVolumeInfo
|
||||
inputDetails bool
|
||||
expect map[string]interface{}
|
||||
expect map[string]any
|
||||
legacyInfoSource bool
|
||||
}{
|
||||
{
|
||||
name: "empty info, not legacy",
|
||||
volumeInfo: []*volume.BackupVolumeInfo{},
|
||||
expect: map[string]interface{}{
|
||||
expect: map[string]any{
|
||||
"csiSnapshots": "<none included>",
|
||||
},
|
||||
},
|
||||
@@ -363,7 +363,7 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) {
|
||||
name: "empty info, legacy",
|
||||
volumeInfo: []*volume.BackupVolumeInfo{},
|
||||
legacyInfoSource: true,
|
||||
expect: map[string]interface{}{
|
||||
expect: map[string]any{
|
||||
"csiSnapshots": "<none included or not detectable>",
|
||||
},
|
||||
},
|
||||
@@ -384,9 +384,9 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
expect: map[string]interface{}{
|
||||
"csiSnapshots": map[string]interface{}{
|
||||
"pvc-ns-1/pvc-1": map[string]interface{}{
|
||||
expect: map[string]any{
|
||||
"csiSnapshots": map[string]any{
|
||||
"pvc-ns-1/pvc-1": map[string]any{
|
||||
"snapshot": "included, specify --details for more information",
|
||||
},
|
||||
},
|
||||
@@ -411,10 +411,10 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) {
|
||||
},
|
||||
},
|
||||
inputDetails: true,
|
||||
expect: map[string]interface{}{
|
||||
"csiSnapshots": map[string]interface{}{
|
||||
"pvc-ns-2/pvc-2": map[string]interface{}{
|
||||
"snapshot": map[string]interface{}{
|
||||
expect: map[string]any{
|
||||
"csiSnapshots": map[string]any{
|
||||
"pvc-ns-2/pvc-2": map[string]any{
|
||||
"snapshot": map[string]any{
|
||||
"operationID": "fake-operation-2",
|
||||
"snapshotContentName": "vsc-2",
|
||||
"storageSnapshotID": "snapshot-2",
|
||||
@@ -442,9 +442,9 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
expect: map[string]interface{}{
|
||||
"csiSnapshots": map[string]interface{}{
|
||||
"pvc-ns-3/pvc-3": map[string]interface{}{
|
||||
expect: map[string]any{
|
||||
"csiSnapshots": map[string]any{
|
||||
"pvc-ns-3/pvc-3": map[string]any{
|
||||
"dataMovement": "included, specify --details for more information",
|
||||
},
|
||||
},
|
||||
@@ -468,10 +468,10 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) {
|
||||
},
|
||||
},
|
||||
inputDetails: true,
|
||||
expect: map[string]interface{}{
|
||||
"csiSnapshots": map[string]interface{}{
|
||||
"pvc-ns-4/pvc-4": map[string]interface{}{
|
||||
"dataMovement": map[string]interface{}{
|
||||
expect: map[string]any{
|
||||
"csiSnapshots": map[string]any{
|
||||
"pvc-ns-4/pvc-4": map[string]any{
|
||||
"dataMovement": map[string]any{
|
||||
"operationID": "fake-operation-4",
|
||||
"dataMover": "velero",
|
||||
"uploaderType": "fake-uploader",
|
||||
@@ -498,10 +498,10 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) {
|
||||
},
|
||||
},
|
||||
inputDetails: true,
|
||||
expect: map[string]interface{}{
|
||||
"csiSnapshots": map[string]interface{}{
|
||||
"pvc-ns-4/pvc-4": map[string]interface{}{
|
||||
"dataMovement": map[string]interface{}{
|
||||
expect: map[string]any{
|
||||
"csiSnapshots": map[string]any{
|
||||
"pvc-ns-4/pvc-4": map[string]any{
|
||||
"dataMovement": map[string]any{
|
||||
"operationID": "fake-operation-4",
|
||||
"dataMover": "velero",
|
||||
"uploaderType": "fake-uploader",
|
||||
@@ -515,7 +515,7 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) {
|
||||
|
||||
for _, tc := range testcases {
|
||||
t.Run(tc.name, func(tt *testing.T) {
|
||||
output := make(map[string]interface{})
|
||||
output := make(map[string]any)
|
||||
describeCSISnapshotsInSF(tc.inputDetails, tc.volumeInfo, output, tc.legacyInfoSource)
|
||||
assert.True(tt, reflect.DeepEqual(output, tc.expect))
|
||||
})
|
||||
@@ -527,14 +527,14 @@ func TestDescribeResourcePoliciesInSF(t *testing.T) {
|
||||
Kind: "configmap",
|
||||
Name: "resource-policy-1",
|
||||
}
|
||||
expect := map[string]interface{}{
|
||||
"resourcePolicies": map[string]interface{}{
|
||||
expect := map[string]any{
|
||||
"resourcePolicies": map[string]any{
|
||||
"type": "configmap",
|
||||
"name": "resource-policy-1",
|
||||
},
|
||||
}
|
||||
sd := &StructuredDescriber{
|
||||
output: make(map[string]interface{}),
|
||||
output: make(map[string]any),
|
||||
format: "",
|
||||
}
|
||||
DescribeResourcePoliciesInSF(sd, input)
|
||||
@@ -549,8 +549,8 @@ func TestDescribeBackupResultInSF(t *testing.T) {
|
||||
"ns-1": {"ns-1-msg-1", "ns-1-msg-2"},
|
||||
},
|
||||
}
|
||||
got := map[string]interface{}{}
|
||||
expect := map[string]interface{}{
|
||||
got := map[string]any{}
|
||||
expect := map[string]any{
|
||||
"velero": []string{"msg-1", "msg-2"},
|
||||
"cluster": []string{"cluster-1", "cluster-2"},
|
||||
"namespace": map[string][]string{
|
||||
@@ -579,24 +579,24 @@ func TestDescribeDeleteBackupRequestsInSF(t *testing.T) {
|
||||
testcases := []struct {
|
||||
name string
|
||||
input []velerov1api.DeleteBackupRequest
|
||||
expect map[string]interface{}
|
||||
expect map[string]any
|
||||
}{
|
||||
{
|
||||
name: "empty list",
|
||||
input: []velerov1api.DeleteBackupRequest{},
|
||||
expect: map[string]interface{}{
|
||||
"deletionAttempts": map[string]interface{}{
|
||||
"deleteBackupRequests": []map[string]interface{}{},
|
||||
expect: map[string]any{
|
||||
"deletionAttempts": map[string]any{
|
||||
"deleteBackupRequests": []map[string]any{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "list with one failed and one in-progress request",
|
||||
input: []velerov1api.DeleteBackupRequest{*dbr1, *dbr2},
|
||||
expect: map[string]interface{}{
|
||||
"deletionAttempts": map[string]interface{}{
|
||||
expect: map[string]any{
|
||||
"deletionAttempts": map[string]any{
|
||||
"failed": int(1),
|
||||
"deleteBackupRequests": []map[string]interface{}{
|
||||
"deleteBackupRequests": []map[string]any{
|
||||
{
|
||||
"creationTimestamp": t1.String(),
|
||||
"phase": velerov1api.DeleteBackupRequestPhaseProcessed,
|
||||
@@ -616,7 +616,7 @@ func TestDescribeDeleteBackupRequestsInSF(t *testing.T) {
|
||||
for _, tc := range testcases {
|
||||
t.Run(tc.name, func(tt *testing.T) {
|
||||
sd := &StructuredDescriber{
|
||||
output: make(map[string]interface{}),
|
||||
output: make(map[string]any),
|
||||
format: "",
|
||||
}
|
||||
DescribeDeleteBackupRequestsInSF(sd, tc.input)
|
||||
|
||||
@@ -47,12 +47,12 @@ func Describe(fn func(d *Describer)) string {
|
||||
return d.buf.String()
|
||||
}
|
||||
|
||||
func (d *Describer) Printf(msg string, args ...interface{}) {
|
||||
func (d *Describer) Printf(msg string, args ...any) {
|
||||
fmt.Fprint(d.out, d.Prefix)
|
||||
fmt.Fprintf(d.out, msg, args...)
|
||||
}
|
||||
|
||||
func (d *Describer) Println(args ...interface{}) {
|
||||
func (d *Describer) Println(args ...any) {
|
||||
fmt.Fprint(d.out, d.Prefix)
|
||||
fmt.Fprintln(d.out, args...)
|
||||
}
|
||||
@@ -122,14 +122,14 @@ func BoolPointerString(b *bool, falseString, trueString, nilString string) strin
|
||||
}
|
||||
|
||||
type StructuredDescriber struct {
|
||||
output map[string]interface{}
|
||||
output map[string]any
|
||||
format string
|
||||
}
|
||||
|
||||
// NewStructuredDescriber creates a StructuredDescriber.
|
||||
func NewStructuredDescriber(format string) *StructuredDescriber {
|
||||
return &StructuredDescriber{
|
||||
output: make(map[string]interface{}),
|
||||
output: make(map[string]any),
|
||||
format: format,
|
||||
}
|
||||
}
|
||||
@@ -144,13 +144,13 @@ func DescribeInSF(fn func(d *StructuredDescriber), format string) string {
|
||||
}
|
||||
|
||||
// Describe adds all types of argument to d.output.
|
||||
func (d *StructuredDescriber) Describe(name string, arg interface{}) {
|
||||
func (d *StructuredDescriber) Describe(name string, arg any) {
|
||||
d.output[name] = arg
|
||||
}
|
||||
|
||||
// DescribeMetadata describes standard object metadata.
|
||||
func (d *StructuredDescriber) DescribeMetadata(metadata metav1.ObjectMeta) {
|
||||
metadataInfo := make(map[string]interface{})
|
||||
metadataInfo := make(map[string]any)
|
||||
metadataInfo["name"] = metadata.Name
|
||||
metadataInfo["namespace"] = metadata.Namespace
|
||||
metadataInfo["labels"] = metadata.Labels
|
||||
|
||||
@@ -106,17 +106,17 @@ func TestDescriber_DescribeSlice(t *testing.T) {
|
||||
func TestStructuredDescriber_JSONEncode(t *testing.T) {
|
||||
testcases := []struct {
|
||||
name string
|
||||
inputMap map[string]interface{}
|
||||
inputMap map[string]any
|
||||
expect string
|
||||
}{
|
||||
{
|
||||
name: "invalid json",
|
||||
inputMap: map[string]interface{}{},
|
||||
inputMap: map[string]any{},
|
||||
expect: "{}\n",
|
||||
},
|
||||
{
|
||||
name: "valid json",
|
||||
inputMap: map[string]interface{}{"k1": "v1"},
|
||||
inputMap: map[string]any{"k1": "v1"},
|
||||
expect: `{
|
||||
"k1": "v1"
|
||||
}
|
||||
@@ -148,8 +148,8 @@ func TestStructuredDescriber_DescribeMetadata(t *testing.T) {
|
||||
"annotation-2": "v2",
|
||||
},
|
||||
}
|
||||
expect := map[string]interface{}{
|
||||
"metadata": map[string]interface{}{
|
||||
expect := map[string]any{
|
||||
"metadata": map[string]any{
|
||||
"name": "test",
|
||||
"namespace": "test-ns",
|
||||
"labels": map[string]string{
|
||||
|
||||
Reference in New Issue
Block a user