Created
May 29, 2024 20:31
-
-
Save ralphbean/863e9eb7e6be7394398b3416f3f2e1a4 to your computer and use it in GitHub Desktop.
download.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
# A script to pull down multiarch artifacts with conflicting names stored in a single image index | |
PULLSPEC=$1 | |
REPO=$(echo $PULLSPEC | awk -F ':' '{ print $1 }') | |
TAG=$(echo $PULLSPEC | awk -F ':' '{ print $2 }') | |
IMAGE_INDEX=$(oras manifest fetch $PULLSPEC) | |
OUTPUT=output/ | |
while IFS= read -r manifest; | |
do | |
manifest=$(echo $manifest | base64 -d) | |
arch=$(echo $manifest | jq -r '.platform | "\(.os)/\(.architecture)"') | |
digest=$(echo $manifest | jq -r '.digest') | |
mkdir -p $OUTPUT/$arch | |
oras pull --output $OUTPUT/$arch $REPO@$digest | |
done <<< $(jq -r '.manifests[] | @base64' <<< $IMAGE_INDEX) | |
tree $OUTPUT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment