Skip to content

Commit

Permalink
fix host IP for virtualbox
Browse files Browse the repository at this point in the history
  • Loading branch information
11janci committed Jun 14, 2020
1 parent 46b5d41 commit ad179b1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/minikube/cluster/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,18 @@ func HostIP(host *host.Host) (net.IP, error) {
}
return ip, nil
case driver.VirtualBox:
out, err := exec.Command(driver.VBoxManagePath(), "showvminfo", host.Name, "--machinereadable").Output()
vBoxManageCmd := driver.VBoxManagePath()
out, err := exec.Command(vBoxManageCmd, "showvminfo", host.Name, "--machinereadable").Output()
if err != nil {
return []byte{}, errors.Wrap(err, "vboxmanage")
}
re := regexp.MustCompile(`hostonlyadapter2="(.*?)"`)
iface := re.FindStringSubmatch(string(out))[1]
ipList, err := exec.Command(driver.VBoxManagePath(), "list", "hostonlyifs").Output()
ipList, err := exec.Command(vBoxManageCmd, "list", "hostonlyifs").Output()
if err != nil {
return []byte{}, errors.Wrap(err, "Error getting VM/Host IP address")
}
re = regexp.MustCompile(`(?s)Name:\s*` + iface + `.+IPAddress:\s*(\S+)`)
re = regexp.MustCompile(`(?s)Name:\s*` + iface + `$.+?IPAddress:\s*(\S+)`)
ip := re.FindStringSubmatch(string(ipList))[1]
return net.ParseIP(ip), nil
case driver.Parallels:
Expand Down

0 comments on commit ad179b1

Please sign in to comment.