Skip to content

Commit

Permalink
Merge pull request #2349 from hashicorp/f-node-status-drivers
Browse files Browse the repository at this point in the history
Node-status displays drivers
  • Loading branch information
dadgar committed Feb 23, 2017
2 parents 2757c8e + 22969c0 commit ad64573
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions command/node_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,26 @@ func (c *NodeStatusCommand) Run(args []string) int {
return c.formatNode(client, node)
}

func nodeDrivers(n *api.Node) []string {
var drivers []string
for k, v := range n.Attributes {
// driver.docker = 1
parts := strings.Split(k, ".")
if len(parts) != 2 {
continue
} else if parts[0] != "driver" {
continue
} else if v != "1" {
continue
}

drivers = append(drivers, parts[1])
}

sort.Strings(drivers)
return drivers
}

func (c *NodeStatusCommand) formatNode(client *api.Client, node *api.Node) int {
// Format the header output
basic := []string{
Expand All @@ -293,6 +313,7 @@ func (c *NodeStatusCommand) formatNode(client *api.Client, node *api.Node) int {
fmt.Sprintf("DC|%s", node.Datacenter),
fmt.Sprintf("Drain|%v", node.Drain),
fmt.Sprintf("Status|%s", node.Status),
fmt.Sprintf("Drivers|%s", strings.Join(nodeDrivers(node), ",")),
}

if c.short {
Expand Down

0 comments on commit ad64573

Please sign in to comment.