Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 deletions pkg/store/instance_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package store

import (
"fmt"
"os/exec"
"regexp"
"strings"

Expand All @@ -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 {
Expand Down Expand Up @@ -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 <distroName> 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
}
Loading