The Cloud API supports passing in a variety of image customizations, like e.g. extra packages or pre-defining users. Add a new command line option to the client `--customizations` which takes a path to a JSON file which contains the customziations; they will be passed via the existing `opts` argument to the hub. Add support for `customizations` to the `opts`/`options` arguments to the hub plugin. No validation to the object is done. Instead we rely in Composer for the validation of the content. Add support for `customizations` the image `ComposeRequest` in the builder plugin. All specified values are just passed through to composer as-is. Add tests for the respective plugins.
137 lines
3.9 KiB
Python
137 lines
3.9 KiB
Python
"""Koji osbuild integration for Koji Hub"""
|
|
import sys
|
|
import jsonschema
|
|
|
|
import koji
|
|
from koji.context import context
|
|
|
|
sys.path.insert(0, "/usr/share/koji-hub/")
|
|
import kojihub # pylint: disable=import-error, wrong-import-position
|
|
|
|
|
|
OSBUILD_IMAGE_SCHEMA = {
|
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
"title": "osbuildImage arguments",
|
|
"type": "array",
|
|
"minItems": 7,
|
|
"items": [
|
|
{
|
|
"type": "string",
|
|
"description": "Name"
|
|
},
|
|
{
|
|
"type": "string",
|
|
"description": "Version"
|
|
},
|
|
{
|
|
"type": "string",
|
|
"description": "Distribution"
|
|
},
|
|
{
|
|
"type": "array",
|
|
"description": "Image Types",
|
|
"minItems": 1
|
|
},
|
|
{
|
|
"type": "string",
|
|
"description": "Target"
|
|
},
|
|
{
|
|
"type": "array",
|
|
"description": "Architectures",
|
|
"minItems": 1,
|
|
"items": {
|
|
"type": "string"
|
|
}
|
|
},
|
|
{
|
|
"type": "object",
|
|
"$ref": "#/definitions/options"
|
|
}],
|
|
"definitions": {
|
|
"repo": {
|
|
"title": "Repository options",
|
|
"type": "object",
|
|
"additionalProperties": False,
|
|
"properties": {
|
|
"baseurl": {
|
|
"type": "string"
|
|
},
|
|
"package_sets": {
|
|
"type": "array",
|
|
"description": "Repositories",
|
|
"items": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"ostree": {
|
|
"title": "OSTree specific options",
|
|
"type": "object",
|
|
"additionalProperties": False,
|
|
"properties": {
|
|
"parent": {
|
|
"type": "string"
|
|
},
|
|
"ref": {
|
|
"type": "string"
|
|
},
|
|
"url": {
|
|
"type": "string"
|
|
}
|
|
}
|
|
},
|
|
"options": {
|
|
"title": "Optional arguments",
|
|
"type": "object",
|
|
"additionalProperties": False,
|
|
"properties": {
|
|
"customizations": {
|
|
"type": "object",
|
|
"additionalProperties": True
|
|
},
|
|
"ostree": {
|
|
"type": "object",
|
|
"$ref": "#/definitions/ostree"
|
|
},
|
|
"repo": {
|
|
"type": "array",
|
|
"description": "Repositories",
|
|
"items": {
|
|
"oneOf": [
|
|
{"type": "string"},
|
|
{"$ref": "#/definitions/repo"}
|
|
]
|
|
}
|
|
},
|
|
"release": {
|
|
"type": "string",
|
|
"description": "Release override"
|
|
},
|
|
"skip_tag": {
|
|
"type": "boolean",
|
|
"description": "Omit tagging the result"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@koji.plugin.export
|
|
def osbuildImage(name, version, distro, image_types, target, arches, opts=None, priority=None):
|
|
"""Create an image via osbuild"""
|
|
context.session.assertPerm("image")
|
|
args = [name, version, distro, image_types, target, arches, opts]
|
|
task = {"channel": "image"}
|
|
|
|
try:
|
|
jsonschema.validate(args, OSBUILD_IMAGE_SCHEMA)
|
|
except jsonschema.exceptions.ValidationError as err:
|
|
raise koji.ParameterError(str(err)) from None
|
|
|
|
if priority and priority < 0 and not context.session.hasPerm('admin'):
|
|
raise koji.ActionNotAllowed('only admins may create high-priority tasks')
|
|
|
|
return kojihub.make_task('osbuildImage', args, **task)
|