From ad035dfeac8d7a2f25beede29463b360475aca70 Mon Sep 17 00:00:00 2001 From: Jack Dane Date: Sun, 18 Jun 2023 20:36:59 +0100 Subject: [PATCH] fix: Make source a keyword argument for Mounts * There is no source for tmpfs mounts. * Raise an exception if a source hasn't been parsed for types other than tmpfs. Signed-off-by: Jack Dane --- docker/types/services.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docker/types/services.py b/docker/types/services.py index a3383ef7..39f260ce 100644 --- a/docker/types/services.py +++ b/docker/types/services.py @@ -242,16 +242,20 @@ class Mount(dict): tmpfs_mode (int): The permission mode for the tmpfs mount. """ - def __init__(self, target, source, type='volume', read_only=False, + def __init__(self, target, source=None, type='volume', read_only=False, consistency=None, propagation=None, no_copy=False, labels=None, driver_config=None, tmpfs_size=None, tmpfs_mode=None): - self['Target'] = target - self['Source'] = source if type not in ('bind', 'volume', 'tmpfs', 'npipe'): raise errors.InvalidArgument( f'Unsupported mount type: "{type}"' ) + if source is None and type != 'tmpfs': + raise errors.InvalidArgument( + f'A source must be provided for type: "{type}"' + ) + self['Target'] = target + self['Source'] = source self['Type'] = type self['ReadOnly'] = read_only