From 78fcca689675e0ffe870602e701f9fbe324919bf Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 8 May 2016 03:10:15 -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 32d691b..0bb618d 100644 --- a/README.md +++ b/README.md @@ -4,18 +4,13 @@ Official postgres plugin for dokku. Currently defaults to installing [postgres 9 ## 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-postgres.git postgres -dokku plugins-install - -# on 0.4.x +# on 0.4.x+ dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres ``` From 543fdaa63321079c0a66b27a3467a9d78b9c4b1f Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 8 May 2016 03:10:41 -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 5af4778..7ed0fcb 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 eab406d..75c028b 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 93c720aeb7ce088824aaaae03b9ef784be46f4a7 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 8 May 2016 03:10:52 -0400 Subject: [PATCH 3/8] quote $APP variable --- functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions b/functions index 75c028b..deffc1b 100755 --- a/functions +++ b/functions @@ -402,6 +402,6 @@ service_linked_apps() { update_plugin_scheme_for_app() { local APP=$1 - local POSTGRES_DATABASE_SCHEME=$(config_get $APP POSTGRES_DATABASE_SCHEME) + local POSTGRES_DATABASE_SCHEME=$(config_get "$APP" POSTGRES_DATABASE_SCHEME) PLUGIN_SCHEME=${POSTGRES_DATABASE_SCHEME:-$PLUGIN_SCHEME} } From 0d41bf2d6fb6cc9f02e6937c1651d0d8d829c892 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 8 May 2016 03:10:59 -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 7ed0fcb..70019a3 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 5de702ea7a1d3db38b86c4a7df74d6f439302f7e Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 8 May 2016 03:11:05 -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 d4f8dba..fc2107d 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 POSTGRES_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/fixtures" export PLUGIN_DATA_ROOT="$POSTGRES_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 f93db550695d65ad7c7f1ef0e9e3e0ba0fde402f Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 8 May 2016 03:11:10 -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 dbbae006e83d96c711a6a02fc01e9f7db64c0f08 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 8 May 2016 03:11:18 -0400 Subject: [PATCH 7/8] Quote more variables --- functions | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions b/functions index deffc1b..2f1a393 100755 --- a/functions +++ b/functions @@ -317,8 +317,8 @@ service_url() { echo "$PLUGIN_SCHEME://postgres:$PASSWORD@$SERVICE_ALIAS:${PLUGIN_DATASTORE_PORTS[0]}/$DATABASE_NAME" } -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) @@ -401,7 +401,7 @@ service_linked_apps() { } update_plugin_scheme_for_app() { - local APP=$1 + local APP="$1" local POSTGRES_DATABASE_SCHEME=$(config_get "$APP" POSTGRES_DATABASE_SCHEME) PLUGIN_SCHEME=${POSTGRES_DATABASE_SCHEME:-$PLUGIN_SCHEME} } From f2b66e8142048903b2e8ec4f257603c940251ae7 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 8 May 2016 03:11:24 -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