mirror of https://github.com/docker/docker-py.git
volume: do not strip trailing characters from names (#3073)
Only remove `:ro` or `:rw` suffixes in their entirety; do not strip arbitrary `r` / `o` / `w` / `:` characters individually. Signed-off-by: Loïc Leyendecker <loic.leyendecker@gmail.com>
This commit is contained in:
parent
8590eaad3c
commit
82cf559b5a
|
|
@ -1147,8 +1147,10 @@ def _host_volume_from_bind(bind):
|
||||||
bits = rest.split(':', 1)
|
bits = rest.split(':', 1)
|
||||||
if len(bits) == 1 or bits[1] in ('ro', 'rw'):
|
if len(bits) == 1 or bits[1] in ('ro', 'rw'):
|
||||||
return drive + bits[0]
|
return drive + bits[0]
|
||||||
|
elif bits[1].endswith(':ro') or bits[1].endswith(':rw'):
|
||||||
|
return bits[1][:-3]
|
||||||
else:
|
else:
|
||||||
return bits[1].rstrip(':ro').rstrip(':rw')
|
return bits[1]
|
||||||
|
|
||||||
|
|
||||||
ExecResult = namedtuple('ExecResult', 'exit_code,output')
|
ExecResult = namedtuple('ExecResult', 'exit_code,output')
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ class ContainerCollectionTest(unittest.TestCase):
|
||||||
volumes=[
|
volumes=[
|
||||||
'/home/user1/:/mnt/vol2',
|
'/home/user1/:/mnt/vol2',
|
||||||
'/var/www:/mnt/vol1:ro',
|
'/var/www:/mnt/vol1:ro',
|
||||||
'volumename:/mnt/vol3',
|
'volumename:/mnt/vol3r',
|
||||||
'/volumewithnohostpath',
|
'/volumewithnohostpath',
|
||||||
'/anothervolumewithnohostpath:ro',
|
'/anothervolumewithnohostpath:ro',
|
||||||
'C:\\windows\\path:D:\\hello\\world:rw'
|
'C:\\windows\\path:D:\\hello\\world:rw'
|
||||||
|
|
@ -123,7 +123,7 @@ class ContainerCollectionTest(unittest.TestCase):
|
||||||
'Binds': [
|
'Binds': [
|
||||||
'/home/user1/:/mnt/vol2',
|
'/home/user1/:/mnt/vol2',
|
||||||
'/var/www:/mnt/vol1:ro',
|
'/var/www:/mnt/vol1:ro',
|
||||||
'volumename:/mnt/vol3',
|
'volumename:/mnt/vol3r',
|
||||||
'/volumewithnohostpath',
|
'/volumewithnohostpath',
|
||||||
'/anothervolumewithnohostpath:ro',
|
'/anothervolumewithnohostpath:ro',
|
||||||
'C:\\windows\\path:D:\\hello\\world:rw'
|
'C:\\windows\\path:D:\\hello\\world:rw'
|
||||||
|
|
@ -198,7 +198,7 @@ class ContainerCollectionTest(unittest.TestCase):
|
||||||
volumes=[
|
volumes=[
|
||||||
'/mnt/vol2',
|
'/mnt/vol2',
|
||||||
'/mnt/vol1',
|
'/mnt/vol1',
|
||||||
'/mnt/vol3',
|
'/mnt/vol3r',
|
||||||
'/volumewithnohostpath',
|
'/volumewithnohostpath',
|
||||||
'/anothervolumewithnohostpath',
|
'/anothervolumewithnohostpath',
|
||||||
'D:\\hello\\world'
|
'D:\\hello\\world'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue