@@ -15,6 +15,7 @@ import (
1515 "github.com/stackitcloud/stackit-cli/internal/pkg/print"
1616 "github.com/stackitcloud/stackit-cli/internal/pkg/projectname"
1717 "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client"
18+ iaasutils "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/utils"
1819 "github.com/stackitcloud/stackit-cli/internal/pkg/spinner"
1920 "github.com/stackitcloud/stackit-cli/internal/pkg/utils"
2021
@@ -79,18 +80,18 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
7980 // Get source name for label (use ID if name not available)
8081 sourceLabel := model .SourceID
8182 if model .SourceType == "volume" {
82- volume , err := apiClient . GetVolume (ctx , model .ProjectId , model .SourceID ). Execute ( )
83+ name , err := iaasutils . GetVolumeName (ctx , apiClient , model .ProjectId , model .SourceID )
8384 if err != nil {
8485 params .Printer .Debug (print .ErrorLevel , "get volume name: %v" , err )
85- } else if volume != nil && volume . Name != nil {
86- sourceLabel = * volume . Name
86+ } else if name != "" {
87+ sourceLabel = name
8788 }
8889 } else if model .SourceType == "snapshot" {
89- snapshot , err := apiClient . GetSnapshot (ctx , model .ProjectId , model .SourceID ). Execute ( )
90+ name , err := iaasutils . GetSnapshotName (ctx , apiClient , model .ProjectId , model .SourceID )
9091 if err != nil {
9192 params .Printer .Debug (print .ErrorLevel , "get snapshot name: %v" , err )
92- } else if snapshot != nil && snapshot . Name != nil {
93- sourceLabel = * snapshot . Name
93+ } else if name != "" {
94+ sourceLabel = name
9495 }
9596 }
9697
0 commit comments