diff --git a/plugins/builder/osbuild.py b/plugins/builder/osbuild.py index 0bcb081..3b608bc 100644 --- a/plugins/builder/osbuild.py +++ b/plugins/builder/osbuild.py @@ -642,7 +642,7 @@ class OSBuildImage(BaseTaskHandler): self.upload_json(status.as_dict(), "compose-status") # pylint: disable=arguments-differ - def handler(self, name, version, distro, image_types, target, arches, opts): + def handler(self, name, version, distro, image_type, target, arches, opts): """Main entry point for the task""" self.logger.debug("Building image via osbuild %s, %s, %s, %s", name, str(arches), str(target), str(opts)) @@ -676,9 +676,9 @@ class OSBuildImage(BaseTaskHandler): if not nvr.release: nvr.release = self.session.getNextRelease(nvr.as_dict()) - # Arches and image types - image_types = [self.map_koji_api_image_type(i) for i in image_types] - ireqs = [ImageRequest(a, i, repos) for a in arches for i in image_types] + # Arches and image type + image_type = self.map_koji_api_image_type(image_type) + ireqs = [ImageRequest(a, image_type, repos) for a in arches] # OStree specific options ostree = opts.get("ostree") @@ -757,15 +757,13 @@ def show_compose(cs): def compose_cmd(client: Client, args): nvr = NVR(args.name, args.version, args.release) images = [] - formats = args.format or ["guest-image"] - formats = [ - KOJIAPI_IMAGE_TYPES.get(f, f) for f in formats - ] + image_type = args.format + image_type = KOJIAPI_IMAGE_TYPES.get(image_type, image_type) repos = [Repository(url) for url in args.repo] - for fmt in formats: - for arch in args.arch: - ireq = ImageRequest(arch, fmt, repos) - images.append(ireq) + + for arch in args.arch: + ireq = ImageRequest(arch, image_type, repos) + images.append(ireq) kojidata = ComposeRequest.Koji(args.koji, 0, nvr) request = ComposeRequest(args.distro, images, kojidata) @@ -820,7 +818,7 @@ def main(): subpar.add_argument("--repo", metavar="REPO", help='The repository to use', type=str, action="append", default=[]) subpar.add_argument("--format", metavar="FORMAT", help='Request the image format [guest-image]', - action="append", type=str, default=[]) + type=str, default="guest-image") subpar.add_argument("--koji", metavar="URL", help='The koji url', default=DEFAULT_KOJIHUB_URL) subpar.set_defaults(cmd='compose') diff --git a/plugins/cli/osbuild.py b/plugins/cli/osbuild.py index ae6527c..6fc1f77 100755 --- a/plugins/cli/osbuild.py +++ b/plugins/cli/osbuild.py @@ -69,7 +69,7 @@ def parse_args(argv): "Maybe be used multiple times")) parser.add_option("--image-type", metavar="TYPE", help='Request an image-type [default: guest-image]', - type=str, action="append", default=[]) + type=str, default="guest-image") parser.add_option("--skip-tag", action="store_true", help="Do not attempt to tag package") parser.add_option("--wait", action="store_true", @@ -107,10 +107,7 @@ def handle_osbuild_image(options, session, argv): args = parse_args(argv) name, version, arch, target = args.name, args.version, args.arch, args.target - distro, image_types = args.distro, args.image_type - - if not image_types: - image_types = ["guest-image"] + distro, image_type = args.distro, args.image_type opts = {} @@ -152,12 +149,12 @@ def handle_osbuild_image(options, session, argv): print("distro:", distro) print("arches:", ", ".join(arch)) print("target:", target) - print("image types ", str(image_types)) + print("image type:", image_type) pprint(opts) kl.activate_session(session, options) - task_id = session.osbuildImage(name, version, distro, image_types, target, arch, opts=opts) + task_id = session.osbuildImage(name, version, distro, image_type, target, arch, opts=opts) if not options.quiet: print(f"Created task: {task_id}") diff --git a/plugins/hub/osbuild.py b/plugins/hub/osbuild.py index f95d352..615b73e 100644 --- a/plugins/hub/osbuild.py +++ b/plugins/hub/osbuild.py @@ -28,9 +28,8 @@ OSBUILD_IMAGE_SCHEMA = { "description": "Distribution" }, { - "type": "array", - "description": "Image Types", - "minItems": 1 + "type": "string", + "description": "Image Type", }, { "type": "string", @@ -120,10 +119,10 @@ OSBUILD_IMAGE_SCHEMA = { @koji.plugin.export -def osbuildImage(name, version, distro, image_types, target, arches, opts=None, priority=None): +def osbuildImage(name, version, distro, image_type, target, arches, opts=None, priority=None): """Create an image via osbuild""" context.session.assertPerm("image") - args = [name, version, distro, image_types, target, arches, opts] + args = [name, version, distro, image_type, target, arches, opts] task = {"channel": "image"} try: diff --git a/test/unit/test_builder.py b/test/unit/test_builder.py index 11f0c24..0c5d2ba 100644 --- a/test/unit/test_builder.py +++ b/test/unit/test_builder.py @@ -644,7 +644,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods handler = self.make_handler() args = ["name", "version", "distro", - ["image_type"], + "image_type", "fedora-candidate", ["x86_64"], {}] @@ -667,7 +667,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods arches = ["x86_64", "s390x"] repos = ["http://1.repo", "https://2.repo"] args = ["name", "version", "distro", - ["image_type"], + "image_type", "fedora-candidate", arches, {"repo": repos}] @@ -713,7 +713,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods handler = self.make_handler(session=session) args = ["name", "version", "distro", - ["image_type"], + "image_type", "fedora-candidate", ["x86_64"], {}] @@ -745,7 +745,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods composer.httpretty_register() args = ["name", "version", "distro", - ["image_type"], + "image_type", "fedora-candidate", composer.architectures, {}] @@ -773,7 +773,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods composer.httpretty_register() args = ["name", "version", "distro", - ["image_type"], + "image_type", "fedora-candidate", composer.architectures, {}] @@ -802,7 +802,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods for it in ("qcow2", "ec2", "ec2-ha", "ec2-sap"): args = ["name", "version", "distro", - [it], + it, "fedora-candidate", composer.architectures, {"skip_tag": True}] @@ -822,7 +822,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods composer.httpretty_register() args = ["name", "version", "distro", - ["image_type"], + "image_type", "fedora-candidate", composer.architectures, {"skip_tag": True}] @@ -889,7 +889,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods composer.oauth_activate(token_url) args = ["name", "version", "distro", - ["image_type"], + "image_type", "fedora-candidate", ["x86_64"], {}] @@ -931,7 +931,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods arches = ["x86_64"] repos = ["http://1.repo", "https://2.repo"] args = ["name", "version", "distro", - ["image_type"], + "image_type", "fedora-candidate", arches, {"repo": repos}] @@ -980,7 +980,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods arches = ["x86_64"] repos = ["http://1.repo", "https://2.repo"] args = ["name", "version", "distro", - ["image_type"], + "image_type", "fedora-candidate", arches, {"repo": repos}] @@ -1058,7 +1058,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods arches = ["x86_64"] repos = ["http://1.repo", "https://2.repo"] args = ["name", "version", "distro", - ["image_type"], + "image_type", "fedora-candidate", arches, {"repo": repos}] @@ -1081,7 +1081,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods arches = ["x86_64", "s390x"] repos = ["http://1.repo", "https://2.repo"] args = ["name", "version", "distro", - ["image_type"], + "image_type", "fedora-candidate", arches, {"repo": repos, @@ -1118,7 +1118,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods arches = ["x86_64", "s390x"] repos = ["http://1.repo", "https://2.repo"] args = ["name", "version", "distro", - ["image_type"], + "image_type", "fedora-candidate", arches, {"repo": repos, @@ -1175,7 +1175,7 @@ class TestBuilderPlugin(PluginTest): # pylint: disable=too-many-public-methods {"baseurl": "https://third.repo/$arch"} ] args = ["name", "version", "distro", - ["image_type"], + "image_type", "fedora-candidate", arches, {"repo": repos}] diff --git a/test/unit/test_cli.py b/test/unit/test_cli.py index 9366c6b..638ffd9 100644 --- a/test/unit/test_cli.py +++ b/test/unit/test_cli.py @@ -92,7 +92,7 @@ class TestCliPlugin(PluginTest): ] expected_args = ["name", "version", "distro", - ['guest-image'], # the default image type + 'guest-image', # the default image type "target", ['arch1']] @@ -154,7 +154,7 @@ class TestCliPlugin(PluginTest): ] expected_args = ["name", "version", "distro", - ['guest-image'], # the default image type + 'guest-image', # the default image type "target", ['arch1']] @@ -207,7 +207,7 @@ class TestCliPlugin(PluginTest): ] expected_args = ["name", "version", "distro", - ['guest-image'], # the default image type + 'guest-image', # the default image type "target", ['arch1']] @@ -265,7 +265,7 @@ class TestCliPlugin(PluginTest): ] expected_args = ["name", "version", "distro", - ['guest-image'], # the default image type + 'guest-image', # the default image type "target", ['arch1']] diff --git a/test/unit/test_hub.py b/test/unit/test_hub.py index 7dd3903..967e420 100644 --- a/test/unit/test_hub.py +++ b/test/unit/test_hub.py @@ -46,7 +46,7 @@ class TestHubPlugin(PluginTest): "release": "1.2.3", "skip_tag": True} args = ["name", "version", "distro", - ["image_type"], + "image_type", "target", ["arches"], opts] @@ -66,7 +66,7 @@ class TestHubPlugin(PluginTest): opts = {} args = ["name", "version", "distro", - "image_type", # image type not an array + ["image_type"], # image type not an array "target", ["arches"], opts]