diff options
author | James Ennis <james.ennis@codethink.co.uk> | 2019-03-27 15:47:34 +0000 |
---|---|---|
committer | Daniel Silverstone <daniel.silverstone@codethink.co.uk> | 2019-03-27 21:26:07 +0000 |
commit | 1f821e2418c0ae8d9903fe765b480cea636ed736 (patch) | |
tree | 872399a01ec0f8b738d5e01e19879e9f563ad517 | |
parent | f4e4b76f0141e6d82ea7f6a1122ddb143dbaf6a3 (diff) | |
download | buildstream-1f821e2418c0ae8d9903fe765b480cea636ed736.tar.gz |
_basecache.py: Raise appropriate error if 'artifacts' is not dict/list of dictsshared/yaml-rework
-rw-r--r-- | buildstream/_basecache.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/buildstream/_basecache.py b/buildstream/_basecache.py index 1ca03cbf5..af3fe9bb7 100644 --- a/buildstream/_basecache.py +++ b/buildstream/_basecache.py @@ -73,16 +73,17 @@ class BaseCache(): try: artifacts = [_yaml.node_get(config_node, dict, cls.config_node_name)] except LoadError: - artifacts = _yaml.node_get(config_node, list, cls.config_node_name, default_value=[]) + try: + artifacts = _yaml.node_get(config_node, list, cls.config_node_name, default_value=[]) + except LoadError: + provenance = _yaml.node_get_provenance(config_node, key=cls.config_node_name) + raise _yaml.LoadError(_yaml.LoadErrorReason.INVALID_DATA, + "%s: 'artifacts' must be a single 'url:' mapping, or a list of mappings" % + (str(provenance))) + + for spec_node in artifacts: + cache_specs.append(cls.spec_class._new_from_config_node(spec_node, basedir)) - if isinstance(artifacts, list): - for spec_node in artifacts: - cache_specs.append(cls.spec_class._new_from_config_node(spec_node, basedir)) - else: - provenance = _yaml.node_get_provenance(config_node, key=cls.config_node_name) - raise _yaml.LoadError(_yaml.LoadErrorReason.INVALID_DATA, - "%s: 'artifacts' must be a single 'url:' mapping, or a list of mappings" % - (str(provenance))) return cache_specs # _configured_remote_cache_specs(): |