diff options
author | Joffrey F <joffrey@docker.com> | 2017-01-09 14:34:25 -0800 |
---|---|---|
committer | Joffrey F <joffrey@docker.com> | 2017-01-09 14:34:25 -0800 |
commit | 180dd6997489c7c5ccdd4c9bfbd213f0298143c4 (patch) | |
tree | 651991f24cfca38b5ff287c4689ab17327d09c02 | |
parent | a96073199939c6f01894414a8a9eb78409ac4bb5 (diff) | |
download | docker-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.py | 4 | ||||
-rw-r--r-- | docker/types/services.py | 12 |
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 |