mirror of
https://github.com/containers/podman-compose.git
synced 2025-01-23 22:39:04 +01:00
Allow config to merge strings and lists in command and entrypoint
Signed-off-by: Sergei Biriukov <svbiriukov@gmail.com>
This commit is contained in:
parent
1ffd24dcf9
commit
517aeba330
@ -61,6 +61,15 @@ def is_list(list_object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def is_list_of_str(list_of_str_object):
|
||||||
|
if is_list(list_of_str_object):
|
||||||
|
for element in list_of_str_object:
|
||||||
|
if not is_str(element):
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
# identity filter
|
# identity filter
|
||||||
def filteri(a):
|
def filteri(a):
|
||||||
return filter(lambda i: i, a)
|
return filter(lambda i: i, a)
|
||||||
@ -1307,14 +1316,25 @@ def rec_merge_one(target, source):
|
|||||||
if key not in source:
|
if key not in source:
|
||||||
continue
|
continue
|
||||||
value2 = source[key]
|
value2 = source[key]
|
||||||
if key == "command":
|
if key in ("command", "entrypoint"):
|
||||||
target[key] = clone(value2)
|
if not is_str(value) and not is_list_of_str(value):
|
||||||
|
raise ValueError(
|
||||||
|
f"can't merge value of [{key}]: must be a string or a list of strings"
|
||||||
|
)
|
||||||
|
if not is_str(value2) and not is_list_of_str(value2):
|
||||||
|
raise ValueError(
|
||||||
|
f"can't merge value of [{key}]: must be a string or a list of strings"
|
||||||
|
)
|
||||||
|
if is_str(value2):
|
||||||
|
target[key] = value2.split(" ")
|
||||||
|
else:
|
||||||
|
target[key] = clone(value2)
|
||||||
continue
|
continue
|
||||||
if not isinstance(value2, type(value)):
|
if not isinstance(value2, type(value)):
|
||||||
value_type = type(value)
|
value_type = type(value)
|
||||||
value2_type = type(value2)
|
value2_type = type(value2)
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"can't merge value of {key} of type {value_type} and {value2_type}"
|
f"can't merge value of [{key}] of type {value_type} and {value2_type}"
|
||||||
)
|
)
|
||||||
if is_list(value2):
|
if is_list(value2):
|
||||||
if key == "volumes":
|
if key == "volumes":
|
||||||
|
Loading…
Reference in New Issue
Block a user