mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Issue #8053
- 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:
parent
c27bd94162
commit
7ec6bfbb8b
@ -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(
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user