# Prerequisite
# 1) Install azure-cli, oras
import_artifact_tree()
{
local reference=$1
local artifacts
local artifact
if [[ $reference = sha256:* ]]
then
echo "import: $source_registry/$source_repo@$reference"
# use --reposiotry to avoid generate default latest tag
az acr import -n $target_registry --source $source_registry/$source_repo@$reference --repository $source_repo --force
artifacts=$(oras discover -o json $source_registry/$source_repo@$reference | jq -r ".manifests[].digest //empty")
else
echo "import: $source_registry/$source_repo:$reference"
az acr import -n $target_registry --source $source_registry/$source_repo:$reference --force
artifacts=$(oras discover -o json $source_registry/$source_repo:$reference | jq -r ".manifests[].digest //empty")
fi
for artifact in $artifacts; do
import_artifact_tree $artifact
done
# TODO: if it's a manifest list or oci index, continue to import the artifacts associated with each child manifest
}
source_registry="mcr.microsoft.com"
source_repo="mirror/docker/bitnami/kafka"
source_tag="3.2"
target_registry="myregistry.azurecr.io"
# check source artifiact tree in the source regsitry
oras discover -o tree $source_registry/$source_repo:$source_tag
# import
import_artifact_tree $source_tag
# check imported artifact tree in the target registry
az acr login -n $target_registry
oras discover -o tree $target_registry/$source_repo:$source_tag
Last active
December 24, 2022 01:55
-
-
Save northtyphoon/8e32b2804232f8211dc9e924548e7c5b to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment