-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecs.go
66 lines (58 loc) · 1.38 KB
/
ecs.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"fmt"
"os"
"strconv"
"github.com/djw/ecs/wrapper"
"github.com/olekukonko/tablewriter"
)
func main() {
clusters := make(chan *wrapper.Cluster)
go wrapper.GetClusters(clusters)
// Print as table
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"Name", "Running", "Pending"})
table.SetColumnAlignment([]int{tablewriter.ALIGN_LEFT, tablewriter.ALIGN_RIGHT, tablewriter.ALIGN_RIGHT})
for c := range clusters {
clusterRow := []string{
c.Name,
strconv.FormatInt(int64(c.Running), 10),
strconv.FormatInt(int64(c.Pending), 10),
}
table.Rich(clusterRow, []tablewriter.Colors{
tablewriter.Colors{tablewriter.Bold},
tablewriter.Colors{tablewriter.Bold},
tablewriter.Colors{tablewriter.Bold},
})
for _, s := range c.Services {
row := []string{
" - " + s.Name,
strconv.FormatInt(int64(s.Running), 10),
strconv.FormatInt(int64(s.Pending), 10),
}
table.Rich(row, []tablewriter.Colors{
tablewriter.Colors{},
tablewriter.Colors{},
tablewriter.Colors{},
})
for _, t := range s.Tasks {
task := fmt.Sprintf(" * %d (%v -> %v)",
t.Revision,
t.DesiredStatus,
t.LastStatus,
)
row := []string{
task,
"",
"",
}
table.Rich(row, []tablewriter.Colors{
tablewriter.Colors{},
tablewriter.Colors{},
tablewriter.Colors{},
})
}
}
}
table.Render()
}