Add support for env_file as objects

Fixes: https://github.com/containers/podman-compose/issues/897

Signed-off-by: Alexandre Germain <nihilivin@gmail.com>
This commit is contained in:
Alexandre Germain
2024-05-03 15:31:23 +02:00
committed by Povilas Kanapickas
parent 35cbc49160
commit b202a09501
6 changed files with 142 additions and 2 deletions

View File

@ -993,10 +993,18 @@ async def container_to_args(compose, cnt, detached=True):
for item in norm_as_list(cnt.get("dns_search", None)):
podman_args.extend(["--dns-search", item])
env_file = cnt.get("env_file", [])
if is_str(env_file):
if is_str(env_file) or is_dict(env_file):
env_file = [env_file]
for i in env_file:
i = os.path.realpath(os.path.join(dirname, i))
if is_str(i):
i = {"path": i}
path = i["path"]
required = i.get("required", True)
i = os.path.realpath(os.path.join(dirname, path))
if not os.path.exists(i):
if not required:
continue
raise ValueError("Env file at {} does not exist".format(i))
podman_args.extend(["--env-file", i])
env = norm_as_list(cnt.get("environment", {}))
for e in env: