From 9ea65023d2eee0668ac36233d488cba193008a9a Mon Sep 17 00:00:00 2001 From: EJ Etherington Date: Mon, 24 Jul 2017 14:39:11 -0700 Subject: [PATCH 1/5] simple idea to make rok8s-scripts compatible with docker older and newer docker versions --- bin/docker-push | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/docker-push b/bin/docker-push index 0df56cf6..df6976ab 100755 --- a/bin/docker-push +++ b/bin/docker-push @@ -31,7 +31,11 @@ then exit 1 fi -docker tag -f "${DOCKERTAG}:latest" "${EXTERNAL_REGISTRY_BASE_DOMAIN}/${REPOSITORY_NAME}:${CI_REF}" +DOCKER_TAG_COM="docker tag" +docker version | grep -e Version | head -n 1 | grep 1.9 && DOCKER_TAG_COM="${DOCKER_TAG_COM} -f " + +$DOCKER_TAG_COM "${DOCKERTAG}:latest" "${EXTERNAL_REGISTRY_BASE_DOMAIN}/${REPOSITORY_NAME}:${CI_REF}" + if [ $? -ne 0 ] then echo "Unable to tag image, aborting" From a20a7e0b82bd22102768d505ddf605922b8a4a6d Mon Sep 17 00:00:00 2001 From: EJ Etherington Date: Tue, 25 Jul 2017 10:24:02 -0700 Subject: [PATCH 2/5] fixing short sighted initial attempt. Added actual version comparision that _should_ be safe enough for any docker version --- bin/docker-push | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/docker-push b/bin/docker-push index df6976ab..15eebfdd 100755 --- a/bin/docker-push +++ b/bin/docker-push @@ -32,7 +32,14 @@ then fi DOCKER_TAG_COM="docker tag" -docker version | grep -e Version | head -n 1 | grep 1.9 && DOCKER_TAG_COM="${DOCKER_TAG_COM} -f " +version=`docker version | grep -e Version | head -n 1 | awk '{ print $2 }'` +major=`echo $version | awk -F. '{ print $1 }'` +minor=`echo $version | awk -F. '{ print $2 }'` + +if [[ $minor -le 9 && $major -eq 1 ]] || [ $major -eq 0 ] +then + DOCKER_TAG_COM="${DOCKER_TAG_COM} -f " +fi $DOCKER_TAG_COM "${DOCKERTAG}:latest" "${EXTERNAL_REGISTRY_BASE_DOMAIN}/${REPOSITORY_NAME}:${CI_REF}" From 06e1089ce910571fa5c7cfd154a2f3db1c5037fd Mon Sep 17 00:00:00 2001 From: EJ Etherington Date: Tue, 25 Jul 2017 10:37:35 -0700 Subject: [PATCH 3/5] fixing deprecated syntax to pass tests --- bin/docker-push | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/docker-push b/bin/docker-push index 15eebfdd..e792762c 100755 --- a/bin/docker-push +++ b/bin/docker-push @@ -32,11 +32,11 @@ then fi DOCKER_TAG_COM="docker tag" -version=`docker version | grep -e Version | head -n 1 | awk '{ print $2 }'` -major=`echo $version | awk -F. '{ print $1 }'` -minor=`echo $version | awk -F. '{ print $2 }'` +version=$(docker version | grep -e Version | head -n 1 | awk '{ print $2 }') +major=$(echo ${version} | awk -F. '{ print $1 }') +minor=$(echo ${version} | awk -F. '{ print $2 }') -if [[ $minor -le 9 && $major -eq 1 ]] || [ $major -eq 0 ] +if [[ ${minor} -le 9 && ${major} -eq 1 ]] || [ ${major} -eq 0 ] then DOCKER_TAG_COM="${DOCKER_TAG_COM} -f " fi From 780f1e1946ef4abdd3ce4804b289970ac83916c5 Mon Sep 17 00:00:00 2001 From: EJ Etherington Date: Tue, 25 Jul 2017 10:42:40 -0700 Subject: [PATCH 4/5] fixing some test requirements I missed --- bin/docker-push | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/docker-push b/bin/docker-push index e792762c..81fa1087 100755 --- a/bin/docker-push +++ b/bin/docker-push @@ -33,10 +33,10 @@ fi DOCKER_TAG_COM="docker tag" version=$(docker version | grep -e Version | head -n 1 | awk '{ print $2 }') -major=$(echo ${version} | awk -F. '{ print $1 }') -minor=$(echo ${version} | awk -F. '{ print $2 }') +major=$(echo "${version}" | awk -F. '{ print $1 }') +minor=$(echo "${version}" | awk -F. '{ print $2 }') -if [[ ${minor} -le 9 && ${major} -eq 1 ]] || [ ${major} -eq 0 ] +if [[ "${minor}" -le 9 && "${major}" -eq 1 ]] || [ "${major}" -eq 0 ] then DOCKER_TAG_COM="${DOCKER_TAG_COM} -f " fi From 8bf0ed23540fc157765d01cf30603e16069e9c22 Mon Sep 17 00:00:00 2001 From: EJ Etherington Date: Tue, 25 Jul 2017 11:10:46 -0700 Subject: [PATCH 5/5] preventing potential octal interpretation of minor version number --- bin/docker-push | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/docker-push b/bin/docker-push index 81fa1087..668f6d0b 100755 --- a/bin/docker-push +++ b/bin/docker-push @@ -36,7 +36,7 @@ version=$(docker version | grep -e Version | head -n 1 | awk '{ print $2 }') major=$(echo "${version}" | awk -F. '{ print $1 }') minor=$(echo "${version}" | awk -F. '{ print $2 }') -if [[ "${minor}" -le 9 && "${major}" -eq 1 ]] || [ "${major}" -eq 0 ] +if [[ "${minor#0}" -le 9 && "${major}" -eq 1 ]] || [ "${major}" -eq 0 ] then DOCKER_TAG_COM="${DOCKER_TAG_COM} -f " fi