From a1b03e2b8026f33f66d663de9d7b84a8aa01775b Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Fri, 18 Sep 2020 14:20:53 +0200 Subject: [PATCH] builder: better and unified result value When returning the result from the task handler function, return a more complete and structured object in all cases. The name of the sub-object is named after the service the item belongs to; specifically composer is used for what belongs to (osbuild)-composer. --- plugins/builder/osbuild.py | 19 ++++++++++--------- test/unit/test_builder.py | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/plugins/builder/osbuild.py b/plugins/builder/osbuild.py index ec7dac1..67bd1ac 100644 --- a/plugins/builder/osbuild.py +++ b/plugins/builder/osbuild.py @@ -313,17 +313,18 @@ class OSBuildImage(BaseTaskHandler): self.logger.debug("Waiting for comose to finish") status = client.wait_for_compose(cid) - if not status.is_success: - self.logger.error("Compose failed: %s", str(status)) - return { - 'koji_builds': [] - } - return { - 'koji_builds': [bid], - 'composer_id': cid, - 'build': bid, + result = { + "status": status.status, + "composer": { + "server": self.composer_url, + "id": cid + }, + "koji": { + "build": bid + } } + return result # Stand alone osbuild composer API client executable diff --git a/test/unit/test_builder.py b/test/unit/test_builder.py index 04e4ebb..e4b8141 100644 --- a/test/unit/test_builder.py +++ b/test/unit/test_builder.py @@ -346,7 +346,7 @@ class TestBuilderPlugin(PluginTest): res = handler.handler(*args) assert res, "invalid compose result" - compose_id = res["composer_id"] + compose_id = res["composer"]["id"] compose = composer.composes.get(compose_id) self.assertIsNotNone(compose)