Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ Show summary for a given account:
API token <redacted>
URL https://api.gridscale.io
Getting information about used resources…
OBJECT COUNT
Platform services 0
Servers 18
Storages 24
IP addresses 2
OBJECT COUNT CORES MEMORY (GiB) CAPACITY (GiB)
Platform services 0 - - -
Servers 18 36 72 -
Storages 24 - - 240
IP addresses 2 - - -
`,
RunE: func(cmd *cobra.Command, args []string) error {
type output struct {
Expand Down Expand Up @@ -156,14 +156,28 @@ Show summary for a given account:

out := new(bytes.Buffer)
if !rootFlags.json {
heading := []string{"object", "count"}
heading := []string{"object", "count", "cores", "memory (GiB)", "capacity (GiB)"}
var rows [][]string
for v := range ch {
if v.Err != nil {
return v.Err
}
count := v.Agg["count"].(int)
rows = append(rows, []string{v.Obj, strconv.Itoa(count)})
cores := "-"
memory := "-"
capacity := "-"

if val, ok := v.Agg["cores"]; ok {
cores = strconv.Itoa(val.(int))
}
if val, ok := v.Agg["memory"]; ok {
memory = strconv.Itoa(val.(int))
}
if val, ok := v.Agg["capacity"]; ok {
capacity = strconv.Itoa(val.(int))
}

rows = append(rows, []string{v.Obj, strconv.Itoa(count), cores, memory, capacity})
}
render.AsTable(out, heading, rows, renderOpts)
} else {
Expand Down