(ctx context.Context, app, addon string)
| 15 | ) |
| 16 | |
| 17 | func ListBackups(ctx context.Context, app, addon string) error { |
| 18 | client, err := config.ScalingoClient(ctx) |
| 19 | if err != nil { |
| 20 | return errors.Wrapf(ctx, err, "fail to get Scalingo client") |
| 21 | } |
| 22 | backups, err := client.BackupList(ctx, app, addon) |
| 23 | if err != nil { |
| 24 | return errors.Wrapf(ctx, err, "fail to list backups") |
| 25 | } |
| 26 | |
| 27 | t := tablewriter.NewWriter(os.Stdout) |
| 28 | t.Header([]string{"ID", "Created At", "Size", "Status"}) |
| 29 | |
| 30 | for _, backup := range backups { |
| 31 | t.Append([]string{ |
| 32 | backup.ID, |
| 33 | backup.CreatedAt.Format(time.RFC1123), |
| 34 | humanize.Bytes(backup.Size), |
| 35 | formatBackupStatus(backup.Status), |
| 36 | }) |
| 37 | } |
| 38 | t.Render() |
| 39 | return nil |
| 40 | } |
| 41 | func formatBackupStatus(status scalingo.BackupStatus) string { |
| 42 | switch status { |
| 43 | case scalingo.BackupStatusScheduled: |
no test coverage detected