From 653bb8828bbfa32a372996bc04c7c10e4a3f16df Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 29 Aug 2015 01:54:00 -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 13043aa..773d77d 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" - -MONGO_IMAGE=${MONGO_IMAGE:="mongo"} -MONGO_IMAGE_VERSION=${MONGO_IMAGE_VERSION:="3.1.6"} -MONGO_ROOT=/var/lib/dokku/services/mongo - -PLUGIN_COMMAND_PREFIX="mongo" -PLUGIN_DATA_ROOT=$MONGO_ROOT -PLUGIN_SERVICE="MongoDB" -PLUGIN_IMAGE=$MONGO_IMAGE -PLUGIN_IMAGE_VERSION=$MONGO_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 ce48195..3fbdd9d 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 25569f8..5dd2dae 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/mongo output="" for i in $PLUGIN_DATA_ROOT/*; do diff --git a/functions b/functions index d67d5e2..f73ea8d 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/mongo -PLUGIN_SERVICE="MongoDB" +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 "MONGO" + echo "$PLUGIN_DEFAULT_ALIAS" fi } @@ -49,5 +47,5 @@ service_url() { local ID="$(cat "$SERVICE_ROOT/ID")" local IP="$(get_container_ip "$ID")" - echo "mongodb://$IP:27017" + echo "$PLUGIN_SCHEME://$IP:$PLUGIN_DATASTORE_PORT" } diff --git a/install b/install index f6a3ff4..91a71d1 100755 --- a/install +++ b/install @@ -1,14 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x - -MONGO_IMAGE="mongo" -MONGO_IMAGE_VERSION=3.1.6 -MONGO_ROOT=/var/lib/dokku/services/mongo - -PLUGIN_DATA_ROOT=$MONGO_ROOT -PLUGIN_SERVICE="Memcached" -PLUGIN_IMAGE=$MONGO_IMAGE -PLUGIN_IMAGE_VERSION=$MONGO_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