Revamp link/unlink commands
Previously we were exporting `DATABASE_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 `DATABASE_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 `DATABASE_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_POSTGRES_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)
This commit is contained in:
17
commands
17
commands
@@ -16,13 +16,6 @@ if [[ $1 == $PLUGIN_COMMAND_PREFIX:* ]]; then
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
$PLUGIN_COMMAND_PREFIX:alias)
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify a name for the service"
|
||||
[[ -z $3 ]] && dokku_log_fail "Please specify an alias for the service"
|
||||
verify_service_name "$2"
|
||||
service_set_alias "$2" "$3"
|
||||
;;
|
||||
|
||||
$PLUGIN_COMMAND_PREFIX:create)
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify a name for the service"
|
||||
[[ ! -d "$PLUGIN_DATA_ROOT/$2" ]] || dokku_log_fail "$PLUGIN_SERVICE service $2 already exists"
|
||||
@@ -206,9 +199,16 @@ case "$1" in
|
||||
service_port_unexpose "$2"
|
||||
;;
|
||||
|
||||
$PLUGIN_COMMAND_PREFIX:promote)
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify a name for the service"
|
||||
[[ -z $3 ]] && dokku_log_fail "Please specify an app to run the command on"
|
||||
verify_service_name "$2"
|
||||
verify_app_name "$3"
|
||||
promote "$2" "$3"
|
||||
;;
|
||||
|
||||
help | $PLUGIN_COMMAND_PREFIX:help)
|
||||
HELP=$(cat<<EOF
|
||||
$PLUGIN_COMMAND_PREFIX:alias <name> <alias>, Set an alias for the docker link
|
||||
$PLUGIN_COMMAND_PREFIX:create <name>, Create a $PLUGIN_SERVICE service
|
||||
$PLUGIN_COMMAND_PREFIX:destroy <name>, Delete the $PLUGIN_SERVICE service and stop its container if there are no links left
|
||||
$PLUGIN_COMMAND_PREFIX:link <name> <app>, Link the $PLUGIN_SERVICE service to the app
|
||||
@@ -225,6 +225,7 @@ case "$1" in
|
||||
$PLUGIN_COMMAND_PREFIX:unexpose <name>, Unexpose a previously exposed $PLUGIN_SERVICE service
|
||||
$PLUGIN_COMMAND_PREFIX:start <name>, Start a previously stopped $PLUGIN_SERVICE service
|
||||
$PLUGIN_COMMAND_PREFIX:stop <name>, Stop a running $PLUGIN_SERVICE service
|
||||
$PLUGIN_COMMAND_PREFIX:promote <name> <app>, Promote service <name> as ${PLUGIN_DEFAULT_ALIAS}_URL in <app>
|
||||
EOF
|
||||
)
|
||||
if [[ -n $DOKKU_API_VERSION ]]; then
|
||||
|
||||
Reference in New Issue
Block a user