mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Merge pull request #40349 from ferringb/develop
ticket #40348: fix pillar include key nested support
This commit is contained in:
commit
d8cabca9a6
@ -688,9 +688,11 @@ class Pillar(object):
|
||||
)
|
||||
if nstate:
|
||||
if key:
|
||||
nstate = {
|
||||
key: nstate
|
||||
}
|
||||
# If key is x:y, convert it to {x: {y: nstate}}
|
||||
for key_fragment in reversed(key.split(":")):
|
||||
nstate = {
|
||||
key_fragment: nstate
|
||||
}
|
||||
|
||||
state = merge(
|
||||
state,
|
||||
|
@ -121,6 +121,36 @@ class PillarTestCase(TestCase):
|
||||
({'foo': 'bar2'}, [])
|
||||
)
|
||||
|
||||
# Test includes using empty key directive
|
||||
compile_template.side_effect = [
|
||||
{'foo': 'bar', 'include': [{'blah': {'key': ''}}]},
|
||||
{'foo': 'bar2'}
|
||||
]
|
||||
self.assertEqual(
|
||||
pillar.render_pillar({'base': ['foo.sls']}),
|
||||
({'foo': 'bar2'}, [])
|
||||
)
|
||||
|
||||
# Test includes using simple non-nested key
|
||||
compile_template.side_effect = [
|
||||
{'foo': 'bar', 'include': [{'blah': {'key': 'nested'}}]},
|
||||
{'foo': 'bar2'}
|
||||
]
|
||||
self.assertEqual(
|
||||
pillar.render_pillar({'base': ['foo.sls']}),
|
||||
({'foo': 'bar', 'nested': {'foo': 'bar2'}}, [])
|
||||
)
|
||||
|
||||
# Test includes using nested key
|
||||
compile_template.side_effect = [
|
||||
{'foo': 'bar', 'include': [{'blah': {'key': 'nested:level'}}]},
|
||||
{'foo': 'bar2'}
|
||||
]
|
||||
self.assertEqual(
|
||||
pillar.render_pillar({'base': ['foo.sls']}),
|
||||
({'foo': 'bar', 'nested': {'level': {'foo': 'bar2'}}}, [])
|
||||
)
|
||||
|
||||
@patch('salt.pillar.salt.fileclient.get_file_client', autospec=True)
|
||||
@patch('salt.pillar.salt.minion.Matcher') # autospec=True disabled due to py3 mock bug
|
||||
def test_topfile_order(self, Matcher, get_file_client):
|
||||
|
Loading…
Reference in New Issue
Block a user