mirror of https://github.com/easzlab/kubeasz.git
modified dockertag: wget -> curl, add harbor-image-tag for query private harbor registry project, tags
parent
4dab4aed24
commit
0e988944bc
|
@ -1,5 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
|
||||||
function usage() {
|
function usage() {
|
||||||
cat << HELP
|
cat << HELP
|
||||||
|
|
||||||
|
@ -17,13 +16,13 @@ HELP
|
||||||
|
|
||||||
if [ $# -lt 1 ]; then
|
if [ $# -lt 1 ]; then
|
||||||
usage
|
usage
|
||||||
exit 2
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
image="$1"
|
image="$1"
|
||||||
tags=`wget -q https://registry.hub.docker.com/v1/repositories/${image}/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}'`
|
tags=$(curl -ksL https://registry.hub.docker.com/v1/repositories/${image}/tags | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}')
|
||||||
|
|
||||||
if [ -n "$2" ]; then
|
if [ -n "$2" ]; then
|
||||||
tags=`echo "${tags}" | grep "$2"`
|
tags=$(echo "${tags}" | grep "$2")
|
||||||
fi
|
fi
|
||||||
echo "${tags}"
|
echo "${tags}"
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
function usage() {
|
||||||
|
cat << HELP
|
||||||
|
|
||||||
|
harbor-image-tag -- list all tags for a Docker image on a remote Harbor Registry
|
||||||
|
|
||||||
|
EXAMPLE:
|
||||||
|
- list all images:
|
||||||
|
harbor-image-tag get_images
|
||||||
|
|
||||||
|
- list all tags for redis:
|
||||||
|
harbor-image-tag get_tags redis/redis
|
||||||
|
|
||||||
|
HELP
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ $# -lt 1 ]; then
|
||||||
|
usage
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
USER="admin"
|
||||||
|
PASS="XXXXXXXXXXXXXXXXXX"
|
||||||
|
HURL="https://{{ HARBOR_DOMAIN }}"
|
||||||
|
MTAG=$2
|
||||||
|
|
||||||
|
function get_images() {
|
||||||
|
RTOKEN=$(curl -k -s -u ${USER}:${PASS} ${HURL}/service/token?account=${USER}\&service=harbor-registry\&scope=registry:catalog:* | grep "token" | awk -F '"' '{print $4}')
|
||||||
|
RLIST=$(curl -k -s -H "authorization: bearer ${RTOKEN} " ${HURL}/v2/_catalog | awk -F '[' '{print $2}'|awk -F ']' '{print $1}' | sed 's/"//g')
|
||||||
|
echo ${RLIST} | tr ',' '\n'
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_tags() {
|
||||||
|
TTOKEN=$(curl -iksL -X GET -u ${USER}:${PASS} ${HURL}/service/token?account=${USER}\&service=harbor-registry\&scope=repository:${MTAG}:pull | grep "token" | awk -F '"' '{print $4}')
|
||||||
|
TLIST=$(curl -ksL -X GET -H "Content-Type: application/json" -H "Authorization: Bearer ${TTOKEN}" ${HURL}/v2/${MTAG}/tags/list| awk -F '[' '{print $2}' | awk -F ']' '{print $1}' | sed 's/"//g')
|
||||||
|
echo ${TLIST} | tr ',' '\n'
|
||||||
|
}
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
get_images)
|
||||||
|
get_images
|
||||||
|
;;
|
||||||
|
get_tags)
|
||||||
|
get_tags
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
esac
|
Loading…
Reference in New Issue