mirror of https://github.com/docker/compose.git
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
|
||||
def is_named_volume(self):
|
||||
return self.external and not (
|
||||
self.external.startswith('.') or self.external.startswith('/')
|
||||
)
|
||||
return self.external and not self.external.startswith(('.', '/', '~'))
|
||||
|
|
|
@ -478,7 +478,8 @@ def get_networks(service_dict, network_definitions):
|
|||
|
||||
|
||||
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:
|
||||
declared_volume = next(
|
||||
(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._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):
|
||||
|
|
|
@ -846,6 +846,7 @@ class ProjectTest(DockerClientTestCase):
|
|||
self.assertEqual(len(volumes), 1)
|
||||
self.assertEqual(volumes[0].external, full_vol_name)
|
||||
project.up()
|
||||
engine_volumes = self.client.volumes()
|
||||
self.assertIsNone(next(v for v in engine_volumes if v['Name'] == vol_name))
|
||||
self.assertIsNotNone(next(v for v in engine_volumes if v['Name'] == full_vol_name))
|
||||
engine_volumes = self.client.volumes()['Volumes']
|
||||
container = service.get_container()
|
||||
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…
Reference in New Issue