MCPcopy Create free account
hub / github.com/Scalingo/cli / ListBackups

Function ListBackups

db/backups.go:17–40  ·  view source on GitHub ↗
(ctx context.Context, app, addon string)

Source from the content-addressed store, hash-verified

15)
16
17func 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}
41func formatBackupStatus(status scalingo.BackupStatus) string {
42 switch status {
43 case scalingo.BackupStatusScheduled:

Callers 1

backups.goFile · 0.92

Calls 3

ScalingoClientFunction · 0.92
formatBackupStatusFunction · 0.85
RenderMethod · 0.65

Tested by

no test coverage detected