From ea9971404fb031d2f183a4ddf79162173ee117b8 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 8 May 2016 02:59:32 -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 9bed871..dfc4ed8 100644 --- a/README.md +++ b/README.md @@ -4,18 +4,13 @@ Official mongo plugin for dokku. Currently defaults to installing [mongo 3.2.6]( ## 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-mongo.git mongo -dokku plugins-install - -# on 0.4.x +# on 0.4.x+ dokku plugin:install https://github.com/dokku/dokku-mongo.git mongo ``` From 3edec37f54be0f0a6602fdd29fd112702ce1c026 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 8 May 2016 03:00:05 -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 5c48329..15275cc 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 b616182..3922e74 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 0e5e1b8fc3d211db7be751daf13072ee13dae6ae Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 8 May 2016 03:00:17 -0400 Subject: [PATCH 3/8] quote $APP variable --- functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions b/functions index 3922e74..37778e7 100755 --- a/functions +++ b/functions @@ -385,6 +385,6 @@ service_linked_apps() { update_plugin_scheme_for_app() { local APP=$1 - local MONGO_DATABASE_SCHEME=$(config_get $APP MONGO_DATABASE_SCHEME) + local MONGO_DATABASE_SCHEME=$(config_get "$APP" MONGO_DATABASE_SCHEME) PLUGIN_SCHEME=${MONGO_DATABASE_SCHEME:-$PLUGIN_SCHEME} } From bce92157fcf7494bf543cfd422b5f158660fe583 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 8 May 2016 03:00:25 -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 15275cc..ec52dcb 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 e1de34807f10f909dd6fe16921d2b51778be9872 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 8 May 2016 03:00:34 -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 5c98aa8..8d576ea 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 MONGO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/fixtures" export PLUGIN_DATA_ROOT="$MONGO_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 e6d819e6ef84777dbac196e0790eec0d98fd0d58 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 8 May 2016 03:00:40 -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 2cd7c1a352357f90811c1e11235770122749299e Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 8 May 2016 03:00:47 -0400 Subject: [PATCH 7/8] Quote more variables --- functions | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions b/functions index 37778e7..0b8c8b4 100755 --- a/functions +++ b/functions @@ -306,8 +306,8 @@ service_url() { echo "$PLUGIN_SCHEME://$SERVICE:$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) @@ -384,7 +384,7 @@ service_linked_apps() { } update_plugin_scheme_for_app() { - local APP=$1 + local APP="$1" local MONGO_DATABASE_SCHEME=$(config_get "$APP" MONGO_DATABASE_SCHEME) PLUGIN_SCHEME=${MONGO_DATABASE_SCHEME:-$PLUGIN_SCHEME} } From b3145a8ab710ba7bf879070c84c89a08482b2c63 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 8 May 2016 03:00:54 -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