From 972af5b9840d9be765e0537ec0486f2cd0325e64 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 29 Aug 2015 01:53:34 -0400 Subject: [PATCH] Use central config for env vars --- commands | 11 +---------- dependencies | 1 + docker-args | 2 +- functions | 8 +++----- install | 10 +--------- 5 files changed, 7 insertions(+), 25 deletions(-) diff --git a/commands b/commands index fcfad07..072d85b 100755 --- a/commands +++ b/commands @@ -2,16 +2,7 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$(dirname "$0")/../common/functions" source "$(dirname "$0")/functions" - -POSTGRES_IMAGE=${POSTGRES_IMAGE:="postgres"} -POSTGRES_IMAGE_VERSION=${POSTGRES_IMAGE_VERSION:="9.5"} -POSTGRES_ROOT=/var/lib/dokku/services/postgres - -PLUGIN_COMMAND_PREFIX="postgres" -PLUGIN_DATA_ROOT=$POSTGRES_ROOT -PLUGIN_SERVICE="Postgres" -PLUGIN_IMAGE=$POSTGRES_IMAGE -PLUGIN_IMAGE_VERSION=$POSTGRES_IMAGE_VERSION +source "$(dirname "$0")/config" if [[ ! -d $PLUGIN_DATA_ROOT ]]; then dokku_log_fail "$PLUGIN_SERVICE: Please run: sudo dokku plugins-install" diff --git a/dependencies b/dependencies index 6eacec8..d368ae6 100755 --- a/dependencies +++ b/dependencies @@ -1,5 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$(dirname "$0")/config" case "$DOKKU_DISTRO" in ubuntu) diff --git a/docker-args b/docker-args index 4601fe2..9e39800 100755 --- a/docker-args +++ b/docker-args @@ -2,10 +2,10 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$(dirname "$0")/../common/functions" source "$(dirname "$0")/functions" +source "$(dirname "$0")/config" STDIN=$(cat) APP="$1" -PLUGIN_DATA_ROOT=/var/lib/dokku/services/postgres output="" for i in $PLUGIN_DATA_ROOT/*; do diff --git a/functions b/functions index 1c5dad2..67711f4 100755 --- a/functions +++ b/functions @@ -1,8 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x - -PLUGIN_DATA_ROOT=/var/lib/dokku/services/postgres -PLUGIN_SERVICE="Postgres" +source "$(dirname "$0")/config" get_random_port() { local port=$RANDOM @@ -38,7 +36,7 @@ service_alias() { if [[ -f "$ALIAS_FILE" ]]; then cat "$ALIAS_FILE" else - echo "DATABASE" + echo "$PLUGIN_DEFAULT_ALIAS" fi } @@ -50,5 +48,5 @@ service_url() { local ID="$(cat "$SERVICE_ROOT/ID")" local IP="$(get_container_ip "$ID")" local PASSWORD="$(cat "$SERVICE_ROOT/PASSWORD")" - echo "postgres://postgres:$PASSWORD@$IP:5432/$SERVICE" + echo "$PLUGIN_SCHEME://postgres:$PASSWORD@$IP:$PLUGIN_DATASTORE_PORT/$SERVICE" } diff --git a/install b/install index 82361fb..91a71d1 100755 --- a/install +++ b/install @@ -1,14 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x - -POSTGRES_IMAGE="postgres" -POSTGRES_IMAGE_VERSION=9.5 -POSTGRES_ROOT=/var/lib/dokku/services/postgres - -PLUGIN_DATA_ROOT=$POSTGRES_ROOT -PLUGIN_SERVICE="Postgres" -PLUGIN_IMAGE=$POSTGRES_IMAGE -PLUGIN_IMAGE_VERSION=$POSTGRES_IMAGE_VERSION +source "$(dirname "$0")/config" if ! docker images | grep -e "^$PLUGIN_IMAGE " | grep -q $PLUGIN_IMAGE_VERSION ; then docker pull $PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION