plugins: add support for customizations

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.
This commit is contained in:
Christian Kellner 2022-05-02 15:25:20 +02:00
parent d8c9332257
commit 591a55aad5
5 changed files with 130 additions and 1 deletions

View file

@ -168,15 +168,19 @@ class ComposeRequest:
self.distribution = distro
self.image_requests = ireqs
self.koji = koji
self.customizations: Optional[dict] = None
def as_dict(self):
return {
res = {
"distribution": self.distribution,
"koji": self.koji.as_dict(),
"image_requests": [
img.as_dict() for img in self.image_requests
]
}
if self.customizations:
res["customizations"] = self.customizations
return res
class ImageStatus(enum.Enum):
@ -641,6 +645,9 @@ class OSBuildImage(BaseTaskHandler):
kojidata = ComposeRequest.Koji(self.koji_url, self.id, nvr)
request = ComposeRequest(distro, ireqs, kojidata)
# Additional customizations are passed through
request.customizations = opts.get("customizations")
self.upload_json(request.as_dict(), "compose-request")
cid = client.compose_create(request)