Catch error when compose file is empty

Also catch cases such as the top element being a list or a string
This commit is contained in:
Sam Tygier 2020-05-09 16:40:10 +01:00 committed by Muayyad Alsadi
parent 1ca6a88ebd
commit 5915ba345f

View File

@ -874,6 +874,9 @@ class PodmanCompose:
with open(filename, 'r') as f:
content = yaml.safe_load(f)
#print(filename, json.dumps(content, indent = 2))
if not isinstance(content, dict):
sys.stderr.write("Compose file does not contain a top level object: %s\n"%filename)
exit(1)
content = normalize(content)
#print(filename, json.dumps(content, indent = 2))
content = rec_subs(content, [os.environ, dotenv_dict])