executor: Allow inheriting env vars if on host or in Docker
Created by: mrnugget
When executing src
as part of a batch spec execution we need PATH
and HOME
to be set so that we can create temp/caching directories and
find git
in the PATH
.
This works without anything from our side when executing src
inside
Firecracker since ignite exec
will SSH into the VM and env vars get.
But when executing src
on the host (as is the case when running the
executor on macOS) then its environment only contains the values we set,
since that's how Go's exec.Command
works: if cmd.Env
is nil then the
command inherits the environment, otherwise only the given values are
set.
What this PR attempts is to introduce an InheritLocalEnv
option that
contains a list of environment variables that the given command should
inherit from its environment, but only outside Firecracker.
That exception makes the code a bit ugly, since there's shared code between the Docker and the Firecracker runner and I had to introduce an exception.
But I'm also not sure how to not make it a special case.
Ideas welcome!