Skip to content

Commit 4d899ed

Browse files
authored
Merge pull request #1166 from piotr-kubiak/megre-args
Allow merging of args in both list and dict syntax
2 parents 7d75337 + f9489af commit 4d899ed

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

newsfragments/1163.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fixed error when merging args in list and dict syntax

podman_compose.py

+3
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,9 @@ def normalize_service(service, sub_dir=""):
16071607
for k, v in build["additional_contexts"].items():
16081608
new_additional_contexts.append(f"{k}={v}")
16091609
build["additional_contexts"] = new_additional_contexts
1610+
if "build" in service and "args" in service["build"]:
1611+
if isinstance(build["args"], dict):
1612+
build["args"] = norm_as_list(build["args"])
16101613
for key in ("command", "entrypoint"):
16111614
if key in service:
16121615
if isinstance(service[key], str):

tests/unit/test_can_merge_build.py

+10
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ class TestCanMergeBuild(unittest.TestCase):
6868
{"build": {"dockerfile": "./dockerfile-1", "args": ["ENV2=2"]}},
6969
{"build": {"dockerfile": "./dockerfile-1", "args": ["ENV1=1", "ENV2=2"]}},
7070
),
71+
(
72+
{"build": {"dockerfile": "./dockerfile-1", "args": {"ENV1": "1"}}},
73+
{"build": {"dockerfile": "./dockerfile-2", "args": {"ENV2": "2"}}},
74+
{"build": {"dockerfile": "./dockerfile-2", "args": ["ENV1=1", "ENV2=2"]}},
75+
),
76+
(
77+
{"build": {"dockerfile": "./dockerfile-1", "args": ["ENV1=1"]}},
78+
{"build": {"dockerfile": "./dockerfile-2", "args": {"ENV2": "2"}}},
79+
{"build": {"dockerfile": "./dockerfile-2", "args": ["ENV1=1", "ENV2=2"]}},
80+
),
7181
])
7282
def test_parse_compose_file_when_multiple_composes(self, input, override, expected):
7383
compose_test_1 = {"services": {"test-service": input}}

0 commit comments

Comments
 (0)