From 7084c2a600fcb18e48507e4397e2ac7fb62735b9 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Fri, 15 Jan 2021 18:09:55 +0100 Subject: [PATCH] meta: support for inputs Inputs are modules like Stages, Assemblers and Sources. Add them as a new module klass to the various functions. Include them in the schema test, so the schema of all inputs is validated. Also sort the module classes alphabetically in the class mapping and class list. --- osbuild/meta.py | 7 ++++--- test/mod/test_osbuild.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/osbuild/meta.py b/osbuild/meta.py index c1843aa0..ea1718ef 100644 --- a/osbuild/meta.py +++ b/osbuild/meta.py @@ -359,9 +359,10 @@ class ModuleInfo: @staticmethod def module_class_to_directory(klass: str) -> str: mapping = { - "Stage": "stages", "Assembler": "assemblers", - "Source": "sources" + "Input": "inputs", + "Source": "sources", + "Stage": "stages", } return mapping.get(klass) @@ -419,7 +420,7 @@ class Index: with contextlib.suppress(FileNotFoundError): with open(path, "r") as f: schema = json.load(f) - elif klass in ["Stage", "Assembler", "Source"]: + elif klass in ["Assembler", "Input", "Source", "Stage"]: info = self.get_module_info(klass, name) if info: schema = info.schema diff --git a/test/mod/test_osbuild.py b/test/mod/test_osbuild.py index a5f65b72..0b5bdf79 100644 --- a/test/mod/test_osbuild.py +++ b/test/mod/test_osbuild.py @@ -124,7 +124,7 @@ class TestDescriptions(unittest.TestCase): index = osbuild.meta.Index(os.curdir) modules = [] - for klass in ("Stage", "Assembler", "Source"): + for klass in ("Assembler", "Input", "Source", "Stage"): mods = index.list_modules_for_class(klass) modules += [(klass, module) for module in mods]