Skip to content
This repository was archived by the owner on Dec 17, 2021. It is now read-only.

Commit 6e710bd

Browse files
committed
commands/ls: Simplify func attemptGetHostState
1 parent 1c05771 commit 6e710bd

File tree

1 file changed

+1
-32
lines changed

1 file changed

+1
-32
lines changed

commands/ls.go

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"github.com/docker/machine/libmachine/drivers"
1818
"github.com/docker/machine/libmachine/host"
1919
"github.com/docker/machine/libmachine/log"
20-
"github.com/docker/machine/libmachine/mcndockerclient"
2120
"github.com/docker/machine/libmachine/persist"
2221
"github.com/docker/machine/libmachine/state"
2322
"github.com/skarademir/naturalsort"
@@ -257,40 +256,10 @@ func matchesLabel(host *host.Host, labels []string) bool {
257256
// we need.
258257
func attemptGetHostState(h *host.Host, stateQueryChan chan<- HostListItem) {
259258
requestBeginning := time.Now()
260-
url := ""
261259
currentState := state.None
262-
dockerVersion := "Unknown"
263260
hostError := ""
264261

265-
url, err := h.URL()
266-
267-
// PERFORMANCE: if we have the url, it's ok to assume the host is running
268-
// This reduces the number of calls to the drivers
269-
if err == nil {
270-
if url != "" {
271-
currentState = state.Running
272-
} else {
273-
currentState, err = h.Driver.GetState()
274-
}
275-
} else {
276-
currentState, _ = h.Driver.GetState()
277-
}
278-
279-
if err == nil && url != "" {
280-
// PERFORMANCE: Reuse the url instead of asking the host again.
281-
// This reduces the number of calls to the drivers
282-
dockerHost := &mcndockerclient.RemoteDocker{
283-
HostURL: url,
284-
AuthOption: h.AuthOptions(),
285-
}
286-
dockerVersion, err = mcndockerclient.DockerVersion(dockerHost)
287-
288-
if err != nil {
289-
dockerVersion = "Unknown"
290-
} else {
291-
dockerVersion = fmt.Sprintf("v%s", dockerVersion)
292-
}
293-
}
262+
currentState, err := h.Driver.GetState()
294263

295264
if err != nil {
296265
hostError = err.Error()

0 commit comments

Comments
 (0)