From 6d674a0970f4bea051967990293ef88fd930bc71 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Fri, 5 Feb 2021 18:19:19 +0000 Subject: [PATCH] main_cli: detect format Now that meta.Index provides a way to detect the format given the input data, use that method instead of the hard-coded use of the version 1 format via the input. This should make the main entry point format independent. --- osbuild/main_cli.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/osbuild/main_cli.py b/osbuild/main_cli.py index c1b913de..5cc67741 100644 --- a/osbuild/main_cli.py +++ b/osbuild/main_cli.py @@ -15,7 +15,6 @@ import osbuild import osbuild.meta import osbuild.monitor from osbuild.objectstore import ObjectStore -from osbuild.formats import v1 as fmt RESET = "\033[0m" @@ -74,13 +73,21 @@ def parse_arguments(sys_argv): return parser.parse_args(sys_argv[1:]) -# pylint: disable=too-many-branches +# pylint: disable=too-many-branches,too-many-return-statements def osbuild_cli(): args = parse_arguments(sys.argv) desc = parse_manifest(args.manifest_path) - # first thing after parsing is validation of the input index = osbuild.meta.Index(args.libdir) + + # detect the format from the manifest description + info = index.detect_format_info(desc) + if not info: + print("Unsupported manifest format") + return 2 + fmt = info.module + + # first thing is validation of the manifest res = fmt.validate(desc, index) if not res: if args.json or args.inspect: