@@ -14,6 +14,7 @@ import (
1414 "github.com/stackitcloud/stackit-cli/internal/pkg/print"
1515 "github.com/stackitcloud/stackit-cli/internal/pkg/projectname"
1616 "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client"
17+ iaasUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/utils"
1718 "github.com/stackitcloud/stackit-cli/internal/pkg/spinner"
1819 "github.com/stackitcloud/stackit-cli/internal/pkg/utils"
1920
@@ -71,12 +72,10 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
7172 }
7273
7374 // Get volume name for label
74- volumeLabel := model .VolumeID
75- volume , err := apiClient .GetVolume (ctx , model .ProjectId , model .VolumeID ).Execute ()
75+ volumeLabel , err := iaasUtils .GetVolumeName (ctx , apiClient , model .ProjectId , model .VolumeID )
7676 if err != nil {
7777 params .Printer .Debug (print .ErrorLevel , "get volume name: %v" , err )
78- } else if volume != nil && volume .Name != nil {
79- volumeLabel = * volume .Name
78+ volumeLabel = model .VolumeID
8079 }
8180
8281 if ! model .AssumeYes {
@@ -105,11 +104,11 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
105104 s .Stop ()
106105 }
107106
107+ operationState := "Created"
108108 if model .Async {
109- params .Printer .Outputf ("Triggered snapshot of %q in %q. Snapshot ID: %s\n " , volumeLabel , projectLabel , utils .PtrString (resp .Id ))
110- } else {
111- params .Printer .Outputf ("Created snapshot of %q in %q. Snapshot ID: %s\n " , volumeLabel , projectLabel , utils .PtrString (resp .Id ))
109+ operationState = "Triggered creation of"
112110 }
111+ params .Printer .Outputf ("%s snapshot of %q in %q. Snapshot ID: %s\n " , operationState , volumeLabel , projectLabel , utils .PtrString (resp .Id ))
113112 return nil
114113 },
115114 }
0 commit comments