mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Parse kwargs with YAML, Fix #5224
This commit is contained in:
parent
0db1eb70ca
commit
d00a89afd4
@ -134,10 +134,10 @@ def detect_kwargs(func, args, data=None):
|
||||
# Invalid kwarg
|
||||
pass
|
||||
elif has_kwargs:
|
||||
kwargs[comps[0]] = '='.join(comps[1:])
|
||||
kwargs[comps[0]] = yamlify_arg('='.join(comps[1:]))
|
||||
continue
|
||||
elif comps[0] in kwarg_spec:
|
||||
kwargs[comps[0]] = '='.join(comps[1:])
|
||||
kwargs[comps[0]] = yamlify_arg('='.join(comps[1:]))
|
||||
continue
|
||||
_args.append(arg)
|
||||
if has_kwargs and isinstance(data, dict):
|
||||
@ -147,6 +147,18 @@ def detect_kwargs(func, args, data=None):
|
||||
return _args, kwargs
|
||||
|
||||
|
||||
def yamlify_arg(arg):
|
||||
'''
|
||||
yaml.safe_load the arg unless it has a newline in it
|
||||
'''
|
||||
try:
|
||||
if '\n' not in arg:
|
||||
return yaml.safe_load(arg)
|
||||
except Exception:
|
||||
pass
|
||||
return arg
|
||||
|
||||
|
||||
class SMinion(object):
|
||||
'''
|
||||
Create an object that has loaded all of the minion module functions,
|
||||
|
Loading…
Reference in New Issue
Block a user