osbuild: accept only a single image type in the configuration
Modify the osbuild configuration schema to accept only an array with a single value as the `image_types`, in addition to a single string. The single string was supported by the schema also before, but this fact was not mentioned in the documentation, nor it was supported by the `koji-osbuild` plugin of version lower than `9`. Update the documentation accordingly. Add unit test for invalid configuration containing more than one image type. Signed-off-by: Tomas Hozza <thozza@redhat.com>
This commit is contained in:
parent
57ea640916
commit
805a1083a2
@ -1594,7 +1594,9 @@ OSBuild Composer for building images
|
||||
|
||||
* ``name`` -- name of the Koji package
|
||||
* ``distro`` -- image for which distribution should be build TODO examples
|
||||
* ``image_types`` -- a list of image types to build (e.g. ``qcow2``)
|
||||
* ``image_types`` -- a list with a single image type string or just a
|
||||
string representing the image type to build (e.g. ``qcow2``). In any
|
||||
case, only a single image type can be provided as an argument.
|
||||
|
||||
Optional keys:
|
||||
|
||||
|
@ -1171,7 +1171,21 @@ def make_schema():
|
||||
"version": {"type": "string"},
|
||||
"distro": {"type": "string"},
|
||||
"target": {"type": "string"},
|
||||
"image_types": {"$ref": "#/definitions/strings"},
|
||||
# Only a single image_type can be specified
|
||||
# https://github.com/osbuild/koji-osbuild/commit/c7252650814f82281ee57b598cb2ad970b580451
|
||||
# https://github.com/osbuild/koji-osbuild/commit/f21a2de39b145eb94f3d49cb4d8775a33ba56752
|
||||
"image_types": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "array",
|
||||
"items": {"type": "string"},
|
||||
"description": "Deprecated variant",
|
||||
"minItems": 1,
|
||||
"maxItems": 1,
|
||||
},
|
||||
{"type": "string"},
|
||||
]
|
||||
},
|
||||
"arches": {"$ref": "#/definitions/list_of_strings"},
|
||||
"release": {"type": "string"},
|
||||
"repo": {"$ref": "#/definitions/list_of_strings"},
|
||||
|
@ -8,6 +8,7 @@ import koji as orig_koji
|
||||
|
||||
from tests import helpers
|
||||
from pungi.phases import osbuild
|
||||
from pungi.checks import validate
|
||||
|
||||
|
||||
class OSBuildPhaseTest(helpers.PungiTestCase):
|
||||
@ -105,6 +106,24 @@ class OSBuildPhaseTest(helpers.PungiTestCase):
|
||||
phase = osbuild.OSBuildPhase(compose)
|
||||
self.assertTrue(phase.skip())
|
||||
|
||||
def test_fail_multiple_image_types(self):
|
||||
cfg = {
|
||||
"name": "test-image",
|
||||
"distro": "rhel-8",
|
||||
# more than one image type is not allowed
|
||||
"image_types": ["qcow2", "rhel-ec2"],
|
||||
}
|
||||
compose = helpers.DummyCompose(
|
||||
self.topdir,
|
||||
{
|
||||
"osbuild": {"^Everything$": [cfg]},
|
||||
"osbuild_target": "image-target",
|
||||
"osbuild_version": "1",
|
||||
"osbuild_release": "2",
|
||||
},
|
||||
)
|
||||
self.assertNotEqual(validate(compose.conf), ([], []))
|
||||
|
||||
|
||||
class RunOSBuildThreadTest(helpers.PungiTestCase):
|
||||
def setUp(self):
|
||||
|
Loading…
Reference in New Issue
Block a user