Skip to content

Commit 0f2c717

Browse files
authored
Merge pull request containers#1110 from indrat/1105-service-env-vars
expand service environment_variables before adding to subs_dict
2 parents a177603 + 2aa042b commit 0f2c717

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

podman_compose.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ def rec_subs(value, subs_dict):
270270
svc_envs = {k: v for k, v in value['environment'].items() if k not in subs_dict}
271271
# we need to add `svc_envs` to the `subs_dict` so that it can evaluate the
272272
# service environment that reference to another service environment.
273-
subs_dict.update(svc_envs)
274273
svc_envs = rec_subs(svc_envs, subs_dict)
275274
subs_dict.update(svc_envs)
276275

tests/integration/test_podman_compose_env_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def test_taking_env_variables_from_env_files_from_different_directories(self):
233233
[
234234
'ZZVAR1=This value is loaded but should be overwritten\r',
235235
'ZZVAR2=This value is loaded from .env in project/ directory\r',
236-
'ZZVAR3=$ZZVAR3\r',
236+
'ZZVAR3=\r',
237237
'',
238238
],
239239
)

tests/unit/test_rec_subs.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ class TestRecSubs(unittest.TestCase):
2626
{"environment": {"non_var": "$$v1", "vx": "$non_var"}, "image": "abc:$non_var"},
2727
{"environment": {"non_var": "$v1", "vx": "$v1"}, "image": "abc:$v1"},
2828
),
29+
(
30+
"service environment with unpopulated ${VARIABLE:-default} format",
31+
{"environment": {"v100": "${v100:-low priority}", "actual-v100": "$v100"}},
32+
{"environment": {"v100": "low priority", "actual-v100": "low priority"}},
33+
),
34+
(
35+
"service environment with populated ${VARIABLE:-default} format",
36+
{"environment": {"v1": "${v1:-low priority}", "actual-v1": "$v1"}},
37+
{"environment": {"v1": "high priority", "actual-v1": "high priority"}},
38+
),
2939
# list
3040
(
3141
"Values in list are substituted",

0 commit comments

Comments
 (0)