mirror of
https://github.com/containers/podman-compose.git
synced 2025-04-30 12:24:36 +02:00
Normalize depends_on service property
Signed-off-by: Felix Rubio <felix@kngnt.org> Modified-by: Povilas Kanapickas <povilas@radix.lt>
This commit is contained in:
parent
973e15ba23
commit
3ba0396e7a
@ -1327,13 +1327,11 @@ def flat_deps(services, with_extends=False):
|
|||||||
if ext != name:
|
if ext != name:
|
||||||
deps.add(ServiceDependency(ext))
|
deps.add(ServiceDependency(ext))
|
||||||
continue
|
continue
|
||||||
deps_ls = srv.get("depends_on", None) or []
|
|
||||||
if isinstance(deps_ls, str):
|
# the compose file has been normalized. depends_on, if exists, can only be a dictionary
|
||||||
deps_ls = [ServiceDependency(deps_ls)]
|
# the normalization adds a "service_started" condition by default
|
||||||
elif isinstance(deps_ls, dict):
|
deps_ls = srv.get("depends_on", {})
|
||||||
deps_ls = [ServiceDependency(d) for d in deps_ls.keys()]
|
deps_ls = [ServiceDependency(k) for k, v in deps_ls.items()]
|
||||||
else:
|
|
||||||
deps_ls = [ServiceDependency(d) for d in deps_ls]
|
|
||||||
deps.update(deps_ls)
|
deps.update(deps_ls)
|
||||||
# parse link to get service name and remove alias
|
# parse link to get service name and remove alias
|
||||||
links_ls = srv.get("links", None) or []
|
links_ls = srv.get("links", None) or []
|
||||||
@ -1557,14 +1555,18 @@ def normalize_service(service, sub_dir=""):
|
|||||||
extends = {"service": extends}
|
extends = {"service": extends}
|
||||||
service["extends"] = extends
|
service["extends"] = extends
|
||||||
if "depends_on" in service:
|
if "depends_on" in service:
|
||||||
|
# deps should become a dictionary of dependencies
|
||||||
deps = service["depends_on"]
|
deps = service["depends_on"]
|
||||||
if isinstance(deps, str):
|
if isinstance(deps, str):
|
||||||
deps = [deps]
|
deps = {deps: {}}
|
||||||
if is_list(deps):
|
elif is_list(deps):
|
||||||
deps_dict = {}
|
deps = {x: {} for x in deps}
|
||||||
for d in deps:
|
|
||||||
deps_dict[d] = {'condition': 'service_started'}
|
# the dependency service_started is set by default
|
||||||
service["depends_on"] = deps_dict
|
# unless requested otherwise.
|
||||||
|
for k, v in deps.items():
|
||||||
|
v.setdefault('condition', 'service_started')
|
||||||
|
service["depends_on"] = deps
|
||||||
return service
|
return service
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user