Stop handing StackPilot's own settings to the stacks it deploys (0.66.3)
docker compose ran with StackPilot's whole environment, and compose
resolves ${VAR} from the calling environment before a stack's own .env.
A stack whose compose file says SECRET_KEY: ${SECRET_KEY} therefore ran
with StackPilot's SECRET_KEY instead of the one in its .env — and with
its own again whenever it was started from a shell. AnsiblePilot hit
exactly this: credentials saved under one key became unreadable under
the other, twice.
config.child_env() is os.environ minus every StackPilot setting
(SECRET_KEY, DATA_DIR, STACKS_DIR, PORT, ...); the docker CLI and git
subprocesses now get that instead.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
34458c702c
commit
052a85067b
7 files changed
+44
-7
No files matched your search
@@ -202,6 +202,21 @@ def test_compose_runs_against_our_config_not_the_home_directory(svc):
|
||||
assert svc.cli_env()["DOCKER_CONFIG"] == svc.docker_config_dir()
|
||||
|
||||
|
||||
def test_compose_does_not_hand_our_settings_to_the_stacks(svc, monkeypatch):
|
||||
"""Compose interpolates ${SECRET_KEY} from this environment before the
|
||||
stack's .env — a stack must never run with StackPilot's own key."""
|
||||
monkeypatch.setenv("SECRET_KEY", "stackpilots-own-key")
|
||||
monkeypatch.setenv("data_dir", "/lowercase/still/ours")
|
||||
monkeypatch.setenv("SOME_UNRELATED_VAR", "kept")
|
||||
env = svc.cli_env()
|
||||
assert "SECRET_KEY" not in env
|
||||
assert "STACKS_DIR" not in env
|
||||
assert "data_dir" not in env
|
||||
# Everything else the docker CLI may rely on is still passed through.
|
||||
assert env["SOME_UNRELATED_VAR"] == "kept"
|
||||
assert env["PATH"] == os.environ["PATH"]
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Through the API
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
Reference in new issue
Block a user