(ctx context.Context, app string, paginationReq pagination.Request)
| 17 | ) |
| 18 | |
| 19 | func 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 | } |
no test coverage detected