Hub: support image_type being an array for backwards compatibility
The support for specifying multiple `image_types` for a single compose
has been removed by [1]. This turned out to be problematic, because e.g.
Pungi uses the array type when triggering image builds via osbuild.
Bring back the support for specifying the `image_type` as an array, but
restrict it to a single item. This will cover the Pungi use-case, since
it is always passing a single `image_type` in the array. The array is
then converted to a string in the Hub plugin and passed as such to the
Builder plugin.
Extend unit tests covering the introduced compatibility layer.
[1] c725265081
This commit is contained in:
parent
6065ce8b72
commit
f21a2de39b
2 changed files with 50 additions and 3 deletions
|
|
@ -28,8 +28,21 @@ OSBUILD_IMAGE_SCHEMA = {
|
|||
"description": "Distribution"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Image Type",
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Image Type"
|
||||
},
|
||||
{
|
||||
"type": "array",
|
||||
"description": "Image Types (this option is deprecated)",
|
||||
"minItems": 1,
|
||||
"maxItems": 1,
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
|
|
@ -224,6 +237,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')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue