Skip to content

Commit

Permalink
About of use Azure SDK script
Browse files Browse the repository at this point in the history
  • Loading branch information
lijinpei2008 committed May 8, 2020
2 parents fb4f264 + cb49908 commit 33c482b
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 5 deletions.
4 changes: 2 additions & 2 deletions installAzCLIAndDocker.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ echo "=================================== [sudo gpasswd -a \$USER docker] [newgr
echo "============================================== [sudo chmod g+rwx \"/home/\$USER/.docker\" -R] [sudo chmod a+rw /var/run/docker.sock] =================================================="

#Find History
history
#history

#Clean History
history -c
#history -c
65 changes: 62 additions & 3 deletions loop.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fi

echo "==================================================================== Input Container Registry Name! =========================================================================="
read name
echo "=============================================================== Push Repositories(r/R)? Tags(t)? Task(T)? ===================================================================="
echo "======================================================== Push Repositories(r/R)? Tags(t)? Task(T)? ScopeMap(s/S) ============================================================="
read tit
echo "================================================================== Do you want to loop it a few times? ======================================================================="
read num
Expand Down Expand Up @@ -60,6 +60,62 @@ case ${tit} in
done
;;

"s"|"S")
while ((${loopCount}<=${num}))
do
az acr scope-map create -n ${name}scopemap${loopCount} --repository hello-world${loopCount} content/read content/write -r ${name} --description "Sample scope map."

az acr token create -n ${name}token${loopCount} --scope-map ${name}scopemap${loopCount} -r ${name}

az acr token credential generate -n ${name}token${loopCount} -r ${name}

echo "======================================================================== Input Token Password Name ============================================================================"
read tokenPassword

docker login ${name}.azurecr.io -u ${name}token${loopCount} -p ${tokenPassword}
docker tag hello-world ${name}.azurecr.io/hello-world${loopCount}
docker tag hello-world ${name}.azurecr.io/alpine${loopCount}
docker push ${name}.azurecr.io/hello-world${loopCount}
docker push ${name}.azurecr.io/alpine${loopCount}

az acr scope-map update -n ${name}scopemap${loopCount} --add alpine${loopCount} content/read content/write -r ${name}
docker push ${name}.azurecr.io/alpine${loopCount}

az acr scope-map update -n ${name}scopemap${loopCount} --add hello-world${loopCount} metadata/read -r ${name}

az acr repository show-manifests --repository hello-world${loopCount} -u ${name}token${loopCount} -p ${tokenPassword} -n ${name}
az acr repository show-tags --repository hello-world${loopCount} -u ${name}token${loopCount} -p ${tokenPassword} -n ${name}

az acr scope-map update -n ${name}scopemap${loopCount} --add alpine${loopCount} metadata/write -r ${name}

az acr repository update --repository alpine${loopCount} --write-enabled false --delete-enabled false -u ${name}token${loopCount} -p ${tokenPassword} -n ${name}
az acr repository update --repository alpine${loopCount} --write-enabled true --delete-enabled true -u ${name}token${loopCount} -p ${tokenPassword} -n ${name}

az acr scope-map update -n ${name}scopemap${loopCount} --remove alpine${loopCount} content/read -r ${name}
docker pull ${name}.azurecr.io/hello-world${loopCount}
docker pull ${name}.azurecr.io/alpine${loopCount}

az acr scope-map update -n ${name}scopemap${loopCount} --add alpine${loopCount} content/read -r ${name}
docker pull ${name}.azurecr.io/alpine${loopCount}

az acr scope-map update -n ${name}scopemap${loopCount} --add alpine${loopCount} content/delete -r ${name}

az acr repository delete --repository alpine${loopCount} -u ${name}token${loopCount} -p ${tokenPassword} -n ${name} --yes

az acr token credential generate -n ${name}token${loopCount} -r ${name}
docker push ${name}.azurecr.io/alpine${loopCount}

docker login -u ${name}token${loopCount} -p ${tokenPassword} ${name}.azurecr.io
docker push ${name}.azurecr.io/alpine${loopCount}

az acr token update -n ${name}token${loopCount} -r ${name} --status disabled
docker tag hello-world ${name}a.azurecr.io/alpine${loopCount}
docker push ${name}a.azurecr.io/alpine${loopCount}

let "loopCount++"
done
;;

*)
echo "Error: ${tit} could not be found."
break
Expand All @@ -70,12 +126,15 @@ esac
echo "========================================================== Enter CTRL+C to end Or Enter other key to delete image ============================================================"
read sthmessage

#docker system prune -a #清空全部的 image container
#docker system prune -a #Delete all image and container.

loopCount=1
while ((${loopCount}<=${num}))
do
docker rmi ${name}.${name}.azurecr.io/alpine${loopCount}
docker rmi ${name}a.${name}.azurecr.io/alpine${loopCount}
docker rmi ${name}.${name}.azurecr.io/hello-world${loopCount}
docker rmi ${name}.azurecr.io/newimagename${loopCount}
docker rmi ${name}.azurecr.io/newimagename:version${loopCount}
let "loopCount++"
done
done

0 comments on commit 33c482b

Please sign in to comment.