mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Clean up arg parsing in runner client
This commit is contained in:
parent
9c983c3cb4
commit
15c3637828
@ -91,31 +91,12 @@ class RunnerClient(mixins.SyncClientMixin, mixins.AsyncClientMixin, object):
|
||||
'kwarg must be formatted as a dictionary'
|
||||
)
|
||||
arglist = salt.utils.args.parse_input(arg)
|
||||
def _append_kwarg(arglist, kwarg):
|
||||
'''
|
||||
Append the kwarg dict to the arglist
|
||||
'''
|
||||
|
||||
# if you were passed kwarg, add it to arglist
|
||||
if kwarg:
|
||||
kwarg['__kwarg__'] = True
|
||||
arglist.append(kwarg)
|
||||
|
||||
if kwarg:
|
||||
try:
|
||||
if isinstance(arglist[-1], dict) \
|
||||
and '__kwarg__' in arglist[-1]:
|
||||
for key, val in six.iteritems(kwarg):
|
||||
if key in arglist[-1]:
|
||||
log.warning(
|
||||
'Overriding keyword argument {0!r}'.format(key)
|
||||
)
|
||||
arglist[-1][key] = val
|
||||
else:
|
||||
# No kwargs yet present in arglist
|
||||
_append_kwarg(arglist, kwarg)
|
||||
except IndexError:
|
||||
# arglist is empty, just append
|
||||
_append_kwarg(arglist, kwarg)
|
||||
|
||||
self._verify_fun(fun)
|
||||
args, kwargs = salt.minion.load_args_and_kwargs(
|
||||
self.functions[fun], arglist, pub_data
|
||||
)
|
||||
@ -230,9 +211,9 @@ class Runner(RunnerClient):
|
||||
else:
|
||||
try:
|
||||
low = {'fun': self.opts['fun']}
|
||||
arglist = salt.utils.args.parse_input(self.opts['arg'])
|
||||
args, kwargs = salt.minion.load_args_and_kwargs(
|
||||
self.functions[low['fun']], arglist
|
||||
self.functions[low['fun']],
|
||||
salt.utils.args.parse_input(self.opts['arg']),
|
||||
)
|
||||
low['args'] = args
|
||||
low.update(kwargs)
|
||||
|
Loading…
Reference in New Issue
Block a user