mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
cp.get_file_str: do not fail if file not found (#36936)
This commit is contained in:
parent
2ccc44f314
commit
e2bc94b029
1 changed files with 7 additions and 3 deletions
|
@ -341,6 +341,8 @@ def get_file_str(path, saltenv='base', env=None):
|
|||
'''
|
||||
Return the contents of a file from a URL
|
||||
|
||||
Returns ``False`` if Salt was unable to cache a file from a URL.
|
||||
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
@ -357,9 +359,11 @@ def get_file_str(path, saltenv='base', env=None):
|
|||
saltenv = env
|
||||
|
||||
fn_ = cache_file(path, saltenv)
|
||||
with salt.utils.fopen(fn_, 'r') as fp_:
|
||||
data = fp_.read()
|
||||
return data
|
||||
if isinstance(fn_, six.string_types):
|
||||
with salt.utils.fopen(fn_, 'r') as fp_:
|
||||
data = fp_.read()
|
||||
return data
|
||||
return fn_
|
||||
|
||||
|
||||
def cache_file(path, saltenv='base', env=None):
|
||||
|
|
Loading…
Add table
Reference in a new issue