From bdf452b994ebf80fd057717f67cb9e3b5b58af5a Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Thu, 20 Oct 2016 17:36:34 -0700 Subject: [PATCH] Output Node meta in verbose mode --- command/node_status.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/command/node_status.go b/command/node_status.go index 710b506c68be..6dc28aa2def7 100644 --- a/command/node_status.go +++ b/command/node_status.go @@ -359,6 +359,7 @@ func (c *NodeStatusCommand) formatNode(client *api.Client, node *api.Node) int { if c.verbose { c.formatAttributes(node) + c.formatMeta(node) } return 0 @@ -382,6 +383,24 @@ func (c *NodeStatusCommand) formatAttributes(node *api.Node) { c.Ui.Output(formatKV(attributes)) } +func (c *NodeStatusCommand) formatMeta(node *api.Node) { + // Print the meta + keys := make([]string, 0, len(node.Meta)) + for k := range node.Meta { + keys = append(keys, k) + } + sort.Strings(keys) + + var meta []string + for _, k := range keys { + if k != "" { + meta = append(meta, fmt.Sprintf("%s|%s", k, node.Meta[k])) + } + } + c.Ui.Output(c.Colorize().Color("\n[bold]Meta[reset]")) + c.Ui.Output(formatKV(meta)) +} + func (c *NodeStatusCommand) printCpuStats(hostStats *api.HostStats) { l := len(hostStats.CPU) for i, cpuStat := range hostStats.CPU {