diff --git a/cmd/osbuild-koji-tests/main_test.go b/cmd/osbuild-koji-tests/main_test.go index ed7120b0aad..0045037adca 100644 --- a/cmd/osbuild-koji-tests/main_test.go +++ b/cmd/osbuild-koji-tests/main_test.go @@ -23,6 +23,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/osbuild/images/pkg/distro" "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/upload/koji" ) @@ -180,7 +181,8 @@ func TestKojiImport(t *testing.T) { RPMs: []rpmmd.RPM{}, Extra: koji.BuildOutputExtra{ Image: koji.ImageExtraInfo{ - Arch: "noarch", + Arch: "noarch", + BootMode: distro.BOOT_LEGACY.String(), }, }, }, diff --git a/cmd/osbuild-koji/main.go b/cmd/osbuild-koji/main.go index d84ecfb9e6b..a2f807f49e2 100644 --- a/cmd/osbuild-koji/main.go +++ b/cmd/osbuild-koji/main.go @@ -8,6 +8,7 @@ import ( "time" "github.com/google/uuid" + "github.com/osbuild/images/pkg/distro" "github.com/osbuild/images/pkg/rpmmd" "github.com/osbuild/osbuild-composer/internal/upload/koji" "github.com/sirupsen/logrus" @@ -99,7 +100,8 @@ func main() { RPMs: []rpmmd.RPM{}, Extra: koji.BuildOutputExtra{ Image: koji.ImageExtraInfo{ - Arch: arch, + Arch: arch, + BootMode: distro.BOOT_NONE.String(), // TODO: put the correct boot mode here }, }, }, diff --git a/cmd/osbuild-worker/jobimpl-koji-finalize.go b/cmd/osbuild-worker/jobimpl-koji-finalize.go index a2b503fafad..61ea97a5246 100644 --- a/cmd/osbuild-worker/jobimpl-koji-finalize.go +++ b/cmd/osbuild-worker/jobimpl-koji-finalize.go @@ -184,7 +184,8 @@ func (impl *KojiFinalizeJobImpl) Run(job worker.Job) error { imageRPMs = rpmmd.DeduplicateRPMs(imageRPMs) imgOutputExtraInfo := koji.ImageExtraInfo{ - Arch: buildArgs.Arch, + Arch: buildArgs.Arch, + BootMode: buildArgs.ImageBootMode, } imgOutputsExtraInfo[args.KojiFilenames[i]] = imgOutputExtraInfo diff --git a/internal/upload/koji/koji.go b/internal/upload/koji/koji.go index d4a0b6e3aa0..fa0ddf50663 100644 --- a/internal/upload/koji/koji.go +++ b/internal/upload/koji/koji.go @@ -110,8 +110,12 @@ type BuildRoot struct { // ImageExtraInfo holds extra metadata about the image. // This structure is shared for the Extra metadata of the output and the build. type ImageExtraInfo struct { - // TODO: Ideally this is where the pipeline would be passed. - Arch string `json:"arch"` // TODO: why? + // Koji docs say: "should contain IDs that allow tracking the output back to the system in which it was generated" + // TODO: we should probably add some ID here, probably the OSBuildJob UUID? + + Arch string `json:"arch"` + // Boot mode of the image + BootMode string `json:"boot_mode"` } // BuildOutputExtra holds extra metadata associated with the build output. diff --git a/internal/worker/json.go b/internal/worker/json.go index d6ff26be893..ae8305f52ee 100644 --- a/internal/worker/json.go +++ b/internal/worker/json.go @@ -25,7 +25,7 @@ type OSBuildJob struct { // The ImageBootMode is just copied to the result by the worker, so that // the value can be accessed job which depend on it. // (string representation of distro.BootMode values) - ImageBootMode string `json:"image_boot_mode"` + ImageBootMode string `json:"image_boot_mode,omitempty"` } // OsbuildExports returns a slice of osbuild pipeline names, which should be @@ -60,7 +60,7 @@ type OSBuildJobResult struct { Arch string `json:"arch"` // Boot mode supported by the image // (string representation of distro.BootMode values) - ImageBootMode string `json:"image_boot_mode"` + ImageBootMode string `json:"image_boot_mode,omitempty"` JobResult } diff --git a/test/cases/koji.sh b/test/cases/koji.sh index 87aa49e70d3..5b79951f808 100755 --- a/test/cases/koji.sh +++ b/test/cases/koji.sh @@ -163,6 +163,19 @@ function verify_buildinfo() { echo "Unexpected arch for '${image}'. Expected '${ARCH}', but got '${image_arch}'" exit 1 fi + + local image_boot_mode + image_boot_mode="$(echo "${image_metadata}" | jq -r '.boot_mode')" + # for now, check just that the boot mode is a valid value + case "${image_boot_mode}" in + "uefi"|"legacy"|"hybrid") + ;; + "none"|*) + # for now, we don't upload any images that have 'none' as boot mode, although it is a valid value + echo "Unexpected boot mode for '${image}'. Expected 'uefi', 'legacy' or 'hybrid', but got '${image_boot_mode}'" + exit 1 + ;; + esac done }