Skip to content

Commit 213f976

Browse files
committed
BaseHighsState.render_state now requires matches, which are already being generated by callers of render_state, so it's more efficient to pass it along than to generate it recursively.
1 parent 7ae8f76 commit 213f976

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

salt/state.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,7 +1442,7 @@ def load_dynamic(self, matches):
14421442
faux = {'state': 'file', 'fun': 'recurse'}
14431443
self.state.module_refresh(faux)
14441444

1445-
def render_state(self, sls, env, mods):
1445+
def render_state(self, sls, env, mods, matches):
14461446
'''
14471447
Render a state file and retrieve all of the include states
14481448
'''
@@ -1472,13 +1472,10 @@ def render_state(self, sls, env, mods):
14721472
'as a list'.format(sls))
14731473
errors.append(err)
14741474
else:
1475-
# Available environments to which this minion belongs
1476-
my_avail = self.top_matches(self.get_top()).keys()
1477-
14781475
for inc_sls in state.pop('include'):
14791476
# Subset of my_avail containing the include sls
14801477
my_env = [
1481-
aenv for aenv in my_avail
1478+
aenv for aenv in matches
14821479
if fnmatch.filter(self.avail[aenv], inc_sls)
14831480
]
14841481

@@ -1489,7 +1486,8 @@ def render_state(self, sls, env, mods):
14891486
nstate, mods, err = self.render_state(
14901487
inc_sls,
14911488
my_env[0] if len(my_env) == 1 else env,
1492-
mods
1489+
mods,
1490+
matches
14931491
)
14941492
if nstate:
14951493
state.update(nstate)
@@ -1500,7 +1498,7 @@ def render_state(self, sls, env, mods):
15001498
if not my_env:
15011499
msg = ('Unknown include: Specified SLS {0} is not available on the salt master '
15021500
'in any available environments {1} '
1503-
).format(inc_sls, ', '.join(my_avail))
1501+
).format(inc_sls, ', '.join(matches))
15041502
elif len(my_env) > 1:
15051503
msg = ('Ambiguous include: Specified SLS {0} is available on the salt master '
15061504
'in available environments {1}'
@@ -1610,7 +1608,7 @@ def render_highstate(self, matches):
16101608
mods = set()
16111609
for sls_match in states:
16121610
for sls in fnmatch.filter(self.avail[env], sls_match):
1613-
state, mods, err = self.render_state(sls, env, mods)
1611+
state, mods, err = self.render_state(sls, env, mods, matches)
16141612
# The extend members can not be treated as globally unique:
16151613
if '__extend__' in state and '__extend__' in highstate:
16161614
highstate['__extend__'].extend(state.pop('__extend__'))

0 commit comments

Comments
 (0)