fix: export env for pod exec scripts
This commit is contained in:
parent
2777bbfc4b
commit
8578524e56
@ -59,8 +59,8 @@ def _build_command(command: list[str] | str, env: dict[str, str] | None) -> list
|
|||||||
else:
|
else:
|
||||||
cmd_str = shlex.join(command)
|
cmd_str = shlex.join(command)
|
||||||
if env:
|
if env:
|
||||||
prefix = " ".join(f"{key}={shlex.quote(value)}" for key, value in env.items())
|
exports = "; ".join(f"export {key}={shlex.quote(value)}" for key, value in env.items())
|
||||||
cmd_str = f"{prefix} {cmd_str}"
|
cmd_str = f"{exports}; {cmd_str}"
|
||||||
return ["/bin/sh", "-c", cmd_str]
|
return ["/bin/sh", "-c", cmd_str]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -60,7 +60,7 @@ class HangingStream(DummyStream):
|
|||||||
def test_build_command_wraps_env() -> None:
|
def test_build_command_wraps_env() -> None:
|
||||||
cmd = _build_command(["echo", "hello"], {"FOO": "bar"})
|
cmd = _build_command(["echo", "hello"], {"FOO": "bar"})
|
||||||
assert cmd[0] == "/bin/sh"
|
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:
|
def test_exec_returns_output(monkeypatch) -> None:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user