diff --git a/plugins/builder/osbuild.py b/plugins/builder/osbuild.py index 45d3e69..5dbe5f3 100644 --- a/plugins/builder/osbuild.py +++ b/plugins/builder/osbuild.py @@ -416,7 +416,9 @@ class OSBuildImage(BaseTaskHandler): if not status.is_success: raise koji.BuildError(f"Compose failed (id: {cid})") - self.tag_build(target_info["dest_tag"], bid) + # Build was successful, tag it + if not opts.get('skip_tag'): + self.tag_build(target_info["dest_tag"], bid) result = { "composer": { diff --git a/plugins/cli/osbuild.py b/plugins/cli/osbuild.py index 0a05e1c..7c5605e 100755 --- a/plugins/cli/osbuild.py +++ b/plugins/cli/osbuild.py @@ -30,6 +30,8 @@ def parse_args(argv): parser.add_option("--image-type", metavar="TYPE", help='Request an image-type [default: qcow2]', type=str, action="append", default=[]) + parser.add_option("--skip-tag", action="store_true", + help=_("Do not attempt to tag package")) parser.add_option("--wait", action="store_true", help=_("Wait on the image creation, even if running in the background")) @@ -78,6 +80,9 @@ def handle_osbuild_image(options, session, argv): if args.repo: opts["repo"] = args.repo + if args.skip_tag: + opts["skip_tag"] = True + # Do some early checks to be able to give quick feedback check_target(session, target) diff --git a/plugins/hub/osbuild.py b/plugins/hub/osbuild.py index 21e062d..811dbd2 100644 --- a/plugins/hub/osbuild.py +++ b/plugins/hub/osbuild.py @@ -64,6 +64,10 @@ OSBUILD_IMAGE_SCHEMA = { "release": { "type": "string", "description": "Release override" + }, + "skip_tag": { + "type": "boolean", + "description": "Omit tagging the result" } } } diff --git a/test/unit/test_builder.py b/test/unit/test_builder.py index 299583d..1f4aa74 100644 --- a/test/unit/test_builder.py +++ b/test/unit/test_builder.py @@ -536,9 +536,35 @@ class TestBuilderPlugin(PluginTest): assert res, "invalid compose result" self.uploads.assert_upload("compose-request.json") + with self.assertRaises(AssertionError): self.uploads.assert_upload("x86_64-image_type.log.json") + @httpretty.activate + def test_skip_tag(self): + # Simulate a successful compose, where the tagging + # should be skipped + session = self.mock_session() + handler = self.make_handler(session=session) + + url = self.plugin.DEFAULT_COMPOSER_URL + composer = MockComposer(url) + composer.httpretty_regsiter() + + args = ["name", "version", "distro", + ["image_type"], + "fedora-candidate", + composer.architectures, + {"skip_tag": True}] + + res = handler.handler(*args) + assert res, "invalid compose result" + + self.uploads.assert_upload("compose-request.json") + + # build must *not* have been tagged + self.assertEqual(len(session.host.tags), 0) + @httpretty.activate def test_cli_compose_success(self): # Check the basic usage of the plugin as a stand-alone client diff --git a/test/unit/test_cli.py b/test/unit/test_cli.py index 368438c..1189cfa 100644 --- a/test/unit/test_cli.py +++ b/test/unit/test_cli.py @@ -83,7 +83,8 @@ class TestCliPlugin(PluginTest): # optional keyword arguments "--repo", "https://first.repo", "--repo", "https://second.repo", - "--release", "20200202.n2" + "--release", "20200202.n2", + "--skip-tag" ] expected_args = ["name", "version", "distro", @@ -93,7 +94,8 @@ class TestCliPlugin(PluginTest): expected_opts = { "release": "20200202.n2", - "repo": ["https://first.repo", "https://second.repo"] + "repo": ["https://first.repo", "https://second.repo"], + "skip_tag": True } task_result = {"compose_id": "42", "build_id": 23} diff --git a/test/unit/test_hub.py b/test/unit/test_hub.py index a297c46..7dd3903 100644 --- a/test/unit/test_hub.py +++ b/test/unit/test_hub.py @@ -43,7 +43,8 @@ class TestHubPlugin(PluginTest): context = self.mock_koji_context() opts = {"repo": ["repo1", "repo2"], - "release": "1.2.3"} + "release": "1.2.3", + "skip_tag": True} args = ["name", "version", "distro", ["image_type"], "target",