forked from extern/podman-compose
Avoid crash when no services are defined
If no services are defined, podman-compose crashes as services variable is None, while the expected behavior might be an error or the same as docker-compose, which will continue the execution of the compose file (eg. creating networks, etc). This commit fixes the crash and allows the program to continue, mimicking docker-compose behavior.
This commit is contained in:
parent
efcbc75f63
commit
796e6a4473
@ -828,6 +828,10 @@ class PodmanCompose:
|
||||
print(" ** merged:\n", json.dumps(compose, indent = 2))
|
||||
ver = compose.get('version')
|
||||
services = compose.get('services')
|
||||
if services is None:
|
||||
services = {}
|
||||
print("WARNING: No services defined")
|
||||
|
||||
# NOTE: maybe add "extends.service" to _deps at this stage
|
||||
flat_deps(services, with_extends=True)
|
||||
service_names = sorted([ (len(srv["_deps"]), name) for name, srv in services.items() ])
|
||||
|
7
tests/no_services/docker-compose.yaml
Normal file
7
tests/no_services/docker-compose.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
version: '3'
|
||||
networks:
|
||||
shared-network:
|
||||
driver: bridge
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 172.19.0.0/24
|
Loading…
Reference in New Issue
Block a user