From 5736336276ccddf3193b5ab265c3ce06254ea51a Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 29 Aug 2015 01:52:55 -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 e0080ab..ce63a48 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" - -REDIS_IMAGE=${REDIS_IMAGE:="redis"} -REDIS_IMAGE_VERSION=${REDIS_IMAGE_VERSION:="3.0.3"} -REDIS_ROOT=/var/lib/dokku/services/redis - -PLUGIN_COMMAND_PREFIX="redis" -PLUGIN_DATA_ROOT=$REDIS_ROOT -PLUGIN_SERVICE="Redis" -PLUGIN_IMAGE=$REDIS_IMAGE -PLUGIN_IMAGE_VERSION=$REDIS_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 f7429a8..4df3e70 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 64d905a..9cf22af 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/redis output="" for i in $PLUGIN_DATA_ROOT/*; do diff --git a/functions b/functions index f0fc528..adb70d4 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/redis -PLUGIN_SERVICE="Redis" +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 "REDIS" + echo "$PLUGIN_DEFAULT_ALIAS" fi } @@ -49,5 +47,5 @@ service_url() { local ID="$(cat "$SERVICE_ROOT/ID")" local IP="$(get_container_ip "$ID")" - echo "redis://$IP:6379/0" + echo "$PLUGIN_SCHEME://$IP:$PLUGIN_DATASTORE_PORT/0" } diff --git a/install b/install index 4ac7c38..91a71d1 100755 --- a/install +++ b/install @@ -1,14 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x - -REDIS_IMAGE="redis" -REDIS_IMAGE_VERSION=3.0.3 -REDIS_ROOT=/var/lib/dokku/services/redis - -PLUGIN_DATA_ROOT=$REDIS_ROOT -PLUGIN_SERVICE="Redis" -PLUGIN_IMAGE=$REDIS_IMAGE -PLUGIN_IMAGE_VERSION=$REDIS_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