-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrender.go
45 lines (40 loc) · 1003 Bytes
/
render.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
package app
import (
"os"
"github.com/olekukonko/tablewriter"
)
func render(containers []Container) {
data := make([][]string, 0, len(containers))
for _, c := range containers {
ready := "0"
if c.Ready() {
ready = "1"
}
data = append(data, []string{
c.Name,
ready,
c.State(),
c.RestartCol(),
c.Age(),
c.Ports,
c.Image,
c.ImagePullPolicy,
string(c.Type),
})
}
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"NAME", "READY", "STATUS", "RESTARTS", "AGE", "PORTS", "IMAGE", "PULLPOLICY", "TYPE"})
table.SetAutoWrapText(false)
table.SetAutoFormatHeaders(true)
table.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
table.SetAlignment(tablewriter.ALIGN_LEFT)
table.SetCenterSeparator("")
table.SetColumnSeparator("")
table.SetRowSeparator("")
table.SetHeaderLine(false)
//table.EnableBorder(false)
table.SetTablePadding("\t ") // pad with tabs
table.SetNoWhiteSpace(true)
table.AppendBulk(data) // Add Bulk Data
table.Render()
}