From 11f523116f34e9170950e3f9214e7fbaf5f6edb0 Mon Sep 17 00:00:00 2001 From: Quentin Duchemin <quentinduchemin@tuta.io> Date: Mon, 1 Jun 2020 22:42:44 +0200 Subject: [PATCH] [docker_test.sh] Add logic for new services --- docker_test.sh | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/docker_test.sh b/docker_test.sh index 0a6c7d90..988d8d1c 100755 --- a/docker_test.sh +++ b/docker_test.sh @@ -24,29 +24,21 @@ if [[ $# -ne 1 ]]; then usage fi -if [[ ! -d "$1" ]]; then - echo "ERROR : directory does not exist ($1)" - usage -fi - -# Go to the folder of the service which will be tested -cd "$1" - echo -e "Starting procedure for \033[31m$1\e[0m..." -if [[ -d secrets ]]; then - cd secrets - echo -e "\n==== Create dumb secret files ====" - for f in *.secrets.example; do - echo -e "\tFile $1/secrets/$(basename -- "$f" .secrets.example).secrets created" - cp -- "$f" "$(basename -- "$f" .secrets.example).secrets" - done +# In case the Docker Compose changed since latest local commit, +# we need to set all down before pulling +if [[ -d "$1" ]]; then + # Go to the folder of the service which will be tested + cd "$1" + + echo -e "\n==== Stop and remove existing containers ====" + docker-compose down cd .. +else + echo "WARNING : directory does not exist ($1) ; will try to pull" fi -echo -e "\n==== Stop and remove existing containers ====" -docker-compose down - echo -e "\n==== RESET HARD and pull Dockerfiles repository ====" echo -e "Using branch \033[31m $(git rev-parse --abbrev-ref HEAD)\e[0m, is this correct ? [y/N]" read ans @@ -59,6 +51,24 @@ else exit 0 fi +if [[ -d "$1" ]]; then + echo "ERROR : directory does not exist ($1)" + usage + exit 1 +fi + +cd "$1" + +if [[ -d secrets ]]; then + cd secrets + echo -e "\n==== Create dumb secret files ====" + for f in *.secrets.example; do + echo -e "\tFile $1/secrets/$(basename -- "$f" .secrets.example).secrets created" + cp -- "$f" "$(basename -- "$f" .secrets.example).secrets" + done + cd .. +fi + echo -e "\n==== Replace production URL with testing URL in all files ====" for f in $(grep -l -r ".picasoft.net" .); do echo -e "\tFound in" ${f} -- GitLab