Phases/osbuild: support passing 'customizations' for image builds
The osbuild Koji plugin supports passing customizations for an image
build. This is also supported in the Koji CLI plugin. Some teams want to
pass image customizations for images built as part of Pungi composes.
Extend the osbuild phase to support passing customizations in the Pungi
configuration.
Merges: https://pagure.io/pungi/pull-request/1733
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
(cherry picked from commit e738f65458
)
This commit is contained in:
parent
4d858ef958
commit
a97488721d
@ -1690,6 +1690,10 @@ OSBuild Composer for building images
|
|||||||
* ``ostree_ref`` -- name of the ostree branch
|
* ``ostree_ref`` -- name of the ostree branch
|
||||||
* ``ostree_parent`` -- commit hash or a a branch-like reference to the
|
* ``ostree_parent`` -- commit hash or a a branch-like reference to the
|
||||||
parent commit.
|
parent commit.
|
||||||
|
* ``customizations`` -- a dictionary with customizations to use for the
|
||||||
|
image build. For the list of supported customizations, see the **hosted**
|
||||||
|
variants in the `Image Builder documentation
|
||||||
|
<https://osbuild.org/docs/user-guide/blueprint-reference#installation-device>`.
|
||||||
* ``upload_options`` -- a dictionary with upload options specific to the
|
* ``upload_options`` -- a dictionary with upload options specific to the
|
||||||
target cloud environment. If provided, the image will be uploaded to the
|
target cloud environment. If provided, the image will be uploaded to the
|
||||||
cloud environment, in addition to the Koji server. One can't combine
|
cloud environment, in addition to the Koji server. One can't combine
|
||||||
|
@ -1325,6 +1325,10 @@ def make_schema():
|
|||||||
"ostree_ref": {"type": "string"},
|
"ostree_ref": {"type": "string"},
|
||||||
"ostree_parent": {"type": "string"},
|
"ostree_parent": {"type": "string"},
|
||||||
"manifest_type": {"type": "string"},
|
"manifest_type": {"type": "string"},
|
||||||
|
"customizations": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": True,
|
||||||
|
},
|
||||||
"upload_options": {
|
"upload_options": {
|
||||||
# this should be really 'oneOf', but the minimal
|
# this should be really 'oneOf', but the minimal
|
||||||
# required properties in AWSEC2 and GCP options
|
# required properties in AWSEC2 and GCP options
|
||||||
|
@ -159,6 +159,10 @@ class RunOSBuildThread(WorkerThread):
|
|||||||
if upload_options:
|
if upload_options:
|
||||||
opts["upload_options"] = upload_options
|
opts["upload_options"] = upload_options
|
||||||
|
|
||||||
|
customizations = config.get("customizations")
|
||||||
|
if customizations:
|
||||||
|
opts["customizations"] = customizations
|
||||||
|
|
||||||
if release:
|
if release:
|
||||||
opts["release"] = release
|
opts["release"] = release
|
||||||
task_id = koji.koji_proxy.osbuildImage(
|
task_id = koji.koji_proxy.osbuildImage(
|
||||||
|
@ -186,6 +186,51 @@ class OSBuildPhaseTest(helpers.PungiTestCase):
|
|||||||
)
|
)
|
||||||
self.assertNotEqual(validate(compose.conf), ([], []))
|
self.assertNotEqual(validate(compose.conf), ([], []))
|
||||||
|
|
||||||
|
@mock.patch("pungi.phases.osbuild.ThreadPool")
|
||||||
|
def test_run_with_customizations(self, ThreadPool):
|
||||||
|
cfg = {
|
||||||
|
"name": "test-image",
|
||||||
|
"distro": "rhel-8",
|
||||||
|
"image_types": ["qcow2"],
|
||||||
|
"customizations": {"installation_device": "/dev/sda"},
|
||||||
|
}
|
||||||
|
compose = helpers.DummyCompose(
|
||||||
|
self.topdir,
|
||||||
|
{
|
||||||
|
"osbuild": {"^Everything$": [cfg]},
|
||||||
|
"osbuild_target": "image-target",
|
||||||
|
"osbuild_version": "1",
|
||||||
|
"osbuild_release": "2",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertValidConfig(compose.conf)
|
||||||
|
|
||||||
|
pool = ThreadPool.return_value
|
||||||
|
|
||||||
|
phase = osbuild.OSBuildPhase(compose)
|
||||||
|
phase.run()
|
||||||
|
|
||||||
|
self.assertEqual(len(pool.add.call_args_list), 1)
|
||||||
|
self.assertEqual(
|
||||||
|
pool.queue_put.call_args_list,
|
||||||
|
[
|
||||||
|
mock.call(
|
||||||
|
(
|
||||||
|
compose,
|
||||||
|
compose.variants["Everything"],
|
||||||
|
cfg,
|
||||||
|
sorted(compose.variants["Everything"].arches),
|
||||||
|
"1",
|
||||||
|
"2",
|
||||||
|
"image-target",
|
||||||
|
[self.topdir + "/compose/Everything/$arch/os"],
|
||||||
|
[],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
@mock.patch("pungi.phases.osbuild.ThreadPool")
|
@mock.patch("pungi.phases.osbuild.ThreadPool")
|
||||||
def test_rich_repos(self, ThreadPool):
|
def test_rich_repos(self, ThreadPool):
|
||||||
repo = {"baseurl": "http://example.com/repo", "package_sets": ["build"]}
|
repo = {"baseurl": "http://example.com/repo", "package_sets": ["build"]}
|
||||||
|
Loading…
Reference in New Issue
Block a user