Improve error message if driver binary not available

This change provide more information which exact binary for
particular driver is missing in PATH

Signed-off-by: Alexander Kanevskiy <kad@linux.intel.com>
This commit is contained in:
Alexander Kanevskiy
2016-10-28 15:18:26 +03:00
parent 802c6a1bee
commit be4aed9528
2 changed files with 5 additions and 4 deletions

View File

@@ -11,11 +11,11 @@ func TestCreateRm(t *testing.T) {
defer test.TearDown()
test.Run("non-existent driver fails", func() {
test.Machine("create -d bogus bogus").Should().Fail(`Driver "bogus" not found. Do you have the plugin binary accessible in your PATH?`)
test.Machine("create -d bogus bogus").Should().Fail(`Driver "bogus" not found. Do you have the plugin binary "docker-machine-driver-bogus" accessible in your PATH?`)
})
test.Run("non-existent driver fails", func() {
test.Machine("create -d bogus bogus").Should().Fail(`Driver "bogus" not found. Do you have the plugin binary accessible in your PATH?`)
test.Machine("create -d bogus bogus").Should().Fail(`Driver "bogus" not found. Do you have the plugin binary "docker-machine-driver-bogus" accessible in your PATH?`)
})
test.Run("create with no name fails", func() {

View File

@@ -85,10 +85,11 @@ type Executor struct {
type ErrPluginBinaryNotFound struct {
driverName string
driverPath string
}
func (e ErrPluginBinaryNotFound) Error() string {
return fmt.Sprintf("Driver %q not found. Do you have the plugin binary accessible in your PATH?", e.driverName)
return fmt.Sprintf("Driver %q not found. Do you have the plugin binary %q accessible in your PATH?", e.driverName, e.driverPath)
}
// driverPath finds the path of a driver binary by its name.
@@ -114,7 +115,7 @@ func NewPlugin(driverName string) (*Plugin, error) {
driverPath := driverPath(driverName)
binaryPath, err := exec.LookPath(driverPath)
if err != nil {
return nil, ErrPluginBinaryNotFound{driverName}
return nil, ErrPluginBinaryNotFound{driverName, driverPath}
}
log.Debugf("Found binary path at %s", binaryPath)