-
Notifications
You must be signed in to change notification settings - Fork 2
/
deployment_list.go
47 lines (38 loc) · 1.1 KB
/
deployment_list.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package view
import (
"strconv"
"time"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/ecs/types"
"github.com/masaushi/ecsplorer/internal/view/ui"
"github.com/rivo/tview"
)
type DeploymentList struct {
service *types.Service
}
func NewDeploymentList(service *types.Service) *DeploymentList {
return &DeploymentList{
service: service,
}
}
func (dl *DeploymentList) Render() tview.Primitive {
page := tview.NewFlex().
SetDirection(tview.FlexRow).
AddItem(dl.table(), 0, 1, true)
return page
}
func (dl *DeploymentList) table() *tview.Table {
header := []string{"STARTED AT", "STATUS", "RUNNING TASKS", "FAILED TASKS", "TASK DEF"}
rows := make([][]string, len(dl.service.Deployments))
for i, deploy := range dl.service.Deployments {
rows[i] = make([]string, 0, len(header))
rows[i] = append(rows[i],
deploy.CreatedAt.Format(time.RFC3339),
aws.ToString(deploy.Status),
strconv.Itoa(int(deploy.RunningCount)),
strconv.Itoa(int(deploy.FailedTasks)),
aws.ToString(deploy.TaskDefinition),
)
}
return ui.CreateTable(header, rows, func(row, column int) {})
}