1
0
mirror of https://github.com/docker/docs.git synced 2026-11-05 00:14:17 +03:00
Files
docs/commands/active.go
David Gageot c64af2918e Default template for ls command
Signed-off-by: David Gageot <david@gageot.net>
2015-12-28 16:18:30 +01:00

36 lines
624 B
Go

package commands
import (
"errors"
"fmt"
"github.com/docker/machine/libmachine"
"github.com/docker/machine/libmachine/persist"
)
var (
errNoActiveHost = errors.New("No active host found")
)
func cmdActive(c CommandLine, api libmachine.API) error {
if len(c.Args()) > 0 {
return ErrTooManyArguments
}
hosts, hostsInError, err := persist.LoadAllHosts(api)
if err != nil {
return fmt.Errorf("Error getting active host: %s", err)
}
items := getHostListItems(hosts, hostsInError)
for _, item := range items {
if item.ActiveHost {
fmt.Println(item.Name)
return nil
}
}
return errNoActiveHost
}