Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple Docker Registry API v2 Wrapper
#!/usr/bin/env bash
#
# Simple Docker Registry API v2 Wrapper
#
REPOSITORY="doplicated/client"
get_from_dh() {
URL="$1"
TOKEN="$(curl 'https://auth.docker.io/token?service=registry.docker.io&scope=repository:'$REPOSITORY':pull' 2>/dev/null | jq -r '.token')"
curl -H "Authorization: Bearer ${TOKEN}" "$URL" 2>/dev/null
}
rm -f latest.log other.log same.log
get_from_dh 'https://index.docker.io/v2/doplicated/client/manifests/latest' | jq '.fsLayers' > latest.log
get_from_dh 'https://index.docker.io/v2/doplicated/client/manifests/2.40.0' | jq '.fsLayers' > same.log
get_from_dh 'https://index.docker.io/v2/doplicated/client/manifests/2.42.0' | jq '.fsLayers' > other.log
echo ""
echo "Same"
git diff --no-index latest.log same.log
echo ""
echo "Other"
git diff --no-index latest.log other.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.