mirror of
https://github.com/containers/podman-compose.git
synced 2025-02-09 06:49:18 +01:00
Add runtime error if no external volume exists
This commit is contained in:
parent
9c29c8914f
commit
0b5c844431
@ -347,18 +347,22 @@ def assert_volume(compose, mount_dict):
|
|||||||
if (
|
if (
|
||||||
mount_dict["type"] != "volume"
|
mount_dict["type"] != "volume"
|
||||||
or not vol
|
or not vol
|
||||||
or vol.get("external", None)
|
|
||||||
or not vol.get("name", None)
|
or not vol.get("name", None)
|
||||||
):
|
):
|
||||||
return
|
return
|
||||||
proj_name = compose.project_name
|
proj_name = compose.project_name
|
||||||
vol_name = vol["name"]
|
vol_name = vol["name"]
|
||||||
|
is_ext = vol.get("external", None)
|
||||||
log(f"podman volume inspect {vol_name} || podman volume create {vol_name}")
|
log(f"podman volume inspect {vol_name} || podman volume create {vol_name}")
|
||||||
# TODO: might move to using "volume list"
|
# TODO: might move to using "volume list"
|
||||||
# podman volume list --format '{{.Name}}\t{{.MountPoint}}' -f 'label=io.podman.compose.project=HERE'
|
# podman volume list --format '{{.Name}}\t{{.MountPoint}}' -f 'label=io.podman.compose.project=HERE'
|
||||||
try:
|
try:
|
||||||
_ = compose.podman.output([], "volume", ["inspect", vol_name]).decode("utf-8")
|
_ = 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 []
|
labels = vol.get("labels", None) or []
|
||||||
args = [
|
args = [
|
||||||
"create",
|
"create",
|
||||||
|
Loading…
Reference in New Issue
Block a user