Skip to content

Commit e65e6c6

Browse files
committed
core: respect LIMA_SSH_PORT_FORWARDER env var
Signed-off-by: Abiola Ibrahim <[email protected]>
1 parent bead6c2 commit e65e6c6

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

environment/vm/lima/lima.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func New(host environment.HostActions) environment.VM {
3232
var envs []string
3333
envHome := limautil.EnvLimaHome + "=" + limaHome
3434
envLimaInstance := envLimaInstance + "=" + config.CurrentProfile().ID
35-
envSSHForward := "LIMA_SSH_PORT_FORWARDER=true"
35+
envSSHForward := envLimaSSHForwarder + "=" + osutil.EnvVar(envLimaSSHForwarder).ValOr("true")
3636
envBinary := osutil.EnvColimaBinary + "=" + osutil.Executable()
3737
envs = append(envs, envHome, envLimaInstance, envSSHForward, envBinary)
3838

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

4848
const (
49-
envLimaInstance = "LIMA_INSTANCE"
50-
lima = "lima"
51-
limactl = limautil.LimactlCommand
49+
envLimaInstance = "LIMA_INSTANCE"
50+
envLimaSSHForwarder = "LIMA_SSH_PORT_FORWARDER"
51+
lima = "lima"
52+
limactl = limautil.LimactlCommand
5253
)
5354

5455
var _ environment.VM = (*limaVM)(nil)

util/osutil/os.go

+8
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ func (e EnvVar) Val() string {
3131
return os.Getenv(string(e))
3232
}
3333

34+
// Or returns the environment variable value if set, otherwise returns val.
35+
func (e EnvVar) ValOr(val string) string {
36+
if v := os.Getenv(string(e)); v != "" {
37+
return v
38+
}
39+
return val
40+
}
41+
3442
const EnvColimaBinary = "COLIMA_BINARY"
3543

3644
// Executable returns the path name for the executable that started

0 commit comments

Comments
 (0)