summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2017-01-09 14:34:25 -0800
committerJoffrey F <joffrey@docker.com>2017-01-09 14:34:25 -0800
commit180dd6997489c7c5ccdd4c9bfbd213f0298143c4 (patch)
tree651991f24cfca38b5ff287c4689ab17327d09c02
parenta96073199939c6f01894414a8a9eb78409ac4bb5 (diff)
downloaddocker-py-dzimine-dz-fix-mount_options.tar.gz
Raise InvalidArgument exception when invalid arguments are provideddzimine-dz-fix-mount_options
Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r--docker/errors.py4
-rw-r--r--docker/types/services.py12
2 files changed, 10 insertions, 6 deletions
diff --git a/docker/errors.py b/docker/errors.py
index 05f4cae..95c462b 100644
--- a/docker/errors.py
+++ b/docker/errors.py
@@ -93,6 +93,10 @@ class InvalidConfigFile(DockerException):
pass
+class InvalidArgument(DockerException):
+ pass
+
+
class DeprecatedMethod(DockerException):
pass
diff --git a/docker/types/services.py b/docker/types/services.py
index d76561e..b52afd2 100644
--- a/docker/types/services.py
+++ b/docker/types/services.py
@@ -131,7 +131,7 @@ class Mount(dict):
self['Target'] = target
self['Source'] = source
if type not in ('bind', 'volume'):
- raise errors.DockerError(
+ raise errors.InvalidArgument(
'Only acceptable mount types are `bind` and `volume`.'
)
self['Type'] = type
@@ -143,7 +143,7 @@ class Mount(dict):
'Propagation': propagation
}
if any([labels, driver_config, no_copy]):
- raise errors.DockerError(
+ raise errors.InvalidArgument(
'Mount type is binding but volume options have been '
'provided.'
)
@@ -158,7 +158,7 @@ class Mount(dict):
if volume_opts:
self['VolumeOptions'] = volume_opts
if propagation:
- raise errors.DockerError(
+ raise errors.InvalidArgument(
'Mount type is volume but `propagation` argument has been '
'provided.'
)
@@ -167,11 +167,11 @@ class Mount(dict):
def parse_mount_string(cls, string):
parts = string.split(':')
if len(parts) > 3:
- raise errors.DockerError(
+ raise errors.InvalidArgument(
'Invalid mount format "{0}"'.format(string)
)
if len(parts) == 1:
- return cls(target=parts[0])
+ return cls(target=parts[0], source=None)
else:
target = parts[1]
source = parts[0]
@@ -229,7 +229,7 @@ class UpdateConfig(dict):
if delay is not None:
self['Delay'] = delay
if failure_action not in ('pause', 'continue'):
- raise errors.DockerError(
+ raise errors.InvalidArgument(
'failure_action must be either `pause` or `continue`.'
)
self['FailureAction'] = failure_action