Previously we were exporting `REDIS_URL` via the docker-args* hooks. This seems to confuse our users (since the env var is not displayed when calling `dokku config`) and in some cases it also seems that the env var is not correctly set. Another problem is if several services are linked to the same app and if they are exporting `REDIS_URL` as well. Then we don’t know what will be set. To resolve theses issues, this patch changes the way we manage the env vars. We use standard dokku commands (`config` and `docker-options`) so config is set on the linked application and can be reviewed by the user easily. We also handle the case where `REDIS_URL` is already set on the linked application. When it’s the case, we automatically generate another env var based on the following pattern: DOKKU_<service name>_<random unused color>_URL. For example, this can give: DOKKU_REDIS_BLACK_URL. Since naming is now handled automatically, the `alias` command has been removed. If the user wants to set a different env var on her app, it’s just a matter of using `dokku config:set` and pasting the wanted value. IP in DSN has been removed in favor of host name exported by docker in the container. This is more robust and simpler since the IP can change but the name will remain the same if the service container restarts for instance. With all those changes, a new command has been introduced: `promote`. The goal of this command is to easily set a service as the primary one when several are linked to an app. (see README for an example)
65 lines
1.5 KiB
Bash
65 lines
1.5 KiB
Bash
#!/usr/bin/env bash
|
|
export DOKKU_QUIET_OUTPUT=1
|
|
export DOKKU_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/dokku"
|
|
export DOKKU_VERSION=${DOKKU_VERSION:-"master"}
|
|
export PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/bin:$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/dokku:$PATH"
|
|
export PLUGIN_COMMAND_PREFIX="redis"
|
|
export PLUGIN_PATH="$DOKKU_ROOT/plugins"
|
|
export PLUGIN_ENABLED_PATH="$PLUGIN_PATH"
|
|
export PLUGIN_AVAILABLE_PATH="$PLUGIN_PATH"
|
|
export PLUGIN_CORE_AVAILABLE_PATH="$PLUGIN_PATH"
|
|
export REDIS_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/fixtures"
|
|
export PLUGIN_DATA_ROOT="$REDIS_ROOT"
|
|
export PLUGN_URL="https://github.com/progrium/plugn/releases/download/v0.1.0/plugn_0.1.0_linux_x86_64.tgz"
|
|
|
|
mkdir -p "$PLUGIN_DATA_ROOT"
|
|
rm -rf "${PLUGIN_DATA_ROOT:?}"/*
|
|
|
|
flunk() {
|
|
{ if [ "$#" -eq 0 ]; then cat -
|
|
else echo "$*"
|
|
fi
|
|
}
|
|
return 1
|
|
}
|
|
|
|
assert_equal() {
|
|
if [ "$1" != "$2" ]; then
|
|
{ echo "expected: $1"
|
|
echo "actual: $2"
|
|
} | flunk
|
|
fi
|
|
}
|
|
|
|
assert_exit_status() {
|
|
assert_equal "$status" "$1"
|
|
}
|
|
|
|
assert_success() {
|
|
if [ "$status" -ne 0 ]; then
|
|
flunk "command failed with exit status $status"
|
|
elif [ "$#" -gt 0 ]; then
|
|
assert_output "$1"
|
|
fi
|
|
}
|
|
|
|
assert_exists() {
|
|
if [ ! -f "$1" ]; then
|
|
flunk "expected file to exist: $1"
|
|
fi
|
|
}
|
|
|
|
assert_contains() {
|
|
if [[ "$1" != *"$2"* ]]; then
|
|
flunk "expected $2 to be in: $1"
|
|
fi
|
|
}
|
|
|
|
assert_output() {
|
|
local expected
|
|
if [ $# -eq 0 ]; then expected="$(cat -)"
|
|
else expected="$1"
|
|
fi
|
|
assert_equal "$expected" "$output"
|
|
}
|