From 31eacbf29874603571c5d589398563bef55159a4 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 8 May 2016 03:01:41 -0400 Subject: [PATCH 1/8] Add testing for all supported versions of dokku Also drop support for 0.3.x --- .travis.yml | 1 + README.md | 9 ++------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index c08f6d2..4b4255e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,5 +3,6 @@ dist: trusty language: bash env: - DOKKU_VERSION=master + - DOKKU_VERSION=v0.4.14 before_install: make setup script: make test diff --git a/README.md b/README.md index cc41125..52523a4 100644 --- a/README.md +++ b/README.md @@ -4,18 +4,13 @@ Official mysql plugin for dokku. Currently defaults to installing [mysql 5.7.12] ## requirements -- dokku 0.4.0+ +- dokku 0.4.x+ - docker 1.8.x ## installation ```shell -# on 0.3.x -cd /var/lib/dokku/plugins -git clone https://github.com/dokku/dokku-mysql.git mysql -dokku plugins-install - -# on 0.4.x +# on 0.4.x+ dokku plugin:install https://github.com/dokku/dokku-mysql.git mysql ``` From 11615bea773effa2295a909f9611a8450895ea44 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 8 May 2016 03:01:59 -0400 Subject: [PATCH 2/8] Rework how config vars are sourced - ensure we source config/functions from the correct directory - move config sourcing up before DOKKU_TRACE to reduce trace output --- commands | 4 ++-- functions | 2 +- install | 2 +- pre-delete | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/commands b/commands index ab0f4f4..6dd3112 100755 --- a/commands +++ b/commands @@ -1,4 +1,5 @@ #!/usr/bin/env bash +source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config" set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x PLUGIN_BASE_PATH="$PLUGIN_PATH" @@ -6,8 +7,7 @@ if [[ -n $DOKKU_API_VERSION ]]; then PLUGIN_BASE_PATH="$PLUGIN_ENABLED_PATH" fi source "$PLUGIN_BASE_PATH/common/functions" -source "$(dirname "$0")/functions" -source "$(dirname "$0")/config" +source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/functions" if [[ $1 == $PLUGIN_COMMAND_PREFIX:* ]]; then if [[ ! -d $PLUGIN_DATA_ROOT ]]; then diff --git a/functions b/functions index 90c54f9..c77d734 100755 --- a/functions +++ b/functions @@ -1,6 +1,6 @@ #!/usr/bin/env bash +source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config" set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname "$0")/config" source "$PLUGIN_AVAILABLE_PATH/config/functions" get_random_ports() { diff --git a/install b/install index ee439da..170e018 100755 --- a/install +++ b/install @@ -1,6 +1,6 @@ #!/usr/bin/env bash +source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config" set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x -source "$(dirname "$0")/config" if ! docker images | grep -e "^$PLUGIN_IMAGE " | grep -q "$PLUGIN_IMAGE_VERSION" ; then docker pull "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" diff --git a/pre-delete b/pre-delete index 22897dc..403cad4 100755 --- a/pre-delete +++ b/pre-delete @@ -1,4 +1,5 @@ #!/usr/bin/env bash +source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config" set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x PLUGIN_BASE_PATH="$PLUGIN_PATH" @@ -6,8 +7,7 @@ if [[ -n $DOKKU_API_VERSION ]]; then PLUGIN_BASE_PATH="$PLUGIN_ENABLED_PATH" fi source "$PLUGIN_BASE_PATH/common/functions" -source "$(dirname "$0")/functions" -source "$(dirname "$0")/config" +source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/functions" APP="$1" for SERVICE in "$PLUGIN_DATA_ROOT"/*; do From ca5421012b5a66000365c6b178d595d692b22721 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 8 May 2016 03:02:15 -0400 Subject: [PATCH 3/8] quote $APP variable --- functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions b/functions index c77d734..7317805 100755 --- a/functions +++ b/functions @@ -384,6 +384,6 @@ service_linked_apps() { update_plugin_scheme_for_app() { local APP=$1 - local MYSQL_DATABASE_SCHEME=$(config_get $APP MYSQL_DATABASE_SCHEME) + local MYSQL_DATABASE_SCHEME=$(config_get "$APP" MYSQL_DATABASE_SCHEME) PLUGIN_SCHEME=${MYSQL_DATABASE_SCHEME:-$PLUGIN_SCHEME} } From df1289d82ed814dc050d58aab3f8e70bd4a2b2ce Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 8 May 2016 03:02:23 -0400 Subject: [PATCH 4/8] Move command check before DOKKU_TRACE to reduce trace output --- commands | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/commands b/commands index 6dd3112..1287c01 100755 --- a/commands +++ b/commands @@ -1,5 +1,6 @@ #!/usr/bin/env bash source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/config" +[[ " help $PLUGIN_COMMAND_PREFIX:help " == *" $1 "* ]] || [[ "$1" == "$PLUGIN_COMMAND_PREFIX:"* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT" set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x PLUGIN_BASE_PATH="$PLUGIN_PATH" @@ -9,10 +10,8 @@ fi source "$PLUGIN_BASE_PATH/common/functions" source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/functions" -if [[ $1 == $PLUGIN_COMMAND_PREFIX:* ]]; then - if [[ ! -d $PLUGIN_DATA_ROOT ]]; then - dokku_log_fail "$PLUGIN_SERVICE: Please run: sudo dokku plugin:install" - fi +if [[ ! -d $PLUGIN_DATA_ROOT ]]; then + dokku_log_fail "$PLUGIN_SERVICE: Please run: sudo dokku plugin:install" fi if [[ -d "$PLUGIN_DATA_ROOT/*" ]]; then From 4b6ac411895f7970b0af057ce827d55ce7c7fc1c Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 8 May 2016 03:02:29 -0400 Subject: [PATCH 5/8] Download correct version of plugn when running tests under OS X --- tests/test_helper.bash | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_helper.bash b/tests/test_helper.bash index deedd65..6cdc6d8 100644 --- a/tests/test_helper.bash +++ b/tests/test_helper.bash @@ -10,7 +10,11 @@ export PLUGIN_AVAILABLE_PATH="$PLUGIN_PATH" export PLUGIN_CORE_AVAILABLE_PATH="$PLUGIN_PATH" export MYSQL_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/fixtures" export PLUGIN_DATA_ROOT="$MYSQL_ROOT" -export PLUGN_URL="https://github.com/dokku/plugn/releases/download/v0.2.1/plugn_0.2.1_linux_x86_64.tgz" +if [[ "$(uname)" == "Darwin" ]]; then + export PLUGN_URL="https://github.com/dokku/plugn/releases/download/v0.2.1/plugn_0.2.1_darwin_x86_64.tgz" +else + export PLUGN_URL="https://github.com/dokku/plugn/releases/download/v0.2.1/plugn_0.2.1_linux_x86_64.tgz" +fi mkdir -p "$PLUGIN_DATA_ROOT" rm -rf "${PLUGIN_DATA_ROOT:?}"/* From a55726a55a0b7001738073805074d91384953c18 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 8 May 2016 03:02:35 -0400 Subject: [PATCH 6/8] Add a dummy lsb_release command to test binaries This should allow us to run tests on os x using the current dokku binary --- tests/bin/lsb_release | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100755 tests/bin/lsb_release diff --git a/tests/bin/lsb_release b/tests/bin/lsb_release new file mode 100755 index 0000000..222c10d --- /dev/null +++ b/tests/bin/lsb_release @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +if [[ "$(uname)" == "Darwin" ]]; then + echo "Darwin" +else + echo "Ubuntu" +fi From 424a725c8db267226121ab421430d7d4390b268b Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 8 May 2016 03:02:42 -0400 Subject: [PATCH 7/8] Quote more variables --- functions | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions b/functions index 7317805..446a1d7 100755 --- a/functions +++ b/functions @@ -305,8 +305,8 @@ service_url() { echo "$PLUGIN_SCHEME://mysql:$PASSWORD@$SERVICE_ALIAS:${PLUGIN_DATASTORE_PORTS[0]}/$SERVICE" } -is_container_status () { - local CID=$1 +is_container_status() { + local CID="$1" local TEMPLATE="{{.State.$2}}" local CONTAINER_STATUS=$(docker inspect -f "$TEMPLATE" "$CID" || true) @@ -383,7 +383,7 @@ service_linked_apps() { } update_plugin_scheme_for_app() { - local APP=$1 + local APP="$1" local MYSQL_DATABASE_SCHEME=$(config_get "$APP" MYSQL_DATABASE_SCHEME) PLUGIN_SCHEME=${MYSQL_DATABASE_SCHEME:-$PLUGIN_SCHEME} } From 857c9d4d1890d000ed0c8e90c6add7f48e758915 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 8 May 2016 03:02:48 -0400 Subject: [PATCH 8/8] use grep -q when checking for docker images --- install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install b/install index 170e018..c59ac06 100755 --- a/install +++ b/install @@ -6,11 +6,11 @@ if ! docker images | grep -e "^$PLUGIN_IMAGE " | grep -q "$PLUGIN_IMAGE_VERSION" docker pull "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" fi -if ! docker images | grep -e "^svendowideit/ambassador "; then +if ! docker images | grep -q -e "^svendowideit/ambassador "; then docker pull svendowideit/ambassador:latest fi -if ! docker images | grep -e "^dokkupaas/wait "; then +if ! docker images | grep -q -e "^dokkupaas/wait "; then docker pull dokkupaas/wait:latest fi