forked from extern/podman-compose
Add support external volumes
# docker-compose.yml version: '3' services: test: volumes: - data:/data volumes: data: name: some external: true
This commit is contained in:
parent
ab135030c8
commit
6d69b7c74c
@ -145,8 +145,12 @@ def fix_mount_dict(mount_dict, proj_name, srv_name):
|
|||||||
hashlib.sha256(mount_dict["target"].encode("utf-8")).hexdigest(),
|
hashlib.sha256(mount_dict["target"].encode("utf-8")).hexdigest(),
|
||||||
])
|
])
|
||||||
else:
|
else:
|
||||||
# prefix with proj_name
|
name = mount_dict.get('name')
|
||||||
mount_dict["source"] = proj_name+"_"+source
|
if name:
|
||||||
|
mount_dict["source"] = name
|
||||||
|
else:
|
||||||
|
# prefix with proj_name
|
||||||
|
mount_dict["source"] = proj_name+"_"+source
|
||||||
return mount_dict
|
return mount_dict
|
||||||
|
|
||||||
# docker and docker-compose support subset of bash variable substitution
|
# docker and docker-compose support subset of bash variable substitution
|
||||||
@ -390,7 +394,7 @@ def assert_volume(compose, mount_dict):
|
|||||||
inspect volume to get directory
|
inspect volume to get directory
|
||||||
create volume if needed
|
create volume if needed
|
||||||
"""
|
"""
|
||||||
if mount_dict["type"] != "volume": return
|
if mount_dict["type"] != "volume" or mount_dict["external"]: return
|
||||||
proj_name = compose.project_name
|
proj_name = compose.project_name
|
||||||
shared_vols = compose.shared_vols
|
shared_vols = compose.shared_vols
|
||||||
|
|
||||||
@ -494,6 +498,19 @@ def get_mount_args(compose, cnt, volume):
|
|||||||
basedir = compose.dirname
|
basedir = compose.dirname
|
||||||
if is_str(volume): volume = parse_short_mount(volume, basedir)
|
if is_str(volume): volume = parse_short_mount(volume, basedir)
|
||||||
mount_type = volume["type"]
|
mount_type = volume["type"]
|
||||||
|
|
||||||
|
vol = None
|
||||||
|
source = volume.get('source')
|
||||||
|
if source:
|
||||||
|
vol = compose.shared_vols[source]
|
||||||
|
if vol:
|
||||||
|
name = vol.get('name')
|
||||||
|
if name:
|
||||||
|
volume['name'] = name
|
||||||
|
external = vol.get('external')
|
||||||
|
if external:
|
||||||
|
volume['external'] = external
|
||||||
|
|
||||||
assert_volume(compose, fix_mount_dict(volume, proj_name, srv_name))
|
assert_volume(compose, fix_mount_dict(volume, proj_name, srv_name))
|
||||||
if compose._prefer_volume_over_mount:
|
if compose._prefer_volume_over_mount:
|
||||||
if mount_type == 'tmpfs':
|
if mount_type == 'tmpfs':
|
||||||
@ -1110,8 +1127,6 @@ class PodmanCompose:
|
|||||||
service_names = [ name for _, name in service_names]
|
service_names = [ name for _, name in service_names]
|
||||||
# volumes: [...]
|
# volumes: [...]
|
||||||
shared_vols = compose.get('volumes', {})
|
shared_vols = compose.get('volumes', {})
|
||||||
# shared_vols = list(shared_vols.keys())
|
|
||||||
shared_vols = set(shared_vols.keys())
|
|
||||||
self.shared_vols = shared_vols
|
self.shared_vols = shared_vols
|
||||||
podman_compose_labels = [
|
podman_compose_labels = [
|
||||||
"io.podman.compose.config-hash=123",
|
"io.podman.compose.config-hash=123",
|
||||||
|
Loading…
Reference in New Issue
Block a user