- YAML exceptions are now re-reaised as SaltRenderErrors
- Duplicate ID's in single state files now result in errors, and not
  just warnings. This is now consistent with the how conflicting ID's in
  separate state files are handled.
This commit is contained in:
Emil Stenqvist 2013-11-15 22:20:46 +01:00
parent c27bd94162
commit 7ec6bfbb8b
2 changed files with 4 additions and 2 deletions

View File

@ -5,6 +5,7 @@ from __future__ import absolute_import
import logging
import warnings
from yaml.scanner import ScannerError
from yaml.constructor import ConstructorError
# Import salt libs
from salt.utils.yamlloader import CustomLoader, load
@ -44,6 +45,8 @@ def render(yaml_data, saltenv='base', sls='', argline='', **kws):
err_type = _ERROR_MAP.get(exc.problem, 'Unknown yaml render error')
line_num = exc.problem_mark.line + 1
raise SaltRenderError(err_type, line_num, exc.problem_mark.buffer)
except ConstructorError as exc:
raise SaltRenderError(exc)
if len(warn_list) > 0:
for item in warn_list:
log.warn(

View File

@ -77,8 +77,7 @@ class CustomLoader(yaml.SafeLoader):
raise ConstructorError(err)
value = self.construct_object(value_node, deep=deep)
if key in mapping:
warnings.warn(
'Duplicate Key: "{0}"'.format(key), DuplicateKeyWarning)
raise ConstructorError('Conflicting ID "{0}"'.format(key))
mapping[key] = value
return mapping