Merge pull request #79 from andyz-dev/extra-log

[Enhancement] Log more information when the docker-machine command fails
This commit is contained in:
Andy Zhou 2019-06-14 07:55:36 -07:00 committed by GitHub
commit bd5d7a6268
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
package run
import (
"log"
"os"
"os/exec"
"strings"
@ -19,8 +20,16 @@ func getDockerMachineIp() (string, error) {
}
out, err := exec.Command(dockerMachinePath, "ip", machine).Output()
if err != nil {
log.Printf("Error executing 'docker-machine ip'")
if exitError, ok := err.(*exec.ExitError); ok {
log.Printf("%s", string(exitError.Stderr))
}
return "", err
}
ipStr := strings.TrimSuffix(string(out), "\n")
ipStr = strings.TrimSuffix(ipStr, "\r")
return ipStr, err
return ipStr, nil
}