-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathterminal.go
39 lines (29 loc) · 1.19 KB
/
terminal.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
package main
import (
"fmt"
"os"
"github.com/olekukonko/tablewriter"
)
func (tctl *tctl) RenderToTerminal(vminsertUrls []VminsertData, vmselectUrls []VmselectData) {
tctl.logger.Debug("Generating terminal output")
vminsertTenant := [][]string{}
vmselectTenant := [][]string{}
for _, data := range vminsertUrls {
vminsertTenant = append(vminsertTenant, []string{"vminsert", fmt.Sprintf("%d", data.AccountId), fmt.Sprintf("%d", data.ProjectId), data.PrometheusUrl, data.InfluxDbUrl})
}
for _, data := range vmselectUrls {
vmselectTenant = append(vmselectTenant, []string{"vmselect", fmt.Sprintf("%d", data.AccountId), fmt.Sprintf("%d", data.ProjectId), data.PrometheusUrl, data.InfluxDbUrl})
}
bulkData := append(vminsertTenant, vmselectTenant...)
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"Component", "accountID", "projectID", "Prometheus URL", "InfluxDB URL"})
table.SetAutoMergeCellsByColumnIndex([]int{0, 1})
table.SetRowLine(true)
table.SetAlignment(tablewriter.ALIGN_LEFT)
table.SetAutoWrapText(true)
table.SetAutoFormatHeaders(true)
table.SetNoWhiteSpace(false)
table.AppendBulk(bulkData)
table.Render()
tctl.logger.Debug("Generated terminal output")
}