From dbe70d70664dff43092c9e02b3de6fda183cdaaa Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 7 Oct 2025 17:46:37 +0200 Subject: [PATCH] bib: expose new `ova` image type in bib This commit exposes the new `ova` image type and adds a basic smoke test. --- bib/internal/imagetypes/imagetypes.go | 1 + bib/internal/imagetypes/imagetypes_test.go | 6 ++--- test/test_manifest.py | 31 +++++++++++++++++++--- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/bib/internal/imagetypes/imagetypes.go b/bib/internal/imagetypes/imagetypes.go index de396ce4b..98e601e5c 100644 --- a/bib/internal/imagetypes/imagetypes.go +++ b/bib/internal/imagetypes/imagetypes.go @@ -23,6 +23,7 @@ var supportedImageTypes = map[string]imageType{ "vmdk": imageType{Export: "vmdk"}, "vhd": imageType{Export: "vpc"}, "gce": imageType{Export: "gce"}, + "ova": imageType{Export: "archive"}, // the iso image types are RPM based and legacy/deprecated "anaconda-iso": imageType{Export: "bootiso", ISO: true, Legacy: true}, "iso": imageType{Export: "bootiso", ISO: true, Legacy: true}, diff --git a/bib/internal/imagetypes/imagetypes_test.go b/bib/internal/imagetypes/imagetypes_test.go index fe36ea0f6..efe7114b9 100644 --- a/bib/internal/imagetypes/imagetypes_test.go +++ b/bib/internal/imagetypes/imagetypes_test.go @@ -63,15 +63,15 @@ func TestImageTypes(t *testing.T) { }, "bad-image-type": { imageTypes: []string{"bad"}, - expectedErr: errors.New(`unsupported image type "bad", valid types are ami, anaconda-iso, gce, iso, qcow2, raw, vhd, vmdk`), + expectedErr: errors.New(`unsupported image type "bad", valid types are ami, anaconda-iso, gce, iso, ova, qcow2, raw, vhd, vmdk`), }, "bad-in-good": { imageTypes: []string{"ami", "raw", "vmdk", "qcow2", "something-else-what-is-this"}, - expectedErr: errors.New(`unsupported image type "something-else-what-is-this", valid types are ami, anaconda-iso, gce, iso, qcow2, raw, vhd, vmdk`), + expectedErr: errors.New(`unsupported image type "something-else-what-is-this", valid types are ami, anaconda-iso, gce, iso, ova, qcow2, raw, vhd, vmdk`), }, "all-bad": { imageTypes: []string{"bad1", "bad2", "bad3", "bad4", "bad5", "bad42"}, - expectedErr: errors.New(`unsupported image type "bad1", valid types are ami, anaconda-iso, gce, iso, qcow2, raw, vhd, vmdk`), + expectedErr: errors.New(`unsupported image type "bad1", valid types are ami, anaconda-iso, gce, iso, ova, qcow2, raw, vhd, vmdk`), }, } diff --git a/test/test_manifest.py b/test/test_manifest.py index 7171bb0fe..e312883a7 100644 --- a/test/test_manifest.py +++ b/test/test_manifest.py @@ -858,10 +858,9 @@ def test_manifest_customization_custom_file_smoke(tmp_path, build_container): def find_stage_options_from(manifest_str, stage_type): manifest = json.loads(manifest_str) for pipl in manifest["pipelines"]: - if pipl["name"] == "image": - for st in pipl["stages"]: - if st["type"] == stage_type: - return st["options"] + for st in pipl["stages"]: + if st["type"] == stage_type: + return st["options"] raise ValueError(f"cannot find {stage_type} stage manifest:\n{manifest_str}") @@ -1032,3 +1031,27 @@ def test_manifest_image_disk_yaml(tmp_path, build_container): ], encoding="utf8") write_device_options = find_stage_options_from(manifest_str, "org.osbuild.write-device") assert write_device_options["from"] == "input://tree/usr/lib/modules/5.0-x86_64/aboot.img" + + +@pytest.mark.parametrize("tc", gen_testcases("anaconda-iso")) +def test_ova_manifest_smoke(build_container, tc): + testutil.pull_container(tc.container_ref, tc.target_arch) + + output = subprocess.check_output([ + *testutil.podman_run_common, + build_container, + "manifest", + *tc.bib_rootfs_args(), + "--type=ova", + f"{tc.container_ref}", + ]) + # just some basic validation that we generate a ova + assert find_stage_options_from(output, "org.osbuild.tar") == { + "filename": "image.ova", + "format": "ustar", + "paths": [ + "image.ovf", + "image.mf", + "image.vmdk" + ] + }