@@ -72,23 +72,21 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
7272 if err != nil {
7373 return fmt .Errorf ("get backups: %w" , err )
7474 }
75- if resp .Items == nil || len (* resp .Items ) == 0 {
76- projectLabel , err := projectname .GetProjectName (ctx , params .Printer , params .CliVersion , cmd )
77- if err != nil {
78- params .Printer .Debug (print .ErrorLevel , "get project name: %v" , err )
79- projectLabel = model .ProjectId
80- }
81- params .Printer .Info ("No backups found for project %s\n " , projectLabel )
82- return nil
75+
76+ backups := resp .GetItems ()
77+
78+ projectLabel , err := projectname .GetProjectName (ctx , params .Printer , params .CliVersion , cmd )
79+ if err != nil {
80+ params .Printer .Debug (print .ErrorLevel , "get project name: %v" , err )
81+ projectLabel = model .ProjectId
8382 }
84- backups := * resp .Items
8583
8684 // Truncate output
8785 if model .Limit != nil && len (backups ) > int (* model .Limit ) {
8886 backups = backups [:* model .Limit ]
8987 }
9088
91- return outputResult (params .Printer , model .OutputFormat , backups )
89+ return outputResult (params .Printer , model .OutputFormat , projectLabel , backups )
9290 },
9391 }
9492
@@ -137,12 +135,12 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli
137135 return req
138136}
139137
140- func outputResult (p * print.Printer , outputFormat string , backups []iaas.Backup ) error {
141- if backups == nil {
142- return fmt .Errorf ("backups is empty" )
143- }
144-
138+ func outputResult (p * print.Printer , outputFormat , projectLabel string , backups []iaas.Backup ) error {
145139 return p .OutputResult (outputFormat , backups , func () error {
140+ if len (backups ) == 0 {
141+ p .Outputf ("No backups found for project %s\n " , projectLabel )
142+ return nil
143+ }
146144 table := tables .NewTable ()
147145 table .SetHeader ("ID" , "NAME" , "SIZE" , "STATUS" , "SNAPSHOT ID" , "VOLUME ID" , "AVAILABILITY ZONE" , "LABELS" , "CREATED AT" , "UPDATED AT" )
148146
0 commit comments