Make requisite_ins throw errors when '.' in state

This changes the behavior added in #8823, causing requisite_ins to throw
errors instead of logging warnings when there is a '.' in the state that
is being required/watched/etc.
This commit is contained in:
Erik Johnson 2013-12-05 20:07:08 -06:00
parent bd9302ccfe
commit cab102b822

View File

@ -346,7 +346,7 @@ class Compiler(object):
'Invalid requisite type {0!r} ' 'Invalid requisite type {0!r} '
'in state {1!r}, in SLS ' 'in state {1!r}, in SLS '
'{2!r}. Requisite types must ' '{2!r}. Requisite types must '
'not contain periods, did you ' 'not contain dots, did you '
'mean {3!r}?'.format( 'mean {3!r}?'.format(
req_key, req_key,
name, name,
@ -823,7 +823,7 @@ class State(object):
'Invalid requisite type {0!r} ' 'Invalid requisite type {0!r} '
'in state {1!r}, in SLS ' 'in state {1!r}, in SLS '
'{2!r}. Requisite types must ' '{2!r}. Requisite types must '
'not contain periods, did you ' 'not contain dots, did you '
'mean {3!r}?'.format( 'mean {3!r}?'.format(
req_key, req_key,
name, name,
@ -1090,6 +1090,7 @@ class State(object):
]) ])
req_in_all = req_in.union(set(['require', 'watch'])) req_in_all = req_in.union(set(['require', 'watch']))
extend = {} extend = {}
errors = []
for id_, body in high.items(): for id_, body in high.items():
if not isinstance(body, dict): if not isinstance(body, dict):
continue continue
@ -1119,11 +1120,18 @@ class State(object):
if name not in extend: if name not in extend:
extend[name] = {} extend[name] = {}
if '.' in _state: if '.' in _state:
log.warning( errors.append((
'Bad requisite syntax in {0} : {1} for {2},' 'Invalid requisite in {0}: {1} for '
' requisites should not contain any dot' '{2}, in SLS {3!r}. Requisites must '
.format(rkey, _state, name) 'not contain dots, did you mean {4!r}?'
.format(
rkey,
_state,
name,
body['__sls__'],
_state[:_state.find('.')]
) )
))
_state = _state.split(".")[0] _state = _state.split(".")[0]
if _state not in extend[name]: if _state not in extend[name]:
extend[name][_state] = [] extend[name][_state] = []
@ -1155,11 +1163,18 @@ class State(object):
_state = next(iter(ind)) _state = next(iter(ind))
name = ind[_state] name = ind[_state]
if '.' in _state: if '.' in _state:
log.warning( errors.append((
'Bad requisite syntax in {0} : {1} for {2},' 'Invalid requisite in {0}: {1} for '
' requisites should not contain any dot' '{2}, in SLS {3!r}. Requisites must '
.format(rkey, _state, name) 'not contain dots, did you mean {4!r}?'
.format(
rkey,
_state,
name,
body['__sls__'],
_state[:_state.find('.')]
) )
))
_state = _state.split(".")[0] _state = _state.split(".")[0]
if key == 'prereq_in': if key == 'prereq_in':
# Add prerequired to origin # Add prerequired to origin
@ -1259,7 +1274,9 @@ class State(object):
high['__extend__'] = [] high['__extend__'] = []
for key, val in extend.items(): for key, val in extend.items():
high['__extend__'].append({key: val}) high['__extend__'].append({key: val})
return self.reconcile_extend(high) req_in_high, req_in_errors = self.reconcile_extend(high)
errors.extend(req_in_errors)
return req_in_high, errors
def call(self, low, chunks=None, running=None): def call(self, low, chunks=None, running=None):
''' '''