You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by no...@apache.org on 2020/12/29 12:30:49 UTC

[buildstream] 06/07: Add source plugin node validations

This is an automated email from the ASF dual-hosted git repository.

not-in-ldap pushed a commit to branch validation
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit be94c716210b7e9530be67dd20a8c625d7b731ae
Author: Tristan Maat <tr...@codethink.co.uk>
AuthorDate: Thu Sep 7 15:40:57 2017 +0100

    Add source plugin node validations
---
 buildstream/plugins/sources/bzr.py           | 2 ++
 buildstream/plugins/sources/git.py           | 2 ++
 buildstream/plugins/sources/local.py         | 2 ++
 buildstream/plugins/sources/ostree.py        | 2 ++
 buildstream/plugins/sources/tar.py           | 5 +++++
 tests/project/data/plugins/sources/custom.py | 1 +
 6 files changed, 14 insertions(+)

diff --git a/buildstream/plugins/sources/bzr.py b/buildstream/plugins/sources/bzr.py
index 42d3482..e74d87f 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, ['kind', 'url', 'track', 'ref'])
+
         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 e1cac97..dfc8e61 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, ['kind', 'url', 'track', 'ref', 'submodules'])
+
         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 a2f0992..2611a6f 100644
--- a/buildstream/plugins/sources/local.py
+++ b/buildstream/plugins/sources/local.py
@@ -45,6 +45,8 @@ class LocalSource(Source):
     def configure(self, node):
         project = self.get_project()
 
+        self.node_validate(node, ['path', 'kind', 'directory'])
+
         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 f08afc5..f1cec28 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, ['kind', 'url', 'ref', 'track', 'gpg-key'])
+
         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 f174c79..f0facdc 100644
--- a/buildstream/plugins/sources/tar.py
+++ b/buildstream/plugins/sources/tar.py
@@ -62,6 +62,11 @@ class TarSource(Source):
     def configure(self, node):
         project = self.get_project()
 
+        self.node_validate(node, [
+            'kind', 'url', 'ref', 'base-dir',
+            'track', 'directory', 'sha256sum'
+        ])
+
         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/tests/project/data/plugins/sources/custom.py b/tests/project/data/plugins/sources/custom.py
index c3cddb3..411b0b9 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'])
         self.configuration = self.node_get_member(node, str, "configuration")
 
     def preflight(self):