mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Support local files in list of sources
This commit is contained in:
parent
d175061c5d
commit
3d7aa19cd8
1 changed files with 16 additions and 1 deletions
|
@ -3217,11 +3217,13 @@ def source_list(source, source_hash, saltenv):
|
|||
if isinstance(single, dict):
|
||||
# check the proto, if it is http or ftp then download the file
|
||||
# to check, if it is salt then check the master list
|
||||
# if it is a local file, check if the file exists
|
||||
if len(single) != 1:
|
||||
continue
|
||||
single_src = next(iter(single))
|
||||
single_hash = single[single_src] if single[single_src] else source_hash
|
||||
proto = _urlparse(single_src).scheme
|
||||
urlparsed_single_src = _urlparse(single_src)
|
||||
proto = urlparsed_single_src.scheme
|
||||
if proto == 'salt':
|
||||
path, senv = salt.utils.url.parse(single_src)
|
||||
if not senv:
|
||||
|
@ -3236,6 +3238,12 @@ def source_list(source, source_hash, saltenv):
|
|||
if fn_:
|
||||
ret = (single_src, single_hash)
|
||||
break
|
||||
elif proto == 'file' and os.path.exists(urlparsed_single_src.path):
|
||||
ret = (single_src, single_hash)
|
||||
break
|
||||
elif single_src.startswith('/') and os.path.exists(single_src):
|
||||
ret = (single_src, single_hash)
|
||||
break
|
||||
elif isinstance(single, six.string_types):
|
||||
path, senv = salt.utils.url.parse(single)
|
||||
if not senv:
|
||||
|
@ -3243,6 +3251,13 @@ def source_list(source, source_hash, saltenv):
|
|||
if (path, senv) in mfiles or (path, senv) in mdirs:
|
||||
ret = (single, source_hash)
|
||||
break
|
||||
urlparsed_source = _urlparse(single)
|
||||
if urlparsed_source.scheme == 'file' and os.path.exists(urlparsed_source.path):
|
||||
ret = (single, source_hash)
|
||||
break
|
||||
if single.startswith('/') and os.path.exists(single):
|
||||
ret = (single, source_hash)
|
||||
break
|
||||
if ret is None:
|
||||
# None of the list items matched
|
||||
raise CommandExecutionError(
|
||||
|
|
Loading…
Add table
Reference in a new issue