mirror of https://github.com/docker/docs.git
Merge pull request #2733 from dgageot/2688-run-docker-machine-from-path
Run docker-machine from the PATH for core drivers
This commit is contained in:
commit
b7fa3327cf
|
@ -88,6 +88,8 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
localbinary.CurrentBinaryIsDockerMachine = true
|
||||||
|
|
||||||
setDebugOutputLevel()
|
setDebugOutputLevel()
|
||||||
cli.AppHelpTemplate = AppHelpTemplate
|
cli.AppHelpTemplate = AppHelpTemplate
|
||||||
cli.CommandHelpTemplate = CommandHelpTemplate
|
cli.CommandHelpTemplate = CommandHelpTemplate
|
||||||
|
|
|
@ -16,6 +16,7 @@ var (
|
||||||
// Timeout where we will bail if we're not able to properly contact the
|
// Timeout where we will bail if we're not able to properly contact the
|
||||||
// plugin server.
|
// plugin server.
|
||||||
defaultTimeout = 10 * time.Second
|
defaultTimeout = 10 * time.Second
|
||||||
|
CurrentBinaryIsDockerMachine = false
|
||||||
CoreDrivers = [...]string{"amazonec2", "azure", "digitalocean",
|
CoreDrivers = [...]string{"amazonec2", "azure", "digitalocean",
|
||||||
"exoscale", "generic", "google", "hyperv", "none", "openstack",
|
"exoscale", "generic", "google", "hyperv", "none", "openstack",
|
||||||
"rackspace", "softlayer", "virtualbox", "vmwarefusion",
|
"rackspace", "softlayer", "virtualbox", "vmwarefusion",
|
||||||
|
@ -90,10 +91,19 @@ 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 accessible in your PATH?", e.driverName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// driverPath finds the path of a driver binary by its name.
|
||||||
|
// + If the driver is a core driver, there is no separate driver binary. We reuse current binary if it's `docker-machine`
|
||||||
|
// or we assume `docker-machine` is in the PATH.
|
||||||
|
// + If the driver is NOT a core driver, then the separate binary must be in the PATH and it's name must be
|
||||||
|
// `docker-machine-driver-driverName`
|
||||||
func driverPath(driverName string) string {
|
func driverPath(driverName string) string {
|
||||||
for _, coreDriver := range CoreDrivers {
|
for _, coreDriver := range CoreDrivers {
|
||||||
if coreDriver == driverName {
|
if coreDriver == driverName {
|
||||||
return os.Args[0] // "docker-machine"
|
if CurrentBinaryIsDockerMachine {
|
||||||
|
return os.Args[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
return "docker-machine"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue