From 4e808c6ff9c50692697de0f60e4e49151393e673 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 25 Feb 2021 16:05:24 -0500 Subject: [PATCH] refactor: use pre/post triggers for service-action naming This is a bit more clear as the links aren't always idempotent and may have errors - this allows users to reconcile at what point a link may have failed so that they can take further action. --- common-functions | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common-functions b/common-functions index 5b56933..7f0ea6b 100755 --- a/common-functions +++ b/common-functions @@ -453,6 +453,7 @@ service_link() { fi [[ -n $LINK ]] && dokku_log_fail "Already linked as $LINK" + plugn trigger service-action pre-link "$SERVICE" "$APP" touch "$LINKS_FILE" echo "$APP" >>"$LINKS_FILE" sort "$LINKS_FILE" -u -o "$LINKS_FILE" @@ -465,8 +466,9 @@ service_link() { dokku docker-options:add "$APP" build,deploy,run "--link $SERVICE_NAME:$SERVICE_DNS_HOSTNAME" fi [[ -n "$SERVICE_QUERYSTRING" ]] && SERVICE_URL="${SERVICE_URL}?${SERVICE_QUERYSTRING}" + plugn trigger service-action post-link "$SERVICE" "$APP" config_set "$APP" "${ALIAS}_URL=$SERVICE_URL" - plugn trigger service-action link "$SERVICE" "$APP" + plugn trigger service-action post-link-complete "$SERVICE" "$APP" } service_linked_apps() { @@ -772,6 +774,7 @@ service_unlink() { local SERVICE_DNS_HOSTNAME=$(service_dns_hostname "$SERVICE") local LINK=($(echo "$EXISTING_CONFIG" | grep "$SERVICE_URL" | cut -d: -f1)) || true + plugn trigger service-action pre-unlink "$SERVICE" "$APP" remove_from_links_file "$SERVICE" "$APP" if declare -f -F add_passed_docker_option >/dev/null; then @@ -783,8 +786,9 @@ service_unlink() { fi [[ -z ${LINK[*]} ]] && dokku_log_fail "Not linked to app $APP" + plugn trigger service-action post-unlink "$SERVICE" "$APP" config_unset "$APP" "${LINK[*]}" - plugn trigger service-action unlink "$SERVICE" "$APP" + plugn trigger service-action post-unlink-complete "$SERVICE" "$APP" } service_version() {