forked from extern/podman-compose
add test case for when build is a complex dictionary
Signed-off-by: Sergei Biriukov <svbiriukov@gmail.com>
This commit is contained in:
parent
a0005db474
commit
8c66b1cda7
@ -1296,10 +1296,7 @@ def parse_build(build):
|
|||||||
if is_str(build):
|
if is_str(build):
|
||||||
build_parsed["context"] = build
|
build_parsed["context"] = build
|
||||||
elif is_dict(build):
|
elif is_dict(build):
|
||||||
if "context" in build:
|
build_parsed = build
|
||||||
build_parsed["context"] = build["context"]
|
|
||||||
if "dockerfile" in build:
|
|
||||||
build_parsed["dockerfile"] = build["dockerfile"]
|
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"invalid type of build value [{type(build)}]")
|
raise ValueError(f"invalid type of build value [{type(build)}]")
|
||||||
return build_parsed
|
return build_parsed
|
||||||
@ -1326,7 +1323,7 @@ def rec_merge_one(target, source):
|
|||||||
source_parsed = {}
|
source_parsed = {}
|
||||||
if key in source:
|
if key in source:
|
||||||
source_parsed = parse_build(source[key])
|
source_parsed = parse_build(source[key])
|
||||||
target["build"] = {**target_parsed, **source_parsed}
|
target["build"] = rec_merge_one(target_parsed, source_parsed)
|
||||||
continue
|
continue
|
||||||
if key not in source:
|
if key not in source:
|
||||||
continue
|
continue
|
||||||
|
@ -40,6 +40,21 @@ test_cases = [
|
|||||||
{"build": {"dockerfile": "./compose-2.yaml", "context": "./dir-2"}},
|
{"build": {"dockerfile": "./compose-2.yaml", "context": "./dir-2"}},
|
||||||
{"build": {"dockerfile": "./compose-2.yaml", "context": "./dir-2"}},
|
{"build": {"dockerfile": "./compose-2.yaml", "context": "./dir-2"}},
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
{"build": {"dockerfile": "./compose-1.yaml"}},
|
||||||
|
{"build": {"dockerfile": "./compose-2.yaml", "args": ["ENV1=1"]}},
|
||||||
|
{"build": {"dockerfile": "./compose-2.yaml", "args": ["ENV1=1"]}},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
{"build": {"dockerfile": "./compose-2.yaml", "args": ["ENV1=1"]}},
|
||||||
|
{"build": {"dockerfile": "./compose-1.yaml"}},
|
||||||
|
{"build": {"dockerfile": "./compose-1.yaml", "args": ["ENV1=1"]}},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
{"build": {"dockerfile": "./compose-2.yaml", "args": ["ENV1=1"]}},
|
||||||
|
{"build": {"dockerfile": "./compose-1.yaml", "args": ["ENV2=2"]}},
|
||||||
|
{"build": {"dockerfile": "./compose-1.yaml", "args": ["ENV1=1", "ENV2=2"]}},
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user