@@ -76,23 +76,20 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
7676 return fmt .Errorf ("list volumes: %w" , err )
7777 }
7878
79- if resp .Items == nil || len (* resp .Items ) == 0 {
80- projectLabel , err := projectname .GetProjectName (ctx , params .Printer , params .CliVersion , cmd )
81- if err != nil {
82- params .Printer .Debug (print .ErrorLevel , "get project name: %v" , err )
83- projectLabel = model .ProjectId
84- }
85- params .Printer .Info ("No volumes found for project %q\n " , projectLabel )
86- return nil
79+ items := resp .GetItems ()
80+
81+ projectLabel , err := projectname .GetProjectName (ctx , params .Printer , params .CliVersion , cmd )
82+ if err != nil {
83+ params .Printer .Debug (print .ErrorLevel , "get project name: %v" , err )
84+ projectLabel = model .ProjectId
8785 }
8886
8987 // Truncate output
90- items := * resp .Items
9188 if model .Limit != nil && len (items ) > int (* model .Limit ) {
9289 items = items [:* model .Limit ]
9390 }
9491
95- return outputResult (params .Printer , model .OutputFormat , items )
92+ return outputResult (params .Printer , model .OutputFormat , projectLabel , items )
9693 },
9794 }
9895 configureFlags (cmd )
@@ -137,8 +134,12 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli
137134 return req
138135}
139136
140- func outputResult (p * print.Printer , outputFormat string , volumes []iaas.Volume ) error {
137+ func outputResult (p * print.Printer , outputFormat , projectLabel string , volumes []iaas.Volume ) error {
141138 return p .OutputResult (outputFormat , volumes , func () error {
139+ if len (volumes ) == 0 {
140+ p .Outputf ("No volumes found for project %q\n " , projectLabel )
141+ return nil
142+ }
142143 table := tables .NewTable ()
143144 table .SetHeader ("ID" , "Name" , "Status" , "Server" , "Availability Zone" , "Size (GB)" )
144145
0 commit comments