Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow merging of args in both list and dict syntax #1166

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/1163.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fixed error when merging args in list and dict syntax
3 changes: 3 additions & 0 deletions podman_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -1607,6 +1607,9 @@ def normalize_service(service, sub_dir=""):
for k, v in build["additional_contexts"].items():
new_additional_contexts.append(f"{k}={v}")
build["additional_contexts"] = new_additional_contexts
if "build" in service and "args" in service["build"]:
if isinstance(build["args"], dict):
build["args"] = norm_as_list(build["args"])
for key in ("command", "entrypoint"):
if key in service:
if isinstance(service[key], str):
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/test_can_merge_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ class TestCanMergeBuild(unittest.TestCase):
{"build": {"dockerfile": "./dockerfile-1", "args": ["ENV2=2"]}},
{"build": {"dockerfile": "./dockerfile-1", "args": ["ENV1=1", "ENV2=2"]}},
),
(
{"build": {"dockerfile": "./dockerfile-1", "args": {"ENV1": "1"}}},
{"build": {"dockerfile": "./dockerfile-2", "args": {"ENV2": "2"}}},
{"build": {"dockerfile": "./dockerfile-2", "args": ["ENV1=1", "ENV2=2"]}},
),
(
{"build": {"dockerfile": "./dockerfile-1", "args": ["ENV1=1"]}},
{"build": {"dockerfile": "./dockerfile-2", "args": {"ENV2": "2"}}},
{"build": {"dockerfile": "./dockerfile-2", "args": ["ENV1=1", "ENV2=2"]}},
),
])
def test_parse_compose_file_when_multiple_composes(self, input, override, expected):
compose_test_1 = {"services": {"test-service": input}}
Expand Down
Loading