Skip to content

Commit

Permalink
core: respect LIMA_SSH_PORT_FORWARDER env var
Browse files Browse the repository at this point in the history
Signed-off-by: Abiola Ibrahim <[email protected]>
  • Loading branch information
abiosoft committed Feb 3, 2025
1 parent bead6c2 commit 57321ba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 5 additions & 4 deletions environment/vm/lima/lima.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func New(host environment.HostActions) environment.VM {
var envs []string
envHome := limautil.EnvLimaHome + "=" + limaHome
envLimaInstance := envLimaInstance + "=" + config.CurrentProfile().ID
envSSHForward := "LIMA_SSH_PORT_FORWARDER=true"
envSSHForward := envLimaSSHForwarder + "=" + osutil.EnvVar(envLimaSSHForwarder).ValOr("true")
envBinary := osutil.EnvColimaBinary + "=" + osutil.Executable()
envs = append(envs, envHome, envLimaInstance, envSSHForward, envBinary)

Expand All @@ -46,9 +46,10 @@ func New(host environment.HostActions) environment.VM {
}

const (
envLimaInstance = "LIMA_INSTANCE"
lima = "lima"
limactl = limautil.LimactlCommand
envLimaInstance = "LIMA_INSTANCE"
envLimaSSHForwarder = "LIMA_SSH_PORT_FORWARDER"
lima = "lima"
limactl = limautil.LimactlCommand
)

var _ environment.VM = (*limaVM)(nil)
Expand Down
8 changes: 8 additions & 0 deletions util/osutil/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ func (e EnvVar) Val() string {
return os.Getenv(string(e))
}

// Or returns the environment variable value if set, otherwise returns val.
func (e EnvVar) ValOr(val string) string {
if v := os.Getenv(string(e)); v != "" {
return v
}
return val
}

const EnvColimaBinary = "COLIMA_BINARY"

// Executable returns the path name for the executable that started
Expand Down

0 comments on commit 57321ba

Please sign in to comment.