mirror of
https://github.com/containers/podman-compose.git
synced 2025-06-05 20:46:47 +02:00
add code implementing build value merge
Signed-off-by: Sergei Biriukov <svbiriukov@gmail.com>
This commit is contained in:
parent
221cf14501
commit
a0005db474
@ -1291,6 +1291,20 @@ def clone(value):
|
|||||||
return value.copy() if is_list(value) or is_dict(value) else value
|
return value.copy() if is_list(value) or is_dict(value) else value
|
||||||
|
|
||||||
|
|
||||||
|
def parse_build(build):
|
||||||
|
build_parsed = {}
|
||||||
|
if is_str(build):
|
||||||
|
build_parsed["context"] = build
|
||||||
|
elif is_dict(build):
|
||||||
|
if "context" in build:
|
||||||
|
build_parsed["context"] = build["context"]
|
||||||
|
if "dockerfile" in build:
|
||||||
|
build_parsed["dockerfile"] = build["dockerfile"]
|
||||||
|
else:
|
||||||
|
raise ValueError(f"invalid type of build value [{type(build)}]")
|
||||||
|
return build_parsed
|
||||||
|
|
||||||
|
|
||||||
def rec_merge_one(target, source):
|
def rec_merge_one(target, source):
|
||||||
"""
|
"""
|
||||||
update target from source recursively
|
update target from source recursively
|
||||||
@ -1299,11 +1313,21 @@ def rec_merge_one(target, source):
|
|||||||
for key, value in source.items():
|
for key, value in source.items():
|
||||||
if key in target:
|
if key in target:
|
||||||
continue
|
continue
|
||||||
|
if key == "build":
|
||||||
|
target[key] = parse_build(value)
|
||||||
|
else:
|
||||||
target[key] = clone(value)
|
target[key] = clone(value)
|
||||||
done.add(key)
|
done.add(key)
|
||||||
for key, value in target.items():
|
for key, value in target.items():
|
||||||
if key in done:
|
if key in done:
|
||||||
continue
|
continue
|
||||||
|
if key == "build":
|
||||||
|
target_parsed = parse_build(value)
|
||||||
|
source_parsed = {}
|
||||||
|
if key in source:
|
||||||
|
source_parsed = parse_build(source[key])
|
||||||
|
target["build"] = {**target_parsed, **source_parsed}
|
||||||
|
continue
|
||||||
if key not in source:
|
if key not in source:
|
||||||
continue
|
continue
|
||||||
value2 = source[key]
|
value2 = source[key]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user