@@ -15,6 +15,7 @@ import (
1515 "github.com/stackitcloud/stackit-cli/internal/pkg/spinner"
1616 "github.com/stackitcloud/stackit-cli/internal/pkg/utils"
1717
18+ iaasutils "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/utils"
1819 "github.com/stackitcloud/stackit-sdk-go/services/iaas"
1920 "github.com/stackitcloud/stackit-sdk-go/services/iaas/wait"
2021)
@@ -51,25 +52,21 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
5152 return err
5253 }
5354
54- // Get backup details for labels
55- backup , err := apiClient .GetBackup (ctx , model .ProjectId , model .BackupId ).Execute ()
55+ backupLabel , err := iaasutils .GetBackupName (ctx , apiClient , model .ProjectId , model .BackupId )
5656 if err != nil {
5757 params .Printer .Debug (print .ErrorLevel , "get backup details: %v" , err )
5858 }
59- backupLabel := model .BackupId
60- if backup != nil && backup .Name != nil {
61- backupLabel = * backup .Name
62- }
6359
6460 // Get source details for labels
6561 var sourceLabel string
66- if backup != nil && backup .VolumeId != nil {
62+ backup , err := apiClient .GetBackup (ctx , model .ProjectId , model .BackupId ).Execute ()
63+ if err == nil && backup != nil && backup .VolumeId != nil {
6764 sourceLabel = * backup .VolumeId
68- volume , err := apiClient . GetVolume (ctx , model .ProjectId , * backup .VolumeId ). Execute ( )
65+ name , err := iaasutils . GetVolumeName (ctx , apiClient , model .ProjectId , * backup .VolumeId )
6966 if err != nil {
7067 params .Printer .Debug (print .ErrorLevel , "get volume details: %v" , err )
71- } else if volume . Name != nil {
72- sourceLabel = * volume . Name
68+ } else if name != "" {
69+ sourceLabel = name
7370 }
7471 }
7572
0 commit comments