General cleanup in pkg state, reducing duplicate code. Fixing the requires_salt_modules decorator, sys.doc was returning too much information for the event to handle. This change specifically calls sys.doc with the module name.

This commit is contained in:
Gareth J. Greenaway 2018-07-05 12:10:17 -07:00
parent 16fb6ae635
commit 11cb86e6eb
No known key found for this signature in database
GPG key ID: 10B62F8A7CAD7A41
2 changed files with 6 additions and 11 deletions

View file

@ -1523,17 +1523,12 @@ def installed(
# _find_install_targets() found no targets or encountered an error
# check that the hold function is available
if 'pkg.hold' in __salt__:
if 'hold' in kwargs:
if 'pkg.hold' in __salt__ and 'hold' in kwargs:
try:
if kwargs['hold']:
hold_ret = __salt__['pkg.hold'](
name=name, pkgs=pkgs, sources=sources
)
else:
hold_ret = __salt__['pkg.unhold'](
name=name, pkgs=pkgs, sources=sources
)
action = 'pkg.hold' if kwargs['hold'] else 'pkg.unhold'
hold_ret = __salt__[action](
name=name, pkgs=pkgs, sources=sources
)
except (CommandExecutionError, SaltInvocationError) as exc:
return {'name': name,
'changes': {},

View file

@ -1093,7 +1093,7 @@ def requires_salt_modules(*names):
)
for name in names:
if name not in cls.run_function('sys.doc'):
if name not in cls.run_function('sys.doc', [name]):
cls.skipTest(
'Salt module {0!r} is not available'.format(name)
)