mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
cp.get_url: fix dest=None
behaviour with salt://
URL
This commit is contained in:
parent
3ce4897b97
commit
99cf3038cc
@ -556,8 +556,12 @@ class Client(object):
|
|||||||
return url_data.path
|
return url_data.path
|
||||||
|
|
||||||
if url_data.scheme == 'salt':
|
if url_data.scheme == 'salt':
|
||||||
return self.get_file(
|
cached = self.get_file(url, dest, makedirs, saltenv, cachedir=cachedir)
|
||||||
url, dest, makedirs, saltenv, cachedir=cachedir)
|
if dest is None:
|
||||||
|
with salt.utils.fopen(cached, 'r') as fp_:
|
||||||
|
data = fp_.read()
|
||||||
|
return data
|
||||||
|
return cached
|
||||||
if dest:
|
if dest:
|
||||||
destdir = os.path.dirname(dest)
|
destdir = os.path.dirname(dest)
|
||||||
if not os.path.isdir(destdir):
|
if not os.path.isdir(destdir):
|
||||||
|
@ -309,11 +309,11 @@ def get_dir(path, dest, saltenv='base', template=None, gzip=None, env=None, **kw
|
|||||||
|
|
||||||
def get_url(path, dest, saltenv='base', env=None):
|
def get_url(path, dest, saltenv='base', env=None):
|
||||||
'''
|
'''
|
||||||
Used to get a single file from a URL.
|
Used to get a single file from a URL
|
||||||
|
|
||||||
The default behaviuor is to write the fetched file to the given
|
The default behaviour is to write the fetched file to the given
|
||||||
destination path. To simply return the text contents instead, set destination to
|
destination path. To simply return the file contents instead, set
|
||||||
None.
|
destination to ``None``.
|
||||||
|
|
||||||
CLI Example:
|
CLI Example:
|
||||||
|
|
||||||
@ -331,7 +331,7 @@ def get_url(path, dest, saltenv='base', env=None):
|
|||||||
# Backwards compatibility
|
# Backwards compatibility
|
||||||
saltenv = env
|
saltenv = env
|
||||||
|
|
||||||
if dest:
|
if isinstance(dest, str):
|
||||||
return _client().get_url(path, dest, False, saltenv)
|
return _client().get_url(path, dest, False, saltenv)
|
||||||
else:
|
else:
|
||||||
return _client().get_url(path, None, False, saltenv, no_cache=True)
|
return _client().get_url(path, None, False, saltenv, no_cache=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user