mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Allow states to cleanly accept **kwargs
This addition makes it so that ALL data in the low state chunk is passed to the state function via **kwargs. This means that by passing a **kwargs from states all the back to a module function will allow for very transparent additions of arguments to states that accept **kwargs
This commit is contained in:
parent
6a80f56a77
commit
de8011adb2
@ -405,6 +405,14 @@ class State(object):
|
||||
arglen = len(aspec[0])
|
||||
if isinstance(aspec[3], tuple):
|
||||
deflen = len(aspec[3])
|
||||
if aspec[2]:
|
||||
# This state accepts kwargs
|
||||
ret['kwargs'] = {}
|
||||
for key in data:
|
||||
# Passing kwargs the conflict with args == stack trace
|
||||
if key in aspec[0]:
|
||||
continue
|
||||
ret['kwargs'][key] = data[key]
|
||||
kwargs = {}
|
||||
for ind in range(arglen - 1, 0, -1):
|
||||
minus = arglen - ind
|
||||
@ -573,7 +581,10 @@ class State(object):
|
||||
if 'provider' in data:
|
||||
self.load_modules(data)
|
||||
cdata = self.format_call(data)
|
||||
ret = self.states[cdata['full']](*cdata['args'])
|
||||
if 'kwargs' in cdata:
|
||||
ret = self.states[cdata['full']](*cdata['args'], **cdata['kwargs'])
|
||||
else:
|
||||
ret = self.states[cdata['full']](*cdata['args'])
|
||||
ret['__run_num__'] = self.__run_num
|
||||
self.__run_num += 1
|
||||
format_log(ret)
|
||||
|
Loading…
Reference in New Issue
Block a user