Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions xfce-test
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ RUN_AS=
LOG=${LOG:-/dev/stdout}
PARALLEL_BUILDS=${PARALLEL_BUILDS:-0}
TRAVIS=${TRAVIS:-FALSE}
TAG='latest'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer if it can be overridden if needed

Suggested change
TAG='latest'
TAG=${TAG:-latest}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're absolutely right, fixing it now.


is_my_git() {
if git remote -v 2>/dev/null|grep "schuellerf/xfce-test" &>/dev/null; then
Expand Down Expand Up @@ -84,6 +85,30 @@ get-free-display(){
done
}

# checks that the passed tag is available on Dockerhub
validate_tag(){
if [ $# -ne 1 ]; then
printf "ERROR: you need to supply one argument!\n"
exit 1
fi
TAG="$1"
if [ -z "${TAG}" ]; then
TAG='latest'
return 0
else
# check the tag is valid
tags="$(get_tags)"
for t in ${tags}; do
if [ "${t}" = "${TAG}" ]; then
return 0
fi
done
# the specified tag doesn't exist on Dockerhub
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could move the error message and printing of all tags which are available here.
(or you wanted to make the call more encapsulated?)
Either way I think printing the list of available tags, if not found, would improve the usability alot

return 1
fi
}


# use this X display number for the tests
export DISPLAY_NUM=$(get-free-display)

Expand Down Expand Up @@ -194,17 +219,6 @@ MODES_FOR_CASE=$(IFS=$'|'; echo "${WORK_MODES[*]}")
shopt -s extglob
MODES_FOR_CASE="+($MODES_FOR_CASE)"

if [ -z $TAG ]; then
if is_my_git; then
TAG=$(git rev-parse --abbrev-ref HEAD 2>/dev/null|tr '/' '_')
if [[ $TAG == "last_tag" ]]; then
TAG=latest
fi
else
TAG=latest
fi
fi

if [ $# -ge 1 ]; then
case $1 in
"install")
Expand All @@ -227,7 +241,11 @@ if [ $# -ge 1 ]; then
;;
"pull")
if [ -n "$2" ]; then
TAG=$2
TAG="$2"
if ! validate_tag "${TAG}"; then
printf "The tag '%s' was not found on Dockerhub\n" "${TAG}"
exit 2
fi
fi
mode=$1
;;
Expand Down