mirror of https://github.com/docker/compose.git
Expand mount source when type == bind
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
38ae7ae037
commit
5c0a06475c
|
@ -1153,7 +1153,7 @@ def resolve_volume_paths(working_dir, service_dict):
|
||||||
|
|
||||||
def resolve_volume_path(working_dir, volume):
|
def resolve_volume_path(working_dir, volume):
|
||||||
if isinstance(volume, dict):
|
if isinstance(volume, dict):
|
||||||
if volume.get('source', '').startswith('.') and volume['type'] == 'mount':
|
if volume.get('source', '').startswith('.') and volume['type'] == 'bind':
|
||||||
volume['source'] = expand_path(working_dir, volume['source'])
|
volume['source'] = expand_path(working_dir, volume['source'])
|
||||||
return volume
|
return volume
|
||||||
|
|
||||||
|
|
|
@ -1304,6 +1304,29 @@ class ConfigTest(unittest.TestCase):
|
||||||
assert npipe_mount.target == '/named_pipe'
|
assert npipe_mount.target == '/named_pipe'
|
||||||
assert not npipe_mount.is_named_volume
|
assert not npipe_mount.is_named_volume
|
||||||
|
|
||||||
|
def test_load_bind_mount_relative_path(self):
|
||||||
|
expected_source = 'C:\\tmp\\web' if IS_WINDOWS_PLATFORM else '/tmp/web'
|
||||||
|
base_file = config.ConfigFile(
|
||||||
|
'base.yaml', {
|
||||||
|
'version': '3.4',
|
||||||
|
'services': {
|
||||||
|
'web': {
|
||||||
|
'image': 'busybox:latest',
|
||||||
|
'volumes': [
|
||||||
|
{'type': 'bind', 'source': './web', 'target': '/web'},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
details = config.ConfigDetails('/tmp', [base_file])
|
||||||
|
config_data = config.load(details)
|
||||||
|
mount = config_data.services[0].get('volumes')[0]
|
||||||
|
assert mount.target == '/web'
|
||||||
|
assert mount.type == 'bind'
|
||||||
|
assert mount.source == expected_source
|
||||||
|
|
||||||
def test_config_valid_service_names(self):
|
def test_config_valid_service_names(self):
|
||||||
for valid_name in ['_', '-', '.__.', '_what-up.', 'what_.up----', 'whatup']:
|
for valid_name in ['_', '-', '.__.', '_what-up.', 'what_.up----', 'whatup']:
|
||||||
services = config.load(
|
services = config.load(
|
||||||
|
|
Loading…
Reference in New Issue