diff --git a/pkg/store/instance_windows.go b/pkg/store/instance_windows.go index 85d5e1896dc..208bbfb8155 100644 --- a/pkg/store/instance_windows.go +++ b/pkg/store/instance_windows.go @@ -5,7 +5,6 @@ package store import ( "fmt" - "os/exec" "regexp" "strings" @@ -26,7 +25,7 @@ func inspectStatus(instDir string, inst *Instance, y *limayaml.LimaYAML) { inst.SSHLocalPort = 22 if inst.Status == StatusRunning { - sshAddr, err := getWslSSHAddress(inst.Name) + sshAddr, err := GetSSHAddress(inst.Name) if err == nil { inst.SSHAddress = sshAddr } else { @@ -118,21 +117,5 @@ func GetWslStatus(instName string) (string, error) { } func GetSSHAddress(instName string) (string, error) { - return getWslSSHAddress(instName) -} - -// GetWslSSHAddress runs a hostname command to get the IP from inside of a wsl2 VM. -// -// Expected output (whitespace preserved, [] for optional): -// PS > wsl -d bash -c hostname -I | cut -d' ' -f1 -// 168.1.1.1 [10.0.0.1] -func getWslSSHAddress(instName string) (string, error) { - distroName := "lima-" + instName - cmd := exec.Command("wsl.exe", "-d", distroName, "bash", "-c", `hostname -I | cut -d ' ' -f1`) - out, err := cmd.CombinedOutput() - if err != nil { - return "", fmt.Errorf("failed to get hostname for instance %q, err: %w (out=%q)", instName, err, string(out)) - } - - return strings.TrimSpace(string(out)), nil + return "127.0.0.1", nil }