summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Maat <tristan.maat@codethink.co.uk>2017-09-07 15:40:57 +0100
committerTristan Maat <tristan.maat@codethink.co.uk>2017-09-14 11:05:18 +0100
commitd56f472ddc6b6ff364aaa74cf1dac30be0d774de (patch)
tree9d21e68c469433f33387ab9639bf39627dcade65
parent80e53b1a3dd7bf21b55da86b7a982c3f3f5827a2 (diff)
downloadbuildstream-d56f472ddc6b6ff364aaa74cf1dac30be0d774de.tar.gz
Add source plugin node validations
-rw-r--r--buildstream/plugins/sources/bzr.py2
-rw-r--r--buildstream/plugins/sources/git.py2
-rw-r--r--buildstream/plugins/sources/local.py2
-rw-r--r--buildstream/plugins/sources/ostree.py2
-rw-r--r--buildstream/plugins/sources/tar.py2
-rw-r--r--buildstream/source.py7
-rw-r--r--tests/project/data/plugins/sources/custom.py1
-rw-r--r--tests/testutils/repo/tar.py2
8 files changed, 19 insertions, 1 deletions
diff --git a/buildstream/plugins/sources/bzr.py b/buildstream/plugins/sources/bzr.py
index 42d34828f..82ac711e7 100644
--- a/buildstream/plugins/sources/bzr.py
+++ b/buildstream/plugins/sources/bzr.py
@@ -58,6 +58,8 @@ from buildstream import utils
class BzrSource(Source):
def configure(self, node):
+ self.node_validate(node, ['url', 'track', 'ref'] + Source.COMMON_CONFIG_KEYS)
+
self.original_url = self.node_get_member(node, str, 'url')
self.tracking = self.node_get_member(node, str, 'track')
self.ref = self.node_get_member(node, str, 'ref', '') or None
diff --git a/buildstream/plugins/sources/git.py b/buildstream/plugins/sources/git.py
index e1cac9716..7610846b3 100644
--- a/buildstream/plugins/sources/git.py
+++ b/buildstream/plugins/sources/git.py
@@ -214,6 +214,8 @@ class GitSource(Source):
def configure(self, node):
ref = self.node_get_member(node, str, 'ref', '') or None
+ self.node_validate(node, ['url', 'track', 'ref', 'submodules'] + Source.COMMON_CONFIG_KEYS)
+
self.original_url = self.node_get_member(node, str, 'url')
self.mirror = GitMirror(self, '', self.original_url, ref)
self.tracking = self.node_get_member(node, str, 'track', '') or None
diff --git a/buildstream/plugins/sources/local.py b/buildstream/plugins/sources/local.py
index fef0d693a..9f02b0ed4 100644
--- a/buildstream/plugins/sources/local.py
+++ b/buildstream/plugins/sources/local.py
@@ -44,6 +44,8 @@ class LocalSource(Source):
def configure(self, node):
project = self.get_project()
+ self.node_validate(node, ['path'] + Source.COMMON_CONFIG_KEYS)
+
self.path = self.node_get_member(node, str, 'path')
self.fullpath = os.path.join(project.directory, self.path)
diff --git a/buildstream/plugins/sources/ostree.py b/buildstream/plugins/sources/ostree.py
index f08afc58f..d3a164101 100644
--- a/buildstream/plugins/sources/ostree.py
+++ b/buildstream/plugins/sources/ostree.py
@@ -63,6 +63,8 @@ class OSTreeSource(Source):
def configure(self, node):
project = self.get_project()
+ self.node_validate(node, ['url', 'ref', 'track', 'gpg-key'] + Source.COMMON_CONFIG_KEYS)
+
self.original_url = self.node_get_member(node, str, 'url')
self.url = project.translate_url(self.original_url)
self.ref = self.node_get_member(node, str, 'ref', '') or None
diff --git a/buildstream/plugins/sources/tar.py b/buildstream/plugins/sources/tar.py
index 07be703af..bc2891e18 100644
--- a/buildstream/plugins/sources/tar.py
+++ b/buildstream/plugins/sources/tar.py
@@ -61,6 +61,8 @@ class TarSource(Source):
def configure(self, node):
project = self.get_project()
+ self.node_validate(node, ['url', 'ref', 'base-dir'] + Source.COMMON_CONFIG_KEYS)
+
self.original_url = self.node_get_member(node, str, 'url')
self.ref = self.node_get_member(node, str, 'ref', '') or None
self.base_dir = self.node_get_member(node, str, 'base-dir', '*') or None
diff --git a/buildstream/source.py b/buildstream/source.py
index 09dbae138..a18910eb9 100644
--- a/buildstream/source.py
+++ b/buildstream/source.py
@@ -76,6 +76,13 @@ class Source(Plugin):
self.configure(meta.config)
+ COMMON_CONFIG_KEYS = ['kind', 'directory']
+ """Common source config keys
+
+ Source config keys that must not be accessed in configure(), and
+ should be checked for using node_validate().
+ """
+
def get_mirror_directory(self):
"""Fetches the directory where this source should store things
diff --git a/tests/project/data/plugins/sources/custom.py b/tests/project/data/plugins/sources/custom.py
index c3cddb355..def1d3cd1 100644
--- a/tests/project/data/plugins/sources/custom.py
+++ b/tests/project/data/plugins/sources/custom.py
@@ -5,6 +5,7 @@ class CustomSource(Source):
def configure(self, node):
print("Source Data: %s" % node)
+ self.node_validate(node, ['configuration'] + Source.COMMON_CONFIG_KEYS)
self.configuration = self.node_get_member(node, str, "configuration")
def preflight(self):
diff --git a/tests/testutils/repo/tar.py b/tests/testutils/repo/tar.py
index 430ebe427..194995b7b 100644
--- a/tests/testutils/repo/tar.py
+++ b/tests/testutils/repo/tar.py
@@ -23,7 +23,7 @@ class Tar(Repo):
config = {
'kind': 'tar',
'url': 'file://' + tarball,
- 'track': 'master',
+ # 'track': 'master', ## Not a thing according to TVB
'directory': ''
}
if ref is not None: