summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitri <dz@stackstorm.com>2016-12-28 23:23:08 -0800
committerDmitri <dz@stackstorm.com>2016-12-28 23:43:15 -0800
commit59ccd8a782b64d91e3b4609b750c963b253fbb81 (patch)
treeed7243e8a222a9abb511d640f4ed1aea098434e8
parentedd3045ef178dee94e059717af3aedba28f9d70d (diff)
downloaddocker-py-59ccd8a782b64d91e3b4609b750c963b253fbb81.tar.gz
Fix readonly in mounts.
Signed-off-by: Dmitri Zimine dz@stackstorm.com
-rw-r--r--docker/types/services.py3
-rw-r--r--tests/unit/types.py16
2 files changed, 18 insertions, 1 deletions
diff --git a/docker/types/services.py b/docker/types/services.py
index 5041f89..d76561e 100644
--- a/docker/types/services.py
+++ b/docker/types/services.py
@@ -135,6 +135,7 @@ class Mount(dict):
'Only acceptable mount types are `bind` and `volume`.'
)
self['Type'] = type
+ self['ReadOnly'] = read_only
if type == 'bind':
if propagation is not None:
@@ -174,7 +175,7 @@ class Mount(dict):
else:
target = parts[1]
source = parts[0]
- read_only = not (len(parts) == 3 or parts[2] == 'ro')
+ read_only = not (len(parts) == 2 or parts[2] == 'rw')
return cls(target, source, read_only=read_only)
diff --git a/tests/unit/types.py b/tests/unit/types.py
new file mode 100644
index 0000000..5a73837
--- /dev/null
+++ b/tests/unit/types.py
@@ -0,0 +1,16 @@
+import unittest
+from docker.types.services import Mount
+
+
+class TestMounts(unittest.TestCase):
+ def test_parse_mount_string_docker(self):
+ mount = Mount.parse_mount_string("foo/bar:/buz:ro")
+ self.assertEqual(mount['Source'], "foo/bar")
+ self.assertEqual(mount['Target'], "/buz")
+ self.assertEqual(mount['ReadOnly'], True)
+
+ mount = Mount.parse_mount_string("foo/bar:/buz:rw")
+ self.assertEqual(mount['ReadOnly'], False)
+
+ mount = Mount.parse_mount_string("foo/bar:/buz")
+ self.assertEqual(mount['ReadOnly'], False)