Read POSTGRES_DATABASE_SCHEME variable from app when setting DATABASE_URL

This commit is contained in:
Jose Diaz-Gonzalez
2016-04-19 14:35:16 -04:00
parent 3b3bd95e68
commit 23d10ad09c
4 changed files with 53 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$(dirname "$0")/config"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
get_random_ports() {
local iterations="${1:-1}"
@@ -70,6 +71,7 @@ service_exposed_ports() {
service_link() {
local APP="$2"
local SERVICE="$1"
update_plugin_scheme_for_app "$APP"
local SERVICE_URL=$(service_url "$SERVICE")
local SERVICE_NAME=$(get_service_name "$SERVICE")
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
@@ -253,6 +255,7 @@ service_stop() {
service_unlink() {
local APP="$2"
local SERVICE="$1"
update_plugin_scheme_for_app "$APP"
local SERVICE_URL=$(service_url "$SERVICE")
local SERVICE_NAME=$(get_service_name "$SERVICE")
local EXISTING_CONFIG=$(dokku config "$APP")
@@ -316,6 +319,7 @@ promote() {
local APP="$2"
local PLUGIN_DEFAULT_CONFIG_VAR="${PLUGIN_DEFAULT_ALIAS}_URL"
local EXISTING_CONFIG=$(dokku config "$APP")
update_plugin_scheme_for_app "$APP"
local SERVICE_URL=$(service_url "$SERVICE")
local CONFIG_VARS=($(echo "$EXISTING_CONFIG" | grep "$SERVICE_URL" | cut -d: -f1)) || true
local PREVIOUS_DEFAULT_URL=$(get_url_from_config "$EXISTING_CONFIG" "$PLUGIN_DEFAULT_CONFIG_VAR")
@@ -357,3 +361,9 @@ service_linked_apps() {
tr '\n' ' ' < "$LINKS_FILE"
}
update_plugin_scheme_for_app() {
local APP=$1
local POSTGRES_DATABASE_SCHEME=$(config_get $APP POSTGRES_DATABASE_SCHEME)
PLUGIN_SCHEME=${POSTGRES_DATABASE_SCHEME:-$PLUGIN_SCHEME}
}