cp.get_url: fix dest=None behaviour with salt:// URL

This commit is contained in:
Denys Havrysh 2016-10-10 17:56:37 +03:00
parent 3ce4897b97
commit 99cf3038cc
2 changed files with 11 additions and 7 deletions

View File

@ -556,8 +556,12 @@ class Client(object):
return url_data.path
if url_data.scheme == 'salt':
return self.get_file(
url, dest, makedirs, saltenv, cachedir=cachedir)
cached = self.get_file(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:
destdir = os.path.dirname(dest)
if not os.path.isdir(destdir):

View File

@ -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):
'''
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
destination path. To simply return the text contents instead, set destination to
None.
The default behaviour is to write the fetched file to the given
destination path. To simply return the file contents instead, set
destination to ``None``.
CLI Example:
@ -331,7 +331,7 @@ def get_url(path, dest, saltenv='base', env=None):
# Backwards compatibility
saltenv = env
if dest:
if isinstance(dest, str):
return _client().get_url(path, dest, False, saltenv)
else:
return _client().get_url(path, None, False, saltenv, no_cache=True)