Rename HostState struct to HostListItem

Signed-off-by: Guillaume Giamarchi <guillaume.giamarchi@gmail.com>
This commit is contained in:
Guillaume Giamarchi 2014-12-12 01:44:34 +01:00
parent 1547a48dde
commit 8797ca2d50
2 changed files with 9 additions and 9 deletions

View File

@ -116,7 +116,7 @@ func (cli *DockerCli) CmdLs(args ...string) error {
wg := sync.WaitGroup{}
hostStateList := []HostState{}
hostListItem := []HostListItem{}
for _, host := range hostList {
host := host
@ -145,7 +145,7 @@ func (cli *DockerCli) CmdLs(args ...string) error {
host.Name, err)
}
hostStateList = append(hostStateList, HostState{
hostListItem = append(hostListItem, HostListItem{
Name: host.Name,
Active: isActive,
DriverName: host.Driver.DriverName(),
@ -160,9 +160,9 @@ func (cli *DockerCli) CmdLs(args ...string) error {
wg.Wait()
sort.Sort(HostStateByName(hostStateList))
sort.Sort(HostListItemByName(hostListItem))
for _, hostState := range hostStateList {
for _, hostState := range hostListItem {
activeString := ""
if hostState.Active {
activeString = "*"

10
host.go
View File

@ -26,7 +26,7 @@ type Host struct {
storePath string
}
type HostState struct {
type HostListItem struct {
Name string
Active bool
DriverName string
@ -34,17 +34,17 @@ type HostState struct {
URL string
}
type HostStateByName []HostState
type HostListItemByName []HostListItem
func (h HostStateByName) Len() int {
func (h HostListItemByName) Len() int {
return len(h)
}
func (h HostStateByName) Swap(i, j int) {
func (h HostListItemByName) Swap(i, j int) {
h[i], h[j] = h[j], h[i]
}
func (h HostStateByName) Less(i, j int) bool {
func (h HostListItemByName) Less(i, j int) bool {
return strings.ToLower(h[i].Name) < strings.ToLower(h[j].Name)
}