Skip to content

Commit 3d3587e

Browse files
committed
Implemente docke hub api version 2 and tests
1 parent b4eecac commit 3d3587e

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

dockerhub/dockerhub-check-image-exists.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ dockerhub_check_image_exists()
5050
fi
5151
}
5252

53-
5453
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
5554

5655
FUNCTION_NAME=dockerhub_check_image_exists
@@ -69,4 +68,3 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
6968
printf "${green}$check test passed!\n${reset}"
7069
fi
7170
fi
72-

dockerhub/dockerhub-list-tags.sh

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,27 @@ dockerhub_list_tags()
4242

4343
# This command will filter the number versions and limited to one dot (.) and two versions such as 0.1 or all versions if LOCAL_GET_TWO_DIGITS_VERSIONS is set to false
4444
if [[ "$LOCAL_GET_TWO_DIGITS_VERSIONS" == true ]]; then
45-
DOCKERHUB_LIST_TAGS=($(wget -q https://registry.hub.docker.com/v1/repositories/$LOCAL_IMAGE/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}' | grep '^[0-9]' | grep -v '-' | grep -v '\.[0-9]\.'))
45+
DOCKERHUB_LIST_TAGS=($(wget -q https://hub.docker.com/v2/namespaces/library/repositories/$LOCAL_IMAGE/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}' | grep '^[0-9]' | grep -v '-' | grep -v '\.[0-9]\.'))
4646
else
47-
DOCKERHUB_LIST_TAGS=($(wget -q https://registry.hub.docker.com/v1/repositories/$LOCAL_IMAGE/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}' | grep '^[0-9]' | grep -v '-'))
47+
DOCKERHUB_LIST_TAGS=($(wget -q https://hub.docker.com/v2/namespaces/library/repositories/$LOCAL_IMAGE/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}' | grep '^[0-9]' | grep -v '-'))
4848
fi
4949
}
50+
51+
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
52+
53+
FUNCTION_NAME=dockerhub_list_tags
54+
55+
BASESCRIPT_LOG_ALL_ACTIONS=false
56+
source ./../messages/message-echoout.sh
57+
source ./../init/color.sh
58+
source ./../init/symbol.sh
59+
LOCAL_RESULT=$($FUNCTION_NAME $1 $2 2>&1)
60+
61+
RETURN_CODE=$?
62+
if [[ $LOCAL_RESULT == *"ERRO"* ]] || [[ $LOCAL_RESULT == *"erro"* ]] || [[ "$RETURN_CODE" != 0 ]]; then
63+
printf "${red}$cross Error\n${reset}"
64+
printf "Function: '$FUNCTION_NAME'\nOutput:\n$LOCAL_RESULT\n"
65+
else
66+
printf "${green}$check test passed!\n${reset}"
67+
fi
68+
fi

0 commit comments

Comments
 (0)