Merge pull request #1130 from nathanleclaire/fix_quiet_ls

Fix bug with quiet ls mode
This commit is contained in:
Evan Hazlett 2015-05-06 12:55:21 -07:00
commit ce0e365e10
2 changed files with 21 additions and 15 deletions

View File

@ -13,33 +13,34 @@ import (
func cmdLs(c *cli.Context) {
quiet := c.Bool("quiet")
w := tabwriter.NewWriter(os.Stdout, 5, 1, 3, ' ', 0)
if !quiet {
fmt.Fprintln(w, "NAME\tACTIVE\tDRIVER\tSTATE\tURL\tSWARM")
}
mcn := getDefaultMcn(c)
hostList, err := mcn.List()
if err != nil {
log.Fatal(err)
}
// Just print out the names if we're being quiet
if quiet {
for _, host := range hostList {
fmt.Println(host.Name)
}
return
}
swarmMasters := make(map[string]string)
swarmInfo := make(map[string]string)
w := tabwriter.NewWriter(os.Stdout, 5, 1, 3, ' ', 0)
fmt.Fprintln(w, "NAME\tACTIVE\tDRIVER\tSTATE\tURL\tSWARM")
for _, host := range hostList {
swarmOptions := host.HostOptions.SwarmOptions
if !quiet {
if swarmOptions.Master {
swarmMasters[swarmOptions.Discovery] = host.Name
}
if swarmOptions.Master {
swarmMasters[swarmOptions.Discovery] = host.Name
}
if swarmOptions.Discovery != "" {
swarmInfo[host.Name] = swarmOptions.Discovery
}
} else {
fmt.Fprintf(w, "%s\n", host.Name)
if swarmOptions.Discovery != "" {
swarmInfo[host.Name] = swarmOptions.Discovery
}
}

View File

@ -57,6 +57,11 @@ buildMachineWithOldIsoCheckUpgrade() {
[ "$status" -eq 0 ]
}
@test "$DRIVER: quiet ls" {
run machine ls -q
[[ ${output} == "$NAME" ]]
}
@test "$DRIVER: check default machine memory size" {
findMemorySize
[[ ${output} == "${DEFAULT_MEMSIZE}" ]]