Skip to content

Commit

Permalink
core: handle everything for docker-machine within the if else
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Englund <martin@englund.nu>
  • Loading branch information
pmenglund committed Feb 22, 2017
1 parent 8ebdf4f commit 8ea2c2d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions dockertest.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,24 @@ func (r *Resource) GetPort(id string) string {
// variable DOCKER_URL, or from docker-machine if the environment variable DOCKER_MACHINE_NAME is set,
// or if neither is defined a sensible default for the operating system you are on.
func NewPool(endpoint string) (*Pool, error) {
var client *dc.Client
var err error

if endpoint == "" {
if os.Getenv("DOCKER_URL") != "" {
endpoint = os.Getenv("DOCKER_URL")
} else if os.Getenv("DOCKER_MACHINE_NAME") != "" {
client, err = dc.NewClientFromEnv()
goto error_check
client, err := dc.NewClientFromEnv()
if err != nil {
return nil, errors.Wrap(err, "")
}

return &Pool{Client: client}, nil
} else if runtime.GOOS == "windows" {
endpoint = "http://localhost:2375"
} else {
endpoint = "unix:///var/run/docker.sock"
}
}

client, err = dc.NewClient(endpoint)
error_check:
client, err := dc.NewClient(endpoint)
if err != nil {
return nil, errors.Wrap(err, "")
}
Expand Down

0 comments on commit 8ea2c2d

Please sign in to comment.