Last active
January 6, 2021 19:22
-
-
Save sajayantony/a043cc880ad0eb9dda7e3b4d26f0eb25 to your computer and use it in GitHub Desktop.
Obtain the Config blob from the registry from Manifest digest
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/sh | |
set -e | |
REGISTRY="sajay.azurecr.io" | |
REPOSITORY="hello-world" | |
AAD_ACCESS_TOKEN=$(az account get-access-token --query accessToken -o tsv) | |
ACR_REFRESH_TOKEN=$(curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" \ | |
-d "grant_type=access_token&service=$REGISTRY&access_token=$AAD_ACCESS_TOKEN" \ | |
https://$REGISTRY/oauth2/exchange \ | |
| jq '.refresh_token' \ | |
| sed -e 's/^"//' -e 's/"$//') | |
echo "ACR Refresh Token obtained." | |
# Create the repo level scope | |
SCOPE="repository:$REPOSITORY:pull" | |
# to pull multiple repositories passing in multiple scope arguments. | |
#&scope="repository:repo:pull,push" | |
ACR_ACCESS_TOKEN=$(curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" \ | |
-d "grant_type=refresh_token&service=$REGISTRY&scope=$SCOPE&refresh_token=$ACR_REFRESH_TOKEN" \ | |
https://$REGISTRY/oauth2/token \ | |
| jq '.access_token' \ | |
| sed -e 's/^"//' -e 's/"$//') | |
echo "ACR Access Token obtained." | |
MANIFEST_DIGEST="sha256:90659bf80b44ce6be8234e6ff90a1ac34acbeb826903b02cfa0da11c82cbc042" | |
CONFIG_BLOB_DIGEST=$(curl -s -L -H "Authorization: Bearer $ACR_ACCESS_TOKEN" https://$REGISTRY/v2/$REPOSITORY/manifests/$MANIFEST_DIGEST | jq -r .config.digest) | |
echo CONFIG_BLOB_DIGEST=$CONFIG_BLOB_DIGEST | |
# CONFIG_BLOB_DIGEST="sha256:bf756fb1ae65adf866bd8c456593cd24beb6a0a061dedf42b26a993176745f6b" | |
curl -s -L -H "Authorization: Bearer $ACR_ACCESS_TOKEN" https://$REGISTRY/v2/$REPOSITORY/blobs/$CONFIG_BLOB_DIGEST | jq .architecture |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment