Normalize database names in postgres. Closes #2

This commit is contained in:
Jose Diaz-Gonzalez
2015-09-07 01:49:28 -04:00
parent 316fe8f7f0
commit ad4fae1b2a
2 changed files with 12 additions and 3 deletions

View File

@@ -246,7 +246,8 @@ service_url() {
local ID="$(cat "$SERVICE_ROOT/ID")"
local IP="$(get_container_ip "$ID")"
local PASSWORD="$(cat "$SERVICE_ROOT/PASSWORD")"
echo "$PLUGIN_SCHEME://postgres:$PASSWORD@$IP:${PLUGIN_DATASTORE_PORTS[0]}/$SERVICE"
local DATABASE_NAME="$(get_database_name $SERVICE)"
echo "$PLUGIN_SCHEME://postgres:$PASSWORD@$IP:${PLUGIN_DATASTORE_PORTS[0]}/$DATABASE_NAME"
}
is_container_status () {
@@ -265,3 +266,9 @@ get_service_name() {
local SERVICE="$1"
echo "dokku.${PLUGIN_COMMAND_PREFIX}.$SERVICE"
}
get_database_name() {
# postgres does not like special characters in database names
# so we need to normalize them out
echo "$1" | tr .- _
}