mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #29305 from lorengordon/source_hash_protos
Add 'file' as a source_hash proto
This commit is contained in:
commit
027bed7c90
1 changed files with 9 additions and 8 deletions
|
@ -3342,7 +3342,7 @@ def get_managed(
|
|||
if not source_sum:
|
||||
return '', {}, 'Source file {0} not found'.format(source)
|
||||
elif source_hash:
|
||||
protos = ('salt', 'http', 'https', 'ftp', 'swift', 's3')
|
||||
protos = ('salt', 'http', 'https', 'ftp', 'swift', 's3', 'file')
|
||||
if _urlparse(source_hash).scheme in protos:
|
||||
# The source_hash is a file on a server
|
||||
hash_fn = __salt__['cp.cache_file'](source_hash, saltenv)
|
||||
|
@ -3351,18 +3351,19 @@ def get_managed(
|
|||
source_hash)
|
||||
source_sum = extract_hash(hash_fn, '', name)
|
||||
if source_sum is None:
|
||||
return '', {}, ('Source hash file {0} contains an invalid '
|
||||
'hash format, it must be in the format <hash type>=<hash>.'
|
||||
).format(source_hash)
|
||||
return '', {}, ('Source hash {0} format is invalid. It '
|
||||
'must be in the format, <hash type>=<hash>, or it '
|
||||
'must be a supported protocol: {1}'
|
||||
).format(source_hash, ', '.join(protos))
|
||||
|
||||
else:
|
||||
# The source_hash is a hash string
|
||||
comps = source_hash.split('=')
|
||||
if len(comps) < 2:
|
||||
return '', {}, ('Source hash file {0} contains an '
|
||||
'invalid hash format, it must be in '
|
||||
'the format <hash type>=<hash>'
|
||||
).format(source_hash)
|
||||
return '', {}, ('Source hash {0} format is invalid. It '
|
||||
'must be in the format, <hash type>=<hash>, or it '
|
||||
'must be a supported protocol: {1}'
|
||||
).format(source_hash, ', '.join(protos))
|
||||
source_sum['hsum'] = comps[1].strip()
|
||||
source_sum['hash_type'] = comps[0].strip()
|
||||
elif urlparsed_source.scheme == 'file':
|
||||
|
|
Loading…
Add table
Reference in a new issue