From bf59d39587ee586cc68acc388407a27c6aba1d22 Mon Sep 17 00:00:00 2001 From: jjanik <11janci@seznam.cz> Date: Sun, 14 Jun 2020 14:52:07 +0200 Subject: [PATCH] fix host IP for virtualbox --- pkg/minikube/cluster/ip.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/minikube/cluster/ip.go b/pkg/minikube/cluster/ip.go index 1b42cce14198..892a0d5ece82 100644 --- a/pkg/minikube/cluster/ip.go +++ b/pkg/minikube/cluster/ip.go @@ -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(`(?sm)Name:\s*` + iface + `\s*$.+?IPAddress:\s*(\S+)`) ip := re.FindStringSubmatch(string(ipList))[1] return net.ParseIP(ip), nil case driver.Parallels: