Worker/koji-finalize: add cloud target results to image/build metadata

Add any non-Koji upload target results attached to an OSBuild result, to
the image extra metadata. This will make it easy to locate any image
from Koji uploaded to cloud, in the target cloud environment.

The rationale behind including only non-Koji target results is that one
can find it only in Koji, so there is no added value in including the
Koji target results at all.

Extend the `koji.sh` to check the target results in image metadata when
testing Koji scenario with cloud upload.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
Tomáš Hozza 2023-09-19 18:00:23 +02:00 committed by Tomáš Hozza
parent e0ec3a2a1c
commit 4f51d44762
5 changed files with 201 additions and 0 deletions

View file

@ -147,6 +147,38 @@ function verify_buildinfo() {
echo "Unexpected number of images in the buildinfo. Want 1, got ${outputs_images_count}."
exit 1
fi
# Verify that the target results are present in the image output metadata
local target_results
target_results="$(echo "${outputs_images}" | jq -r '.[0].extra.image.upload_target_results')"
local target_results_count
target_results_count="$(echo "${target_results}" | jq 'length')"
if [ "$target_results_count" -ne 1 ]; then
echo "Unexpected number of target results in the buildinfo. Want 1, got ${target_results_count}."
exit 1
fi
local target_result_name
target_result_name="$(echo "${target_results}" | jq -r '.[0].name')"
local want_target_result_name
case ${target_cloud} in
"$CLOUD_PROVIDER_AWS")
want_target_result_name="org.osbuild.aws"
;;
"$CLOUD_PROVIDER_GCP")
want_target_result_name="org.osbuild.gcp"
;;
"$CLOUD_PROVIDER_AZURE")
want_target_result_name="org.osbuild.azure.image"
;;
*)
echo "Unknown cloud provider: ${CLOUD_PROVIDER}"
exit 1
esac
if [ "${target_result_name}" != "${want_target_result_name}" ]; then
echo "Unexpected target result in the buildinfo. Want '${want_target_result_name}', got '${target_result_name}'."
exit 1
fi
fi
local outputs_manifests