mirror of
https://github.com/docker/compose.git
synced 2025-07-23 13:45:00 +02:00
is_named_volume also tests for home paths ~
Fix bug with VolumeSpec not being updated Fix integration test Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
9e67eae311
commit
48377a354f
@ -166,6 +166,4 @@ class VolumeSpec(namedtuple('_VolumeSpec', 'external internal mode')):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def is_named_volume(self):
|
def is_named_volume(self):
|
||||||
return self.external and not (
|
return self.external and not self.external.startswith(('.', '/', '~'))
|
||||||
self.external.startswith('.') or self.external.startswith('/')
|
|
||||||
)
|
|
||||||
|
@ -478,7 +478,8 @@ def get_networks(service_dict, network_definitions):
|
|||||||
|
|
||||||
|
|
||||||
def match_named_volumes(service_dict, project_volumes):
|
def match_named_volumes(service_dict, project_volumes):
|
||||||
for volume_spec in service_dict.get('volumes', []):
|
service_volumes = service_dict.get('volumes', [])
|
||||||
|
for volume_spec in service_volumes:
|
||||||
if volume_spec.is_named_volume:
|
if volume_spec.is_named_volume:
|
||||||
declared_volume = next(
|
declared_volume = next(
|
||||||
(v for v in project_volumes if v.name == volume_spec.external),
|
(v for v in project_volumes if v.name == volume_spec.external),
|
||||||
@ -491,7 +492,9 @@ def match_named_volumes(service_dict, project_volumes):
|
|||||||
volume_spec.repr(), service_dict.get('name')
|
volume_spec.repr(), service_dict.get('name')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
volume_spec._replace(external=declared_volume.full_name)
|
service_volumes[service_volumes.index(volume_spec)] = (
|
||||||
|
volume_spec._replace(external=declared_volume.full_name)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_volumes_from(project, service_dict):
|
def get_volumes_from(project, service_dict):
|
||||||
|
@ -846,6 +846,7 @@ class ProjectTest(DockerClientTestCase):
|
|||||||
self.assertEqual(len(volumes), 1)
|
self.assertEqual(len(volumes), 1)
|
||||||
self.assertEqual(volumes[0].external, full_vol_name)
|
self.assertEqual(volumes[0].external, full_vol_name)
|
||||||
project.up()
|
project.up()
|
||||||
engine_volumes = self.client.volumes()
|
engine_volumes = self.client.volumes()['Volumes']
|
||||||
self.assertIsNone(next(v for v in engine_volumes if v['Name'] == vol_name))
|
container = service.get_container()
|
||||||
self.assertIsNotNone(next(v for v in engine_volumes if v['Name'] == full_vol_name))
|
assert [mount['Name'] for mount in container.get('Mounts')] == [full_vol_name]
|
||||||
|
assert next((v for v in engine_volumes if v['Name'] == vol_name), None) is None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user