summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <ben.c.schubert@gmail.com>2019-07-03 18:01:30 +0100
committerBenjamin Schubert <ben.c.schubert@gmail.com>2019-07-04 10:14:02 +0100
commit59da3304aaf6e320ec111f9e1c660be56d1f051b (patch)
tree308ca3ccc41747776a2ac8854ebaa478abb9c070
parentc7a7e44838a0df64088924caecb9fea1ef9e91af (diff)
downloadbuildstream-bschubert/node-api-novalidate.tar.gz
_yaml: Remove 'node_validate' and replace by 'MappingNode.validate_keys'bschubert/node-api-novalidate
- adapt all call sites to use the new API
-rw-r--r--src/buildstream/_cas/casremote.py2
-rw-r--r--src/buildstream/_context.py15
-rw-r--r--src/buildstream/_gitsourcebase.py4
-rw-r--r--src/buildstream/_loader/loadelement.py4
-rw-r--r--src/buildstream/_loader/types.pyx4
-rw-r--r--src/buildstream/_options/optionbool.py3
-rw-r--r--src/buildstream/_options/optionenum.py2
-rw-r--r--src/buildstream/_options/optionflags.py2
-rw-r--r--src/buildstream/_project.py12
-rw-r--r--src/buildstream/_projectrefs.py2
-rw-r--r--src/buildstream/_yaml.pxd2
-rw-r--r--src/buildstream/_yaml.pyx51
-rw-r--r--src/buildstream/buildelement.py2
-rw-r--r--src/buildstream/element.py2
-rw-r--r--src/buildstream/plugin.py27
-rw-r--r--src/buildstream/plugins/elements/compose.py2
-rw-r--r--src/buildstream/plugins/elements/filter.py2
-rw-r--r--src/buildstream/plugins/elements/import.py2
-rw-r--r--src/buildstream/plugins/elements/script.py2
-rw-r--r--src/buildstream/plugins/sources/bzr.py2
-rw-r--r--src/buildstream/plugins/sources/local.py2
-rw-r--r--src/buildstream/plugins/sources/pip.py2
-rw-r--r--src/buildstream/plugins/sources/remote.py2
-rw-r--r--src/buildstream/plugins/sources/tar.py2
-rw-r--r--src/buildstream/plugins/sources/zip.py2
-rw-r--r--src/buildstream/sandbox/_sandboxremote.py8
-rw-r--r--src/buildstream/source.py2
-rw-r--r--tests/elements/filter/basic/element_plugins/dynamic.py2
-rw-r--r--tests/internals/yaml.py6
-rw-r--r--tests/sources/previous_source_access/plugins/sources/foo_transform.py2
30 files changed, 71 insertions, 103 deletions
diff --git a/src/buildstream/_cas/casremote.py b/src/buildstream/_cas/casremote.py
index 56cfea20f..dac92aa2a 100644
--- a/src/buildstream/_cas/casremote.py
+++ b/src/buildstream/_cas/casremote.py
@@ -31,7 +31,7 @@ class CASRemoteSpec(namedtuple('CASRemoteSpec', 'url push server_cert client_key
#
@staticmethod
def _new_from_config_node(spec_node, basedir=None):
- _yaml.node_validate(spec_node, ['url', 'push', 'server-cert', 'client-key', 'client-cert', 'instance-name'])
+ spec_node.validate_keys(['url', 'push', 'server-cert', 'client-key', 'client-cert', 'instance-name'])
url = spec_node.get_str('url')
push = spec_node.get_bool('push', default=False)
if not url:
diff --git a/src/buildstream/_context.py b/src/buildstream/_context.py
index 9b0db39d7..c1d368a22 100644
--- a/src/buildstream/_context.py
+++ b/src/buildstream/_context.py
@@ -212,7 +212,7 @@ class Context():
raise LoadError(LoadErrorReason.INVALID_DATA,
"artifactdir is obsolete")
- _yaml.node_validate(defaults, [
+ defaults.validate_keys([
'cachedir', 'sourcedir', 'builddir', 'logdir', 'scheduler',
'artifacts', 'source-caches', 'logging', 'projects', 'cache', 'prompt',
'workspacedir', 'remote-execution',
@@ -252,7 +252,7 @@ class Context():
# We need to find the first existing directory in the path of our
# cachedir - the cachedir may not have been created yet.
cache = defaults.get_mapping('cache')
- _yaml.node_validate(cache, ['quota', 'pull-buildtrees', 'cache-buildtrees'])
+ cache.validate_keys(['quota', 'pull-buildtrees', 'cache-buildtrees'])
self.config_cache_quota_string = cache.get_str('quota')
try:
@@ -281,7 +281,7 @@ class Context():
# Load logging config
logging = defaults.get_mapping('logging')
- _yaml.node_validate(logging, [
+ logging.validate_keys([
'key-length', 'verbose',
'error-lines', 'message-lines',
'debug', 'element-format', 'message-format'
@@ -297,7 +297,7 @@ class Context():
# Load scheduler config
scheduler = defaults.get_mapping('scheduler')
- _yaml.node_validate(scheduler, [
+ scheduler.validate_keys([
'on-error', 'fetchers', 'builders',
'pushers', 'network-retries'
])
@@ -314,10 +314,9 @@ class Context():
# Shallow validation of overrides, parts of buildstream which rely
# on the overrides are expected to validate elsewhere.
for overrides in self._project_overrides.values():
- _yaml.node_validate(overrides,
- ['artifacts', 'source-caches', 'options',
- 'strict', 'default-mirror',
- 'remote-execution'])
+ overrides.validate_keys(['artifacts', 'source-caches', 'options',
+ 'strict', 'default-mirror',
+ 'remote-execution'])
@property
def artifactcache(self):
diff --git a/src/buildstream/_gitsourcebase.py b/src/buildstream/_gitsourcebase.py
index 5ed844bbe..311bfca08 100644
--- a/src/buildstream/_gitsourcebase.py
+++ b/src/buildstream/_gitsourcebase.py
@@ -381,11 +381,11 @@ class _GitSourceBase(Source):
config_keys = ['url', 'track', 'ref', 'submodules',
'checkout-submodules', 'ref-format',
'track-tags', 'tags']
- self.node_validate(node, config_keys + Source.COMMON_CONFIG_KEYS)
+ node.validate_keys(config_keys + Source.COMMON_CONFIG_KEYS)
tags_node = node.get_sequence('tags', [])
for tag_node in tags_node:
- self.node_validate(tag_node, ['tag', 'commit', 'annotated'])
+ tag_node.validate_keys(['tag', 'commit', 'annotated'])
tags = self._load_tags(node)
self.track_tags = node.get_bool('track-tags', default=False)
diff --git a/src/buildstream/_loader/loadelement.py b/src/buildstream/_loader/loadelement.py
index 850b41a67..79b3d2bff 100644
--- a/src/buildstream/_loader/loadelement.py
+++ b/src/buildstream/_loader/loadelement.py
@@ -22,8 +22,6 @@ from itertools import count
from pyroaring import BitMap, FrozenBitMap # pylint: disable=no-name-in-module
-from .. import _yaml
-
# LoadElement():
#
@@ -82,7 +80,7 @@ class LoadElement():
self.full_name = self.name
# Ensure the root node is valid
- _yaml.node_validate(self.node, [
+ self.node.validate_keys([
'kind', 'depends', 'sources', 'sandbox',
'variables', 'environment', 'environment-nocache',
'config', 'public', 'description',
diff --git a/src/buildstream/_loader/types.pyx b/src/buildstream/_loader/types.pyx
index 3a415afc9..5b8388e28 100644
--- a/src/buildstream/_loader/types.pyx
+++ b/src/buildstream/_loader/types.pyx
@@ -79,10 +79,10 @@ cdef class Dependency:
elif type(dep) is _yaml.MappingNode:
if default_dep_type:
- _yaml.node_validate(<_yaml.Node> dep, ['filename', 'junction'])
+ (<_yaml.MappingNode> dep).validate_keys(['filename', 'junction'])
dep_type = default_dep_type
else:
- _yaml.node_validate(<_yaml.Node> dep, ['filename', 'type', 'junction'])
+ (<_yaml.MappingNode> dep).validate_keys(['filename', 'type', 'junction'])
# Make type optional, for this we set it to None
dep_type = (<_yaml.MappingNode> dep).get_str(<str> Symbol.TYPE, None)
diff --git a/src/buildstream/_options/optionbool.py b/src/buildstream/_options/optionbool.py
index 1e5935e48..28ab71278 100644
--- a/src/buildstream/_options/optionbool.py
+++ b/src/buildstream/_options/optionbool.py
@@ -17,7 +17,6 @@
# Authors:
# Tristan Van Berkom <tristan.vanberkom@codethink.co.uk>
-from .. import _yaml
from .._exceptions import LoadError, LoadErrorReason
from .option import Option, OPTION_SYMBOLS
@@ -33,7 +32,7 @@ class OptionBool(Option):
def load(self, node):
super().load(node)
- _yaml.node_validate(node, OPTION_SYMBOLS + ['default'])
+ node.validate_keys(OPTION_SYMBOLS + ['default'])
self.value = node.get_bool('default')
def load_value(self, node, *, transform=None):
diff --git a/src/buildstream/_options/optionenum.py b/src/buildstream/_options/optionenum.py
index f04cecd8b..477fe1ed9 100644
--- a/src/buildstream/_options/optionenum.py
+++ b/src/buildstream/_options/optionenum.py
@@ -44,7 +44,7 @@ class OptionEnum(Option):
if allow_default_definition:
valid_symbols += ['default']
- _yaml.node_validate(node, valid_symbols)
+ node.validate_keys(valid_symbols)
self.values = node.get_sequence('values', default=[]).as_str_list()
if not self.values:
diff --git a/src/buildstream/_options/optionflags.py b/src/buildstream/_options/optionflags.py
index c9758e403..1d86361d8 100644
--- a/src/buildstream/_options/optionflags.py
+++ b/src/buildstream/_options/optionflags.py
@@ -44,7 +44,7 @@ class OptionFlags(Option):
if allow_value_definitions:
valid_symbols += ['values']
- _yaml.node_validate(node, valid_symbols)
+ node.validate_keys(valid_symbols)
# Allow subclass to define the valid values
self.values = self.load_valid_values(node)
diff --git a/src/buildstream/_project.py b/src/buildstream/_project.py
index 1a22e0b06..6bae63a33 100644
--- a/src/buildstream/_project.py
+++ b/src/buildstream/_project.py
@@ -328,7 +328,7 @@ class Project():
return path_str
def _validate_node(self, node):
- _yaml.node_validate(node, [
+ node.validate_keys([
'format-version',
'element-path', 'variables',
'environment', 'environment-nocache',
@@ -602,7 +602,7 @@ class Project():
self.first_pass_config.options = OptionPool(self.element_path)
defaults = pre_config_node.get_mapping('defaults')
- _yaml.node_validate(defaults, ['targets'])
+ defaults.validate_keys(['targets'])
self._default_targets = defaults.get_sequence("targets").as_str_list()
# Fatal warnings
@@ -710,7 +710,7 @@ class Project():
# Parse shell options
shell_options = config.get_mapping('shell')
- _yaml.node_validate(shell_options, ['command', 'environment', 'host-files'])
+ shell_options.validate_keys(['command', 'environment', 'host-files'])
self._shell_command = shell_options.get_sequence('command').as_str_list()
# Perform environment expansion right away
@@ -726,7 +726,7 @@ class Project():
mount = HostMount(host_file)
else:
# Some validation
- _yaml.node_validate(host_file, ['path', 'host_path', 'optional'])
+ host_file.validate_keys(['path', 'host_path', 'optional'])
# Parse the host mount
path = host_file.get_str('path')
@@ -813,7 +813,7 @@ class Project():
allowed_mirror_fields = [
'name', 'aliases'
]
- _yaml.node_validate(mirror, allowed_mirror_fields)
+ mirror.validate_keys(allowed_mirror_fields)
mirror_name = mirror.get_str('name')
alias_mappings = {}
for alias_mapping, uris in mirror.get_mapping('aliases').items():
@@ -877,7 +877,7 @@ class Project():
'package-name', 'path',
]
allowed_origins = ['core', 'local', 'pip']
- _yaml.node_validate(origin, allowed_origin_fields)
+ origin.validate_keys(allowed_origin_fields)
origin_value = origin.get_str('origin')
if origin_value not in allowed_origins:
diff --git a/src/buildstream/_projectrefs.py b/src/buildstream/_projectrefs.py
index a46765250..cee74dc11 100644
--- a/src/buildstream/_projectrefs.py
+++ b/src/buildstream/_projectrefs.py
@@ -82,7 +82,7 @@ class ProjectRefs():
self._toplevel_node = _yaml.new_synthetic_file(self._fullpath)
self._toplevel_save = self._toplevel_node
- _yaml.node_validate(self._toplevel_node, ['projects'])
+ self._toplevel_node.validate_keys(['projects'])
# Ensure we create our toplevel entry point on the fly here
for node in [self._toplevel_node, self._toplevel_save]:
diff --git a/src/buildstream/_yaml.pxd b/src/buildstream/_yaml.pxd
index d7109bba5..3ea788866 100644
--- a/src/buildstream/_yaml.pxd
+++ b/src/buildstream/_yaml.pxd
@@ -51,6 +51,7 @@ cdef class MappingNode(Node):
cpdef object items(self)
cpdef list keys(self)
cpdef void safe_del(self, str key)
+ cpdef void validate_keys(self, list valid_keys) except *
cpdef object values(self)
cdef void _composite(self, MappingNode target, list path=*) except *
@@ -83,5 +84,4 @@ cdef class ProvenanceInformation:
cdef public bint is_synthetic
-cpdef void node_validate(Node node, list valid_keys) except *
cpdef ProvenanceInformation node_get_provenance(Node node, str key=*, list indices=*)
diff --git a/src/buildstream/_yaml.pyx b/src/buildstream/_yaml.pyx
index b67227d7b..ade8aaa71 100644
--- a/src/buildstream/_yaml.pyx
+++ b/src/buildstream/_yaml.pyx
@@ -375,6 +375,30 @@ cdef class MappingNode(Node):
except KeyError:
pass
+ # validate_keys()
+ #
+ # Validate the node so as to ensure the user has not specified
+ # any keys which are unrecognized by buildstream (usually this
+ # means a typo which would otherwise not trigger an error).
+ #
+ # Args:
+ # valid_keys (list): A list of valid keys for the specified node
+ #
+ # Raises:
+ # LoadError: In the case that the specified node contained
+ # one or more invalid keys
+ #
+ cpdef void validate_keys(self, list valid_keys) except *:
+ # Probably the fastest way to do this: https://stackoverflow.com/a/23062482
+ cdef set valid_keys_set = set(valid_keys)
+ cdef str key
+
+ for key in self.value:
+ if key not in valid_keys_set:
+ provenance = node_get_provenance(self, key=key)
+ raise LoadError(LoadErrorReason.INVALID_DATA,
+ "{}: Unexpected key: {}".format(provenance, key))
+
cpdef object values(self):
return self.value.values()
@@ -1180,33 +1204,6 @@ cdef Node _new_node_from_list(list inlist, Node ref_node):
return ret
-# node_validate()
-#
-# Validate the node so as to ensure the user has not specified
-# any keys which are unrecognized by buildstream (usually this
-# means a typo which would otherwise not trigger an error).
-#
-# Args:
-# node (Node): A dictionary loaded from YAML
-# valid_keys (list): A list of valid keys for the specified node
-#
-# Raises:
-# LoadError: In the case that the specified node contained
-# one or more invalid keys
-#
-cpdef void node_validate(Node node, list valid_keys) except *:
-
- # Probably the fastest way to do this: https://stackoverflow.com/a/23062482
- cdef set valid_keys_set = set(valid_keys)
- cdef str key
-
- for key in node.value:
- if key not in valid_keys_set:
- provenance = node_get_provenance(node, key=key)
- raise LoadError(LoadErrorReason.INVALID_DATA,
- "{}: Unexpected key: {}".format(provenance, key))
-
-
# assert_symbol_name()
#
# A helper function to check if a loaded string is a valid symbol
diff --git a/src/buildstream/buildelement.py b/src/buildstream/buildelement.py
index 48be1b83a..b79876843 100644
--- a/src/buildstream/buildelement.py
+++ b/src/buildstream/buildelement.py
@@ -169,7 +169,7 @@ class BuildElement(Element):
# FIXME: Currently this forcefully validates configurations
# for all BuildElement subclasses so they are unable to
# extend the configuration
- self.node_validate(node, _command_steps)
+ node.validate_keys(_command_steps)
for command_name in _legacy_command_steps:
if command_name in _command_steps:
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index 280eeb8f1..db657a3d2 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -2654,7 +2654,7 @@ class Element(Plugin):
sandbox_config._assert_fully_composited()
# Sandbox config, unlike others, has fixed members so we should validate them
- _yaml.node_validate(sandbox_config, ['build-uid', 'build-gid', 'build-os', 'build-arch'])
+ sandbox_config.validate_keys(['build-uid', 'build-gid', 'build-os', 'build-arch'])
build_arch = sandbox_config.get_str('build-arch', default=None)
if build_arch:
diff --git a/src/buildstream/plugin.py b/src/buildstream/plugin.py
index 3a6312092..2790c872f 100644
--- a/src/buildstream/plugin.py
+++ b/src/buildstream/plugin.py
@@ -280,7 +280,7 @@ class Plugin():
Plugin implementors should implement this method to read configuration
data and store it.
- The :func:`Plugin.node_validate() <buildstream.plugin.Plugin.node_validate>` method
+ The :func:`MappingNode.validate_keys() <buildstream._yaml.MappingNode.validate_keys>` method
should be used to ensure that the user has not specified keys in `node` which are unsupported
by the plugin.
@@ -427,31 +427,6 @@ class Plugin():
check_is_file=check_is_file,
check_is_dir=check_is_dir)
- def node_validate(self, node, valid_keys):
- """This should be used in :func:`~buildstream.plugin.Plugin.configure`
- implementations to assert that users have only entered
- valid configuration keys.
-
- Args:
- node (dict): A dictionary loaded from YAML
- valid_keys (iterable): A list of valid keys for the node
-
- Raises:
- :class:`.LoadError`: When an invalid key is found
-
- **Example:**
-
- .. code:: python
-
- # Ensure our node only contains valid autotools config keys
- self.node_validate(node, [
- 'configure-commands', 'build-commands',
- 'install-commands', 'strip-commands'
- ])
-
- """
- _yaml.node_validate(node, valid_keys)
-
def debug(self, brief, *, detail=None):
"""Print a debugging message
diff --git a/src/buildstream/plugins/elements/compose.py b/src/buildstream/plugins/elements/compose.py
index a9f18875f..83501d817 100644
--- a/src/buildstream/plugins/elements/compose.py
+++ b/src/buildstream/plugins/elements/compose.py
@@ -59,7 +59,7 @@ class ComposeElement(Element):
BST_VIRTUAL_DIRECTORY = True
def configure(self, node):
- self.node_validate(node, [
+ node.validate_keys([
'integrate', 'include', 'exclude', 'include-orphans'
])
diff --git a/src/buildstream/plugins/elements/filter.py b/src/buildstream/plugins/elements/filter.py
index bba56f351..7a21aa6eb 100644
--- a/src/buildstream/plugins/elements/filter.py
+++ b/src/buildstream/plugins/elements/filter.py
@@ -167,7 +167,7 @@ class FilterElement(Element):
BST_RUN_COMMANDS = False
def configure(self, node):
- self.node_validate(node, [
+ node.validate_keys([
'include', 'exclude', 'include-orphans'
])
diff --git a/src/buildstream/plugins/elements/import.py b/src/buildstream/plugins/elements/import.py
index 61e353dbc..6ae8cef46 100644
--- a/src/buildstream/plugins/elements/import.py
+++ b/src/buildstream/plugins/elements/import.py
@@ -45,7 +45,7 @@ class ImportElement(Element):
BST_RUN_COMMANDS = False
def configure(self, node):
- self.node_validate(node, [
+ node.validate_keys([
'source', 'target'
])
diff --git a/src/buildstream/plugins/elements/script.py b/src/buildstream/plugins/elements/script.py
index 1c694060c..a7b53e422 100644
--- a/src/buildstream/plugins/elements/script.py
+++ b/src/buildstream/plugins/elements/script.py
@@ -51,7 +51,7 @@ class ScriptElement(buildstream.ScriptElement):
elm = self.node_subst_member(n, 'element', None)
self.layout_add(elm, dst)
- self.node_validate(node, [
+ node.validate_keys([
'commands', 'root-read-only', 'layout'
])
diff --git a/src/buildstream/plugins/sources/bzr.py b/src/buildstream/plugins/sources/bzr.py
index 28bea1415..6fccf1e8b 100644
--- a/src/buildstream/plugins/sources/bzr.py
+++ b/src/buildstream/plugins/sources/bzr.py
@@ -67,7 +67,7 @@ class BzrSource(Source):
# pylint: disable=attribute-defined-outside-init
def configure(self, node):
- self.node_validate(node, ['url', 'track', 'ref', *Source.COMMON_CONFIG_KEYS])
+ node.validate_keys(['url', 'track', 'ref', *Source.COMMON_CONFIG_KEYS])
self.original_url = node.get_str('url')
self.tracking = node.get_str('track')
diff --git a/src/buildstream/plugins/sources/local.py b/src/buildstream/plugins/sources/local.py
index fba8af604..ff0cf1679 100644
--- a/src/buildstream/plugins/sources/local.py
+++ b/src/buildstream/plugins/sources/local.py
@@ -54,7 +54,7 @@ class LocalSource(Source):
self.__unique_key = None
def configure(self, node):
- self.node_validate(node, ['path', *Source.COMMON_CONFIG_KEYS])
+ node.validate_keys(['path', *Source.COMMON_CONFIG_KEYS])
self.path = self.node_get_project_path(node, 'path')
self.fullpath = os.path.join(self.get_project_directory(), self.path)
diff --git a/src/buildstream/plugins/sources/pip.py b/src/buildstream/plugins/sources/pip.py
index 627f26397..78c11fd89 100644
--- a/src/buildstream/plugins/sources/pip.py
+++ b/src/buildstream/plugins/sources/pip.py
@@ -109,7 +109,7 @@ class PipSource(Source):
BST_REQUIRES_PREVIOUS_SOURCES_TRACK = True
def configure(self, node):
- self.node_validate(node, ['url', 'packages', 'ref', 'requirements-files'] +
+ node.validate_keys(['url', 'packages', 'ref', 'requirements-files'] +
Source.COMMON_CONFIG_KEYS)
self.ref = node.get_str('ref', None)
self.original_url = node.get_str('url', _PYPI_INDEX_URL)
diff --git a/src/buildstream/plugins/sources/remote.py b/src/buildstream/plugins/sources/remote.py
index bb4c11325..68aa577fc 100644
--- a/src/buildstream/plugins/sources/remote.py
+++ b/src/buildstream/plugins/sources/remote.py
@@ -68,7 +68,7 @@ class RemoteSource(DownloadableFileSource):
if os.sep in self.filename:
raise SourceError('{}: filename parameter cannot contain directories'.format(self),
reason="filename-contains-directory")
- self.node_validate(node, DownloadableFileSource.COMMON_CONFIG_KEYS + ['filename', 'executable'])
+ node.validate_keys(DownloadableFileSource.COMMON_CONFIG_KEYS + ['filename', 'executable'])
def get_unique_key(self):
return super().get_unique_key() + [self.filename, self.executable]
diff --git a/src/buildstream/plugins/sources/tar.py b/src/buildstream/plugins/sources/tar.py
index ef2ee1d85..5da2aedfe 100644
--- a/src/buildstream/plugins/sources/tar.py
+++ b/src/buildstream/plugins/sources/tar.py
@@ -73,7 +73,7 @@ class TarSource(DownloadableFileSource):
super().configure(node)
self.base_dir = node.get_str('base-dir', '*')
- self.node_validate(node, DownloadableFileSource.COMMON_CONFIG_KEYS + ['base-dir'])
+ node.validate_keys(DownloadableFileSource.COMMON_CONFIG_KEYS + ['base-dir'])
def preflight(self):
self.host_lzip = None
diff --git a/src/buildstream/plugins/sources/zip.py b/src/buildstream/plugins/sources/zip.py
index 1724f0587..322be58d7 100644
--- a/src/buildstream/plugins/sources/zip.py
+++ b/src/buildstream/plugins/sources/zip.py
@@ -73,7 +73,7 @@ class ZipSource(DownloadableFileSource):
super().configure(node)
self.base_dir = node.get_str('base-dir', '*')
- self.node_validate(node, DownloadableFileSource.COMMON_CONFIG_KEYS + ['base-dir'])
+ node.validate_keys(DownloadableFileSource.COMMON_CONFIG_KEYS + ['base-dir'])
def get_unique_key(self):
return super().get_unique_key() + [self.base_dir]
diff --git a/src/buildstream/sandbox/_sandboxremote.py b/src/buildstream/sandbox/_sandboxremote.py
index a544331de..e46e987c4 100644
--- a/src/buildstream/sandbox/_sandboxremote.py
+++ b/src/buildstream/sandbox/_sandboxremote.py
@@ -127,7 +127,7 @@ class SandboxRemote(Sandbox):
service_keys = ['execution-service', 'storage-service', 'action-cache-service']
- _yaml.node_validate(remote_config, ['url', *service_keys])
+ remote_config.validate_keys(['url', *service_keys])
exec_config = require_node(remote_config, 'execution-service')
storage_config = require_node(remote_config, 'storage-service')
@@ -135,10 +135,10 @@ class SandboxRemote(Sandbox):
tls_keys = ['client-key', 'client-cert', 'server-cert']
- _yaml.node_validate(exec_config, ['url', 'instance-name', *tls_keys])
- _yaml.node_validate(storage_config, ['url', 'instance-name', *tls_keys])
+ exec_config.validate_keys(['url', 'instance-name', *tls_keys])
+ storage_config.validate_keys(['url', 'instance-name', *tls_keys])
if action_config:
- _yaml.node_validate(action_config, ['url', 'instance-name', *tls_keys])
+ action_config.validate_keys(['url', 'instance-name', *tls_keys])
# Maintain some backwards compatibility with older configs, in which
# 'url' was the only valid key for remote-execution:
diff --git a/src/buildstream/source.py b/src/buildstream/source.py
index 7d27ac9a6..35940bb5a 100644
--- a/src/buildstream/source.py
+++ b/src/buildstream/source.py
@@ -338,7 +338,7 @@ class Source(Plugin):
"""Common source config keys
Source config keys that must not be accessed in configure(), and
- should be checked for using node_validate().
+ should be checked for using node.validate_keys().
"""
#############################################################
diff --git a/tests/elements/filter/basic/element_plugins/dynamic.py b/tests/elements/filter/basic/element_plugins/dynamic.py
index 1ec7d4dd3..18e52c4b6 100644
--- a/tests/elements/filter/basic/element_plugins/dynamic.py
+++ b/tests/elements/filter/basic/element_plugins/dynamic.py
@@ -4,7 +4,7 @@ from buildstream import Element, Scope
# Copies files from the dependent element but inserts split-rules using dynamic data
class DynamicElement(Element):
def configure(self, node):
- self.node_validate(node, ['split-rules'])
+ node.validate_keys(['split-rules'])
self.split_rules = node.get_mapping('split-rules')
def preflight(self):
diff --git a/tests/internals/yaml.py b/tests/internals/yaml.py
index 3f6ef6cc9..f50d68585 100644
--- a/tests/internals/yaml.py
+++ b/tests/internals/yaml.py
@@ -72,7 +72,7 @@ def test_element_provenance(datafiles):
@pytest.mark.datafiles(os.path.join(DATA_DIR))
-def test_node_validate(datafiles):
+def test_mapping_validate_keys(datafiles):
valid = os.path.join(datafiles.dirname,
datafiles.basename,
@@ -83,12 +83,12 @@ def test_node_validate(datafiles):
base = _yaml.load(valid)
- _yaml.node_validate(base, ['kind', 'description', 'moods', 'children', 'extra'])
+ base.validate_keys(['kind', 'description', 'moods', 'children', 'extra'])
base = _yaml.load(invalid)
with pytest.raises(LoadError) as exc:
- _yaml.node_validate(base, ['kind', 'description', 'moods', 'children', 'extra'])
+ base.validate_keys(['kind', 'description', 'moods', 'children', 'extra'])
assert exc.value.reason == LoadErrorReason.INVALID_DATA
diff --git a/tests/sources/previous_source_access/plugins/sources/foo_transform.py b/tests/sources/previous_source_access/plugins/sources/foo_transform.py
index cd0f621d5..4b423a1b3 100644
--- a/tests/sources/previous_source_access/plugins/sources/foo_transform.py
+++ b/tests/sources/previous_source_access/plugins/sources/foo_transform.py
@@ -31,7 +31,7 @@ class FooTransformSource(Source):
return path
def configure(self, node):
- self.node_validate(node, ['ref', *Source.COMMON_CONFIG_KEYS])
+ node.validate_keys(['ref', *Source.COMMON_CONFIG_KEYS])
self.ref = node.get_str('ref', None)
def preflight(self):