Add type-checking for defaults and context in cmd.script

This commit is contained in:
Loren Gordon 2015-10-21 06:02:41 -04:00
parent e3a5758679
commit 0354128484

View File

@ -1017,13 +1017,22 @@ def script(name,
'documentation.')
return ret
if HAS_GRP:
pgid = os.getegid()
if context and not isinstance(context, dict):
ret['comment'] = ('Invalidly-formatted \'context\' parameter. Must '
'be formed as a dict.')
return ret
if defaults and not isinstance(defaults, dict):
ret['comment'] = ('Invalidly-formatted \'defaults\' parameter. Must '
'be formed as a dict.')
return ret
tmpctx = defaults if defaults else {}
if context:
tmpctx.update(context)
if HAS_GRP:
pgid = os.getegid()
cmd_kwargs = copy.deepcopy(kwargs)
cmd_kwargs.update({'runas': user,
'shell': shell or __grains__['shell'],