Skip to content

Commit

Permalink
fix(KFLUXBUGS-1846): fail get-image-architectures if skopeo failed
Browse files Browse the repository at this point in the history
If skopeo inspect fails, the variable would be empty and then
the jq query would return an empty string instead of null, so
we would assume it's an oci artifact and run oras resolve.

If we were unable to fetch the image details with skopeo inspect
we should just fail the script.

Signed-off-by: Martin Malina <[email protected]>
  • Loading branch information
mmalina committed Nov 27, 2024
1 parent dc0f89c commit c89a4c5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions utils/get-image-architectures
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
#!/bin/bash
#
# script: get-image-architectures
#
#
# description: This script fetches all architectures and their digests for a passed image.
# It will output each arch on its own line, as json.
#
# example command:
# example command:
# get-image-architectures IMAGE where IMAGE is quay.io/org/repo@sha256:abcde for example
#

IMAGE=$1

if [ -z "${IMAGE}" ] || [[ "${IMAGE}" == docker://* ]] ; then
echo -e "Please pass an image (without the docker:// prefix) to find the architectures for"
echo "Please pass an image (without the docker:// prefix) to find the architectures for" >&2
exit 1
fi

RAW_OUTPUT=$(skopeo inspect --no-tags --raw docker://${IMAGE})

if [ -z "$RAW_OUTPUT" ]; then
echo "Error: Unable to fetch image details with skopeo inspect" >&2
exit 1
fi


ARTIFACT_TYPE=$(jq -r '.artifactType' <<< $RAW_OUTPUT)
if [ "$ARTIFACT_TYPE" != "null" ] ; then
# OCI artifact (not a normal image)
Expand Down

0 comments on commit c89a4c5

Please sign in to comment.