From f6e0e993919cb114e4437299020e80032d0e40a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Fri, 22 Sep 2023 17:26:15 +0200 Subject: [PATCH] Worker/koji-finalize: include osbuild version in image metadata MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Include the osbuild version used to build the image, in the image extra metadata attached to the Koji build and image output. Extend `koji.sh` to verify that the version is set and of the expected value. Signed-off-by: Tomáš Hozza --- cmd/osbuild-worker/jobimpl-koji-finalize.go | 1 + internal/upload/koji/koji.go | 2 ++ test/cases/koji.sh | 10 ++++++++++ 3 files changed, 13 insertions(+) diff --git a/cmd/osbuild-worker/jobimpl-koji-finalize.go b/cmd/osbuild-worker/jobimpl-koji-finalize.go index 665f781b3..c0332de26 100644 --- a/cmd/osbuild-worker/jobimpl-koji-finalize.go +++ b/cmd/osbuild-worker/jobimpl-koji-finalize.go @@ -188,6 +188,7 @@ func (impl *KojiFinalizeJobImpl) Run(job worker.Job) error { Arch: buildResult.Arch, BootMode: buildResult.ImageBootMode, OSBuildArtifact: kojiTargetResult.OsbuildArtifact, + OSBuildVersion: buildResult.OSBuildVersion, } // The image filename is now set in the KojiTargetResultOptions. diff --git a/internal/upload/koji/koji.go b/internal/upload/koji/koji.go index f652cbbd4..bd9a7b00e 100644 --- a/internal/upload/koji/koji.go +++ b/internal/upload/koji/koji.go @@ -127,6 +127,8 @@ type ImageExtraInfo struct { BootMode string `json:"boot_mode,omitempty"` // Configuration used to prouce this image using osbuild OSBuildArtifact *target.OsbuildArtifact `json:"osbuild_artifact,omitempty"` + // Version of the osbuild binary used by the worker to build the image + OSBuildVersion string `json:"osbuild_version,omitempty"` // Results from any upload targets associated with the image // except for the Koji target. UploadTargetResults []*target.TargetResult `json:"upload_target_results,omitempty"` diff --git a/test/cases/koji.sh b/test/cases/koji.sh index 2eea871fe..7cb04d209 100755 --- a/test/cases/koji.sh +++ b/test/cases/koji.sh @@ -120,6 +120,9 @@ function verify_buildinfo() { local buildid="${1}" local target_cloud="${2:-none}" + local osbuild_version + osbuild_version="$(osbuild --version | cut -d ' ' -f 2 -)" + local extra_build_metadata # extract the extra build metadata JSON from the output extra_build_metadata="$(koji -s "${KOJI_HUB_URL}" --noauth call --json getBuild "${buildid}" | jq -r '.extra')" @@ -243,6 +246,13 @@ function verify_buildinfo() { exit 1 fi + local image_osbuild_version + image_osbuild_version="$(echo "${image_metadata_build}" | jq -r '.osbuild_version')" + if [ "${image_osbuild_version}" != "${osbuild_version}" ]; then + echo "Unexpected osbuild version for '${image_filename}'. Expected '${osbuild_version}', but got '${image_osbuild_version}'" + exit 1 + fi + local image_metadata_archive image_metadata_archive="$(echo "${image}" | jq -r '.extra.image')" if [ "${image_metadata_build}" != "${image_metadata_archive}" ]; then