mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
Need to fail fast in cached_clean state
This commit is contained in:
parent
c53824b111
commit
aace612d09
@ -328,12 +328,6 @@ def cache_cleaned(name=None,
|
||||
ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}
|
||||
specific_pkg = None
|
||||
|
||||
if name:
|
||||
all_cached_pkgs = __salt__['npm.cache_list'](path=None, runas=user)
|
||||
# The first package is always the cache path
|
||||
cache_root_path = all_cached_pkgs[0]
|
||||
specific_pkg = '{0}/{1}/'.format(cache_root_path, name)
|
||||
|
||||
try:
|
||||
cached_pkgs = __salt__['npm.cache_list'](path=name, runas=user)
|
||||
except (CommandExecutionError, CommandNotFoundError) as err:
|
||||
@ -342,10 +336,16 @@ def cache_cleaned(name=None,
|
||||
name or 'packages', err)
|
||||
return ret
|
||||
|
||||
if specific_pkg and (specific_pkg not in cached_pkgs):
|
||||
ret['result'] = True
|
||||
ret['comment'] = 'Package {0} is not in the cache'.format(name)
|
||||
return ret
|
||||
if name:
|
||||
all_cached_pkgs = __salt__['npm.cache_list'](path=None, runas=user)
|
||||
# The first package is always the cache path
|
||||
cache_root_path = all_cached_pkgs[0]
|
||||
specific_pkg = '{0}/{1}/'.format(cache_root_path, name)
|
||||
|
||||
if specific_pkg not in cached_pkgs:
|
||||
ret['result'] = True
|
||||
ret['comment'] = 'Package {0} is not in the cache'.format(name)
|
||||
return ret
|
||||
|
||||
if __opts__['test']:
|
||||
ret['result'] = None
|
||||
|
Loading…
Reference in New Issue
Block a user