删除harbor项目下的所有镜像

user=
pswd=
url=
proid=

REPOS=$(curl -s -X GET --header 'Accept: application/json' "${url}/api/repositories?project_id=${proid}"|grep "name"|awk -F '"' '{print $4}')

for rp in ${REPOS}
do
  TAGS=$(curl -s -X GET --header 'Accept: application/json' "${url}/api/repositories/${rp}/tags"|grep \"name\"|awk -F '"' '{print $4}')
    for t in ${TAGS}
    do
        curl -u "${user}:${pswd}" -X DELETE -H "Content-Type: application/json" "${url}/api/repositories/${rp}/tags/${t}"
        echo ${URL}"/"${rp}":"${t} >> /app/container/docker.tag
    done
  echo "删除 ===> ${URL}\/${rp}\/${t}"
done
posted @ 2019-11-01 20:52  博客萨斯州  阅读(858)  评论(0编辑  收藏  举报