-
Notifications
You must be signed in to change notification settings - Fork 0
/
loop.txt
144 lines (114 loc) · 7.78 KB
/
loop.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/bash
echo "===================================================================== Do you need Login?(Y,y/N,n) =========================================================================="
read needLogin
if [ ${needLogin} == "Y" -o ${needLogin} == "y" ]
then
echo "============================================================================= az login ... ================================================================================="
az login
echo "=============================================================== Please input you want to use account ID ... ================================================================"
read accountId
az account set -s ${accountId}
echo "================================================================== Please input Container Registry Name ... ================================================================"
read containerRegistryName
az acr login -n ${containerRegistryName}
echo "============================================================================== docker login ... ============================================================================"
docker login ${containerRegistryName}.azurecr.io
fi
echo "==================================================================== Input Container Registry Name! =========================================================================="
read name
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
loopCount=1
case ${tit} in
"t")
while ((${loopCount}<=${num}))
do
docker tag hello-world ${name}.azurecr.io/newimagename:version${loopCount}
let "loopCount++"
done
echo "Push?(Y,y/N,n)"
read _input
if [ ${_input} == "Y" -o ${_input} == "y" ]
then
loopCount=1
while ((${loopCount}<=${num}))
do
docker push ${name}.azurecr.io/newimagename:version${loopCount}
let "loopCount++"
done
fi
;;
"r"|"R")
while ((${loopCount}<=${num}))
do
docker tag hello-world ${name}.azurecr.io/newimagename${loopCount}
docker push ${name}.azurecr.io/newimagename${loopCount}
let "loopCount++"
done
;;
"T")
while ((${loopCount}<=${num}))
do
az acr task create -n Task${name}${loopCount} -r ${name} --cmd hello-world -c /dev/null
az acr task run -n Task${name}${loopCount} -r ${name}
let "loopCount++"
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
;;
esac
echo "========================================================== Enter CTRL+C to end Or Enter other key to delete image ============================================================"
echo "docker system prune -a #Delete all image and container. "
read sthmessage
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