fix: export env for pod exec scripts

This commit is contained in:
Brad Stein 2026-01-21 21:56:28 -03:00
parent 2777bbfc4b
commit 8578524e56
2 changed files with 3 additions and 3 deletions

View File

@ -59,8 +59,8 @@ def _build_command(command: list[str] | str, env: dict[str, str] | None) -> list
else:
cmd_str = shlex.join(command)
if env:
prefix = " ".join(f"{key}={shlex.quote(value)}" for key, value in env.items())
cmd_str = f"{prefix} {cmd_str}"
exports = "; ".join(f"export {key}={shlex.quote(value)}" for key, value in env.items())
cmd_str = f"{exports}; {cmd_str}"
return ["/bin/sh", "-c", cmd_str]

View File

@ -60,7 +60,7 @@ class HangingStream(DummyStream):
def test_build_command_wraps_env() -> None:
cmd = _build_command(["echo", "hello"], {"FOO": "bar"})
assert cmd[0] == "/bin/sh"
assert "FOO=bar" in cmd[2]
assert "export FOO=bar" in cmd[2]
def test_exec_returns_output(monkeypatch) -> None: