From 0b5c844431ad15f5ec9b7b8481de7f7c6f5bf92d Mon Sep 17 00:00:00 2001 From: ohxodi Date: Thu, 28 Apr 2022 15:43:57 +0200 Subject: [PATCH] Add runtime error if no external volume exists --- podman_compose.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/podman_compose.py b/podman_compose.py index 9373bfb..65726d0 100755 --- a/podman_compose.py +++ b/podman_compose.py @@ -347,18 +347,22 @@ def assert_volume(compose, mount_dict): if ( mount_dict["type"] != "volume" or not vol - or vol.get("external", None) or not vol.get("name", None) ): return proj_name = compose.project_name vol_name = vol["name"] + is_ext = vol.get("external", None) log(f"podman volume inspect {vol_name} || podman volume create {vol_name}") # TODO: might move to using "volume list" # podman volume list --format '{{.Name}}\t{{.MountPoint}}' -f 'label=io.podman.compose.project=HERE' try: _ = compose.podman.output([], "volume", ["inspect", vol_name]).decode("utf-8") - except subprocess.CalledProcessError: + except subprocess.CalledProcessError as e: + if is_ext: + raise RuntimeError( + f"External volume [{vol_name}] does not exists" + ) from e labels = vol.get("labels", None) or [] args = [ "create",