summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhillip Smyth <phillip.smyth@codethink.co.uk>2018-11-07 13:05:37 +0000
committerJürg Billeter <j@bitron.ch>2018-11-12 14:57:51 +0000
commitae5ccd766cdf531ba46c62e9d2b22b2812b6a195 (patch)
tree1074bbbef3332a3e61e7c95356b1d157b0bd0161
parente6e034516ad8050b76f271b130d66d3a135223b8 (diff)
downloadbuildstream-ae5ccd766cdf531ba46c62e9d2b22b2812b6a195.tar.gz
_project.py: Validate nodes early in Project._load
_project.py: Added validate_nodes() helper function to prevent duplicate lists element-path was being used before node validation resulting in uncaught errors
-rw-r--r--buildstream/_project.py26
1 files changed, 16 insertions, 10 deletions
diff --git a/buildstream/_project.py b/buildstream/_project.py
index 5280cf667..85c82b6e0 100644
--- a/buildstream/_project.py
+++ b/buildstream/_project.py
@@ -219,6 +219,19 @@ class Project():
return self._cache_key
+ def _validate_node(self, node):
+ _yaml.node_validate(node, [
+ 'format-version',
+ 'element-path', 'variables',
+ 'environment', 'environment-nocache',
+ 'split-rules', 'elements', 'plugins',
+ 'aliases', 'name',
+ 'artifacts', 'options',
+ 'fail-on-overlap', 'shell', 'fatal-warnings',
+ 'ref-storage', 'sandbox', 'mirrors', 'remote-execution',
+ 'sources', '(@)'
+ ])
+
# create_element()
#
# Instantiate and return an element
@@ -402,6 +415,8 @@ class Project():
"Project requested format version {}, but BuildStream {}.{} only supports up until format version {}"
.format(format_version, major, minor, BST_FORMAT_VERSION))
+ self._validate_node(pre_config_node)
+
# FIXME:
#
# Performing this check manually in the absense
@@ -467,16 +482,7 @@ class Project():
self._load_pass(config, self.config)
- _yaml.node_validate(config, [
- 'format-version',
- 'element-path', 'variables',
- 'environment', 'environment-nocache',
- 'split-rules', 'elements', 'plugins',
- 'aliases', 'name',
- 'artifacts', 'options',
- 'fail-on-overlap', 'shell', 'fatal-warnings',
- 'ref-storage', 'sandbox', 'mirrors', 'remote-execution'
- ])
+ self._validate_node(config)
#
# Now all YAML composition is done, from here on we just load