Merge pull request #12553 from cheuschober/fix_pillar_get_merge_when_missing

Fixes an oversight in the new modules.pillar.get merge parameter
This commit is contained in:
Thomas S Hatch 2014-05-06 11:10:11 -06:00
commit 6f0dcd8b2b

View File

@ -3,6 +3,9 @@
Extract the pillar data for this minion
'''
# Import python libs
import collections
# Import third party libs
import yaml
@ -34,6 +37,11 @@ def get(key, default='', merge=False, delim=':'):
pkg:apache
merge
Specify whether or not the retrieved values should be recursively
merged into the passed default.
.. versionadded:: Helium
delim
Specify an alternate delimiter to use when traversing a nested dict
@ -47,8 +55,10 @@ def get(key, default='', merge=False, delim=':'):
salt '*' pillar.get pkg:apache
'''
if merge:
return salt.utils.dictupdate.update(default,
salt.utils.traverse_dict(__pillar__, key, '', delim))
ret = salt.utils.traverse_dict(__pillar__, key, {}, delim)
if isinstance(ret, collections.Mapping) and \
isinstance(default, collections.Mapping):
return salt.utils.dictupdate.update(default, ret)
return salt.utils.traverse_dict(__pillar__, key, default, delim)