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

Function List

deployments/list.go:19–53  ·  view source on GitHub ↗
(ctx context.Context, app string, paginationReq pagination.Request)

Source from the content-addressed store, hash-verified

17)
18
19func List(ctx context.Context, app string, paginationReq pagination.Request) error {
20 c, err := config.ScalingoClient(ctx)
21 if err != nil {
22 return errors.Wrapf(ctx, err, "fail to get Scalingo client")
23 }
24
25 deployments, pagination, err := c.DeploymentListWithPagination(ctx, app, paginationReq)
26 if err != nil {
27 return errors.Wrapf(ctx, err, "fail to list the application deployments")
28 }
29
30 t := tablewriter.NewWriter(os.Stdout)
31 t.Header([]string{"ID", "Date", "Duration", "User", "Git Ref", "Status", "Image Size"})
32
33 for _, deployment := range deployments {
34 var duration string
35 if deployment.Duration != 0 {
36 d, _ := time.ParseDuration(fmt.Sprintf("%ds", deployment.Duration))
37 duration = d.String()
38 } else {
39 duration = "n/a"
40 }
41 t.Append([]string{deployment.ID,
42 deployment.CreatedAt.Format(utils.TimeFormat),
43 duration,
44 deployment.User.Username,
45 deployment.GitRef,
46 string(deployment.Status),
47 humanize.IBytes(deployment.ImageSize),
48 })
49 }
50 t.Render()
51 fmt.Fprintln(os.Stderr, io.Gray(fmt.Sprintf("Page: %d, Last Page: %d", pagination.CurrentPage, pagination.TotalPages)))
52 return nil
53}

Callers 1

deployments.goFile · 0.92

Calls 3

ScalingoClientFunction · 0.92
GrayFunction · 0.92
RenderMethod · 0.65

Tested by

no test coverage detected