From e99bedf9e4b46f73b67a22d46998d5dc60c2af74 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Mon, 15 Mar 2021 18:30:37 +0100 Subject: [PATCH] WIP version output summary which handles services See https://git.autonomic.zone/coop-cloud/organising/issues/47. --- abra | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/abra b/abra index af758c8..b6b41fb 100755 --- a/abra +++ b/abra @@ -461,6 +461,29 @@ load_abra_sh() { fi } +output_version_summary() { + echo " Versions:" + IFS=':' read -ra COMPOSE_FILES <<< "$COMPOSE_FILE" + for COMPOSE in "${COMPOSE_FILES[@]}"; do + SERVICES=$(yq e '.services | keys | .[]' "${APP_DIR}/${COMPOSE_FILE}") + for SERVICE in $SERVICES; do + filter="{{index .Spec.Labels \"coop-cloud.gitea.$SERVICE.version\" }}" + label=$(docker service inspect -f "$filter" "gitea_$SERVICE" 2>/dev/null) + live_version=$(echo "$label" | cut -d- -f1) + live_digest=$(echo "$label" | cut -d- -f2) + if [ -n "$live_version" ] && [ -n "$live_digest" ]; then + echo " ${STACK_NAME}_${SERVICE}:" + echo " deployed: $(tput setaf 2)$live_version ($live_digest)$(tput sgr0)" + app_version_lookup="ABRA_TYPE_${SERVICE^^}_VERSION" + app_version=${!app_version_lookup} + app_digest_lookup="ABRA_TYPE_${SERVICE^^}_DIGEST" + app_digest=${!app_digest_lookup} + echo " to de deployed: $(tput setaf 3)$app_version ($app_digest)$(tput sgr0)" + fi + done + done +} + ###### FIXME 3wc: name this section get_servers() { @@ -933,6 +956,8 @@ sub_app_deploy (){ echo " Stack: $(tput setaf 1)${STACK_NAME}$(tput sgr0)" + output_version_summary + prompt_confirm APP=$(basename "$APP_DIR")