@@ -67,27 +67,24 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
6767 if err != nil {
6868 return fmt .Errorf ("list server backups: %w" , err )
6969 }
70- backups := * resp .Items
71- if len (backups ) == 0 {
72- serverLabel := model .ServerId
73- // Get server name
74- if iaasApiClient , err := iaasClient .ConfigureClient (params .Printer , params .CliVersion ); err == nil {
75- serverName , err := iaasUtils .GetServerName (ctx , iaasApiClient , model .ProjectId , model .Region , model .ServerId )
76- if err != nil {
77- params .Printer .Debug (print .ErrorLevel , "get server name: %v" , err )
78- } else if serverName != "" {
79- serverLabel = serverName
80- }
70+ backups := resp .GetItems ()
71+
72+ // Get server name
73+ serverLabel := model .ServerId
74+ if iaasApiClient , err := iaasClient .ConfigureClient (params .Printer , params .CliVersion ); err == nil {
75+ serverName , err := iaasUtils .GetServerName (ctx , iaasApiClient , model .ProjectId , model .Region , model .ServerId )
76+ if err != nil {
77+ params .Printer .Debug (print .ErrorLevel , "get server name: %v" , err )
78+ } else if serverName != "" {
79+ serverLabel = serverName
8180 }
82- params .Printer .Info ("No backups found for server %s\n " , serverLabel )
83- return nil
8481 }
8582
8683 // Truncate output
8784 if model .Limit != nil && len (backups ) > int (* model .Limit ) {
8885 backups = backups [:* model .Limit ]
8986 }
90- return outputResult (params .Printer , model .OutputFormat , backups )
87+ return outputResult (params .Printer , model .OutputFormat , serverLabel , backups )
9188 },
9289 }
9390 configureFlags (cmd )
@@ -131,8 +128,12 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *serverbacku
131128 return req
132129}
133130
134- func outputResult (p * print.Printer , outputFormat string , backups []serverbackup.Backup ) error {
131+ func outputResult (p * print.Printer , outputFormat , serverLabel string , backups []serverbackup.Backup ) error {
135132 return p .OutputResult (outputFormat , backups , func () error {
133+ if len (backups ) == 0 {
134+ p .Outputf ("No backups found for server %s\n " , serverLabel )
135+ return nil
136+ }
136137 table := tables .NewTable ()
137138 table .SetHeader ("ID" , "NAME" , "SIZE (GB)" , "STATUS" , "CREATED AT" , "EXPIRES AT" , "LAST RESTORED AT" , "VOLUME BACKUPS" )
138139 for i := range backups {
0 commit comments