mirror of
https://github.com/containers/podman-compose.git
synced 2025-02-05 21:09:46 +01:00
Merge pull request #1110 from indrat/1105-service-env-vars
expand service environment_variables before adding to subs_dict
This commit is contained in:
commit
0f2c717655
@ -270,7 +270,6 @@ def rec_subs(value, subs_dict):
|
||||
svc_envs = {k: v for k, v in value['environment'].items() if k not in subs_dict}
|
||||
# we need to add `svc_envs` to the `subs_dict` so that it can evaluate the
|
||||
# service environment that reference to another service environment.
|
||||
subs_dict.update(svc_envs)
|
||||
svc_envs = rec_subs(svc_envs, subs_dict)
|
||||
subs_dict.update(svc_envs)
|
||||
|
||||
|
@ -233,7 +233,7 @@ class TestComposeEnvFile(unittest.TestCase, RunSubprocessMixin):
|
||||
[
|
||||
'ZZVAR1=This value is loaded but should be overwritten\r',
|
||||
'ZZVAR2=This value is loaded from .env in project/ directory\r',
|
||||
'ZZVAR3=$ZZVAR3\r',
|
||||
'ZZVAR3=\r',
|
||||
'',
|
||||
],
|
||||
)
|
||||
|
@ -26,6 +26,16 @@ class TestRecSubs(unittest.TestCase):
|
||||
{"environment": {"non_var": "$$v1", "vx": "$non_var"}, "image": "abc:$non_var"},
|
||||
{"environment": {"non_var": "$v1", "vx": "$v1"}, "image": "abc:$v1"},
|
||||
),
|
||||
(
|
||||
"service environment with unpopulated ${VARIABLE:-default} format",
|
||||
{"environment": {"v100": "${v100:-low priority}", "actual-v100": "$v100"}},
|
||||
{"environment": {"v100": "low priority", "actual-v100": "low priority"}},
|
||||
),
|
||||
(
|
||||
"service environment with populated ${VARIABLE:-default} format",
|
||||
{"environment": {"v1": "${v1:-low priority}", "actual-v1": "$v1"}},
|
||||
{"environment": {"v1": "high priority", "actual-v1": "high priority"}},
|
||||
),
|
||||
# list
|
||||
(
|
||||
"Values in list are substituted",
|
||||
|
Loading…
Reference in New Issue
Block a user