Merge pull request #45277 from rallytime/bp-45025

Back-port #45025 to 2017.7
This commit is contained in:
Nicole Thomas 2018-01-05 10:35:52 -05:00 committed by GitHub
commit f09d0e5fdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 7 deletions

View File

@ -664,6 +664,8 @@ class Pillar(object):
log.error(msg)
errors.append(msg)
else:
# render included state(s)
include_states = []
for sub_sls in state.pop('include'):
if isinstance(sub_sls, dict):
sub_sls, v = next(six.iteritems(sub_sls))
@ -685,16 +687,23 @@ class Pillar(object):
nstate = {
key_fragment: nstate
}
include_states.append(nstate)
if err:
errors += err
if include_states:
# merge included state(s) with the current state merged last
include_states.append(state)
state = None
for s in include_states:
if state is None:
state = s
else:
state = merge(
state,
nstate,
s,
self.merge_strategy,
self.opts.get('renderer', 'yaml'),
self.opts.get('pillar_merge_lists', False))
if err:
errors += err
return state, mods, errors
def render_pillar(self, matches, errors=None):

View File

@ -126,7 +126,7 @@ class PillarTestCase(TestCase):
]
self.assertEqual(
pillar.render_pillar({'base': ['foo.sls']}),
({'foo': 'bar2'}, [])
({'foo': 'bar'}, [])
)
# Test includes using empty key directive
@ -136,7 +136,7 @@ class PillarTestCase(TestCase):
]
self.assertEqual(
pillar.render_pillar({'base': ['foo.sls']}),
({'foo': 'bar2'}, [])
({'foo': 'bar'}, [])
)
# Test includes using simple non-nested key