1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #24159 from yongtang/24090-docker-node-list-hostname

Use HOSTNAME in the output of `docker node ls`
This commit is contained in:
Alexander Morozov 2016-06-30 09:28:57 -07:00 committed by GitHub
commit 0f687aafaf
2 changed files with 13 additions and 6 deletions

View file

@ -74,16 +74,12 @@ func printTable(out io.Writer, nodes []swarm.Node, info types.Info) {
// Ignore flushing errors
defer writer.Flush()
fmt.Fprintf(writer, listItemFmt, "ID", "NAME", "MEMBERSHIP", "STATUS", "AVAILABILITY", "MANAGER STATUS")
fmt.Fprintf(writer, listItemFmt, "ID", "HOSTNAME", "MEMBERSHIP", "STATUS", "AVAILABILITY", "MANAGER STATUS")
for _, node := range nodes {
name := node.Spec.Name
name := node.Description.Hostname
availability := string(node.Spec.Availability)
membership := string(node.Spec.Membership)
if name == "" {
name = node.Description.Hostname
}
reachability := ""
if node.ManagerStatus != nil {
if node.ManagerStatus.Leader {

View file

@ -5,6 +5,7 @@ package main
import (
"encoding/json"
"io/ioutil"
"strings"
"time"
"github.com/docker/docker/pkg/integration/checker"
@ -158,3 +159,13 @@ func (s *DockerSwarmSuite) TestSwarmIncompatibleDaemon(c *check.C) {
// restart for teardown
c.Assert(d.Start(), checker.IsNil)
}
// Test case for #24090
func (s *DockerSwarmSuite) TestSwarmNodeListHostname(c *check.C) {
d := s.AddDaemon(c, true, true)
// The first line should contain "HOSTNAME"
out, err := d.Cmd("node", "ls")
c.Assert(err, checker.IsNil)
c.Assert(strings.Split(out, "\n")[0], checker.Contains, "HOSTNAME")
}