mirror of https://github.com/docker/docs.git
1434-Added homebrew cask support for VMware Fusion
This aims to lookup for Vmware Fusion required binaries (vmrun and vmware-vdiskmanager) in the system path first before falling back in the default Vmware Fusion installing path. Thereby, the vmwarefusion docker-machine driver can now be used even if Vmware Fusion is not installed in its default location (with brew cask for example). Signed-off-by: Jean-Christophe Lagache <jclagache@gmail.com>
This commit is contained in:
parent
08208bd141
commit
ebbc45abea
|
@ -8,16 +8,16 @@ import (
|
|||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/docker/machine/log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/machine/log"
|
||||
)
|
||||
|
||||
var (
|
||||
vmrunbin = "/Applications/VMware Fusion.app/Contents/Library/vmrun"
|
||||
vdiskmanbin = "/Applications/VMware Fusion.app/Contents/Library/vmware-vdiskmanager"
|
||||
vmrunbin = setVmwareCmd("vmrun")
|
||||
vdiskmanbin = setVmwareCmd("vmware-vdiskmanager")
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -26,6 +26,14 @@ var (
|
|||
ErrVMRUNNotFound = errors.New("VMRUN not found")
|
||||
)
|
||||
|
||||
// detect the vmrun and vmware-vdiskmanager cmds' path if needed
|
||||
func setVmwareCmd(cmd string) string {
|
||||
if path, err := exec.LookPath(cmd); err == nil {
|
||||
return path
|
||||
}
|
||||
return filepath.Join("/Applications/VMware Fusion.app/Contents/Library/", cmd)
|
||||
}
|
||||
|
||||
func vmrun(args ...string) (string, string, error) {
|
||||
cmd := exec.Command(vmrunbin, args...)
|
||||
if os.Getenv("DEBUG") != "" {
|
||||
|
|
Loading…
Reference in New Issue