diff --git a/plugins/hub/osbuild.py b/plugins/hub/osbuild.py index 5a8635f..0e8ecc4 100644 --- a/plugins/hub/osbuild.py +++ b/plugins/hub/osbuild.py @@ -28,8 +28,22 @@ "description": "Distribution" }, { - "type": "string", - "description": "Image Type", + "oneOf": [ + { + "type": "string", + "description": "Image Type" + }, + { + "type": "array", + "description": "Image Types", + "minItems": 1, + "maxItems": 1, + "deprecated": True, + "items": { + "type": "string" + } + } + ] }, { "type": "string", @@ -224,6 +238,12 @@ def osbuildImage(name, version, distro, image_type, target, arches, opts=None, p except jsonschema.exceptions.ValidationError as err: raise koji.ParameterError(str(err)) from None + # Support array for backwards compatibility + # This check must be done after the schema validation + if isinstance(image_type, list): + image_type = image_type[0] + args = [name, version, distro, image_type, target, arches, opts] + if priority and priority < 0 and not context.session.hasPerm('admin'): raise koji.ActionNotAllowed('only admins may create high-priority tasks') diff --git a/test/unit/test_hub.py b/test/unit/test_hub.py index 967e420..9d4a31e 100644 --- a/test/unit/test_hub.py +++ b/test/unit/test_hub.py @@ -60,13 +60,41 @@ def test_basic(self): self.plugin.osbuildImage(*args, {}) + def test_image_types_array(self): + context = self.mock_koji_context() + + opts = {"repo": ["repo1", "repo2"], + "release": "1.2.3", + "skip_tag": True} + make_task_args = [ + "name", "version", "distro", + "image_type", + "target", + ["arches"], + opts + ] + args = ["name", "version", "distro", + ["image_type"], + "target", + ["arches"], + opts] + + task = {"channel": "image"} + + kojihub = self.mock_kojihub(make_task_args, task) + + setattr(self.plugin, "context", context) + setattr(self.plugin, "kojihub", kojihub) + + self.plugin.osbuildImage(*args, {}) + def test_input_validation(self): context = self.mock_koji_context() setattr(self.plugin, "context", context) opts = {} args = ["name", "version", "distro", - ["image_type"], # image type not an array + ["image_type", "image_type2"], # only a single image type is allowed "target", ["arches"], opts]