Skip to content

Commit df27f42

Browse files
committed
check bundle version before adding to the catalog
1 parent bcc2996 commit df27f42

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

hack/lib/images.bash

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,23 @@ function get_bundle_for_version() {
5858
bundle="${registry_prefix_quay}${app_version}/serverless-bundle"
5959

6060
image=$(image_with_sha "${bundle}:latest")
61+
image_version=$(bundle_image_version "${bundle}:latest")
62+
6163
# As a backup, try also CI registry. This it temporary until the previous version gets to Konflux.
62-
if [[ "${image}" == "" ]]; then
64+
# For .micro releases, it's possible we only have the _previous_ version in Konflux, so also check the version of the bundle
65+
if [[ "${image}" == "" || "${image_version}" != "${version}" ]]; then
6366
image=$(image_with_sha "registry.ci.openshift.org/knative/serverless-bundle:release-${version}")
67+
image_version=$(bundle_image_version "registry.ci.openshift.org/knative/serverless-bundle:release-${version}")
6468
fi
6569

6670
if [[ "${image}" == "" ]]; then
6771
exit 1
6872
fi
6973

74+
if [[ "${image_version}" != "${version}" ]]; then
75+
exit 2
76+
fi
77+
7078
echo "$image"
7179
}
7280

@@ -330,6 +338,12 @@ function image_with_sha {
330338
echo "${image_without_tag}@${digest}"
331339
}
332340

341+
function bundle_image_version {
342+
image=${1:?"Provide image"}
343+
version=$(skopeo inspect --no-tags=true "docker://${image}" | jq -r '.Labels.version')
344+
echo "${version}"
345+
}
346+
333347
function get_app_version_from_tag() {
334348
local tag app_version
335349
tag=${1:?"Provide tag for Serving images"}

0 commit comments

Comments
 (0)