Skip to content

Instantly share code, notes, and snippets.

@ralphbean
Created May 29, 2024 20:31
Show Gist options
  • Save ralphbean/863e9eb7e6be7394398b3416f3f2e1a4 to your computer and use it in GitHub Desktop.
Save ralphbean/863e9eb7e6be7394398b3416f3f2e1a4 to your computer and use it in GitHub Desktop.
download.sh
#!/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