mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Bring salt-ssh pillar.get in line with mainline pillar.get
Fixes #22131
This commit is contained in:
parent
aee00c83df
commit
bc84502f46
1 changed files with 25 additions and 2 deletions
|
@ -2,12 +2,15 @@
|
|||
'''
|
||||
Extract the pillar data for this minion
|
||||
'''
|
||||
# Import python libs
|
||||
import collections
|
||||
|
||||
# Import salt libs
|
||||
import salt.pillar
|
||||
import salt.utils
|
||||
|
||||
|
||||
def get(key, default=''):
|
||||
def get(key, default='', merge=False, delimiter=':'):
|
||||
'''
|
||||
.. versionadded:: 0.14
|
||||
|
||||
|
@ -24,13 +27,33 @@ def get(key, default=''):
|
|||
|
||||
pkg:apache
|
||||
|
||||
merge
|
||||
Specify whether or not the retrieved values should be recursively
|
||||
merged into the passed default.
|
||||
|
||||
.. versionadded:: 2015.5.1
|
||||
|
||||
delimiter
|
||||
Specify an alternate delimiter to use when traversing a nested dict
|
||||
|
||||
.. versionadded:: 2015.5.1
|
||||
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' pillar.get pkg:apache
|
||||
'''
|
||||
return salt.utils.traverse_dict_and_list(__pillar__, key, default)
|
||||
if merge:
|
||||
ret = salt.utils.traverse_dict_and_list(__pillar__, key, {}, delimiter)
|
||||
if isinstance(ret, collections.Mapping) and \
|
||||
isinstance(default, collections.Mapping):
|
||||
return salt.utils.dictupdate.update(default, ret)
|
||||
|
||||
return salt.utils.traverse_dict_and_list(__pillar__,
|
||||
key,
|
||||
default,
|
||||
delimiter)
|
||||
|
||||
|
||||
def item(*args):
|
||||
|
|
Loading…
Add table
Reference in a new issue