feat: implement exists and linked subcommands

This commit is contained in:
Jose Diaz-Gonzalez
2018-02-25 15:41:27 -05:00
parent 2e79f89912
commit 5b03672708
7 changed files with 73 additions and 6 deletions

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_AVAILABLE_PATH/config/functions"
docker_ports_options() {
declare desc="Exports a list of exposed ports"
@@ -288,6 +289,20 @@ service_info() {
fi
}
service_is_linked() {
declare desc="Links a service to an application"
declare SERVICE="$1" APP="$2"
update_plugin_scheme_for_app "$APP"
local SERVICE_URL=$(service_url "$SERVICE")
local EXISTING_CONFIG=$(config_all "$APP")
local LINK=$(echo "$EXISTING_CONFIG" | grep "$SERVICE_URL" | cut -d: -f1) || true
if [[ -z $LINK ]]; then
dokku_log_warn "Service $SERVICE is not linked to $APP"
exit 1
fi
dokku_log_info1 "Service $SERVICE is linked to $APP"
}
service_link() {
declare desc="Links a service to an application"
declare SERVICE="$1" APP="$2"