mirror of https://github.com/docker/compose.git
Merge pull request #2230 from dnephin/lowercase_windows_drive
Lowercase windows drive letter
This commit is contained in:
commit
44e1fc3a32
|
@ -943,23 +943,21 @@ def build_volume_binding(volume_spec):
|
||||||
|
|
||||||
|
|
||||||
def normalize_paths_for_engine(external_path, internal_path):
|
def normalize_paths_for_engine(external_path, internal_path):
|
||||||
"""
|
"""Windows paths, c:\my\path\shiny, need to be changed to be compatible with
|
||||||
Windows paths, c:\my\path\shiny, need to be changed to be compatible with
|
|
||||||
the Engine. Volume paths are expected to be linux style /c/my/path/shiny/
|
the Engine. Volume paths are expected to be linux style /c/my/path/shiny/
|
||||||
"""
|
"""
|
||||||
if IS_WINDOWS_PLATFORM:
|
if not IS_WINDOWS_PLATFORM:
|
||||||
|
return external_path, internal_path
|
||||||
|
|
||||||
if external_path:
|
if external_path:
|
||||||
drive, tail = os.path.splitdrive(external_path)
|
drive, tail = os.path.splitdrive(external_path)
|
||||||
|
|
||||||
if drive:
|
if drive:
|
||||||
reformatted_drive = "/{}".format(drive.replace(":", ""))
|
external_path = '/' + drive.lower().rstrip(':') + tail
|
||||||
external_path = reformatted_drive + tail
|
|
||||||
|
|
||||||
external_path = "/".join(external_path.split("\\"))
|
external_path = external_path.replace('\\', '/')
|
||||||
|
|
||||||
return external_path, "/".join(internal_path.split("\\"))
|
return external_path, internal_path.replace('\\', '/')
|
||||||
else:
|
|
||||||
return external_path, internal_path
|
|
||||||
|
|
||||||
|
|
||||||
def parse_volume_spec(volume_config):
|
def parse_volume_spec(volume_config):
|
||||||
|
|
|
@ -537,8 +537,8 @@ class VolumeConfigTest(unittest.TestCase):
|
||||||
self.assertEqual(d['volumes'], ['/var/lib/data:/data'])
|
self.assertEqual(d['volumes'], ['/var/lib/data:/data'])
|
||||||
|
|
||||||
def test_absolute_windows_path_does_not_expand(self):
|
def test_absolute_windows_path_does_not_expand(self):
|
||||||
d = make_service_dict('foo', {'build': '.', 'volumes': ['C:\\data:/data']}, working_dir='.')
|
d = make_service_dict('foo', {'build': '.', 'volumes': ['c:\\data:/data']}, working_dir='.')
|
||||||
self.assertEqual(d['volumes'], ['C:\\data:/data'])
|
self.assertEqual(d['volumes'], ['c:\\data:/data'])
|
||||||
|
|
||||||
@pytest.mark.skipif(IS_WINDOWS_PLATFORM, reason='posix paths')
|
@pytest.mark.skipif(IS_WINDOWS_PLATFORM, reason='posix paths')
|
||||||
def test_relative_path_does_expand_posix(self):
|
def test_relative_path_does_expand_posix(self):
|
||||||
|
@ -553,14 +553,14 @@ class VolumeConfigTest(unittest.TestCase):
|
||||||
|
|
||||||
@pytest.mark.skipif(not IS_WINDOWS_PLATFORM, reason='windows paths')
|
@pytest.mark.skipif(not IS_WINDOWS_PLATFORM, reason='windows paths')
|
||||||
def test_relative_path_does_expand_windows(self):
|
def test_relative_path_does_expand_windows(self):
|
||||||
d = make_service_dict('foo', {'build': '.', 'volumes': ['./data:/data']}, working_dir='C:\\Users\\me\\myproject')
|
d = make_service_dict('foo', {'build': '.', 'volumes': ['./data:/data']}, working_dir='c:\\Users\\me\\myproject')
|
||||||
self.assertEqual(d['volumes'], ['C:\\Users\\me\\myproject\\data:/data'])
|
self.assertEqual(d['volumes'], ['c:\\Users\\me\\myproject\\data:/data'])
|
||||||
|
|
||||||
d = make_service_dict('foo', {'build': '.', 'volumes': ['.:/data']}, working_dir='C:\\Users\\me\\myproject')
|
d = make_service_dict('foo', {'build': '.', 'volumes': ['.:/data']}, working_dir='c:\\Users\\me\\myproject')
|
||||||
self.assertEqual(d['volumes'], ['C:\\Users\\me\\myproject:/data'])
|
self.assertEqual(d['volumes'], ['c:\\Users\\me\\myproject:/data'])
|
||||||
|
|
||||||
d = make_service_dict('foo', {'build': '.', 'volumes': ['../otherproject:/data']}, working_dir='C:\\Users\\me\\myproject')
|
d = make_service_dict('foo', {'build': '.', 'volumes': ['../otherproject:/data']}, working_dir='c:\\Users\\me\\myproject')
|
||||||
self.assertEqual(d['volumes'], ['C:\\Users\\me\\otherproject:/data'])
|
self.assertEqual(d['volumes'], ['c:\\Users\\me\\otherproject:/data'])
|
||||||
|
|
||||||
@mock.patch.dict(os.environ)
|
@mock.patch.dict(os.environ)
|
||||||
def test_home_directory_with_driver_does_not_expand(self):
|
def test_home_directory_with_driver_does_not_expand(self):
|
||||||
|
|
Loading…
Reference in New Issue