mirror of https://github.com/docker/docker-py.git
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 <jackd98.jd@gmail.com>
This commit is contained in:
parent
84414e343e
commit
ad035dfeac
|
|
@ -242,16 +242,20 @@ class Mount(dict):
|
||||||
tmpfs_mode (int): The permission mode for the tmpfs mount.
|
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,
|
consistency=None, propagation=None, no_copy=False,
|
||||||
labels=None, driver_config=None, tmpfs_size=None,
|
labels=None, driver_config=None, tmpfs_size=None,
|
||||||
tmpfs_mode=None):
|
tmpfs_mode=None):
|
||||||
self['Target'] = target
|
|
||||||
self['Source'] = source
|
|
||||||
if type not in ('bind', 'volume', 'tmpfs', 'npipe'):
|
if type not in ('bind', 'volume', 'tmpfs', 'npipe'):
|
||||||
raise errors.InvalidArgument(
|
raise errors.InvalidArgument(
|
||||||
f'Unsupported mount type: "{type}"'
|
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['Type'] = type
|
||||||
self['ReadOnly'] = read_only
|
self['ReadOnly'] = read_only
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue