Skip to content

Commit

Permalink
Merge pull request #313 from achanda/attributes
Browse files Browse the repository at this point in the history
Show node attribute in node-status
  • Loading branch information
dadgar committed Oct 22, 2015
2 parents ffaacc3 + db2dd3b commit 10ae428
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions command/node_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package command

import (
"fmt"
"sort"
"strings"
)

Expand Down Expand Up @@ -103,6 +104,20 @@ func (c *NodeStatusCommand) Run(args []string) int {
return 1
}

m := node.Attributes
keys := make([]string, len(m))
for k := range m {
keys = append(keys, k)
}
sort.Strings(keys)

var attributes []string
for _, k := range keys {
if k != "" {
attributes = append(attributes, fmt.Sprintf("%s:%s", k, m[k]))
}
}

// Format the output
basic := []string{
fmt.Sprintf("ID|%s", node.ID),
Expand All @@ -111,6 +126,7 @@ func (c *NodeStatusCommand) Run(args []string) int {
fmt.Sprintf("Datacenter|%s", node.Datacenter),
fmt.Sprintf("Drain|%v", node.Drain),
fmt.Sprintf("Status|%s", node.Status),
fmt.Sprintf("Attributes|%s", strings.Join(attributes, ", ")),
}

var allocs []string
Expand Down

0 comments on commit 10ae428

Please sign in to comment.