Handle undeployed state for version output summary

Closes #104.
This commit is contained in:
decentral1se 2021-03-18 17:20:31 +01:00
parent 54b6acc46c
commit 6e61c08b2c
Signed by: decentral1se
GPG Key ID: 92DAD76BD9567B8A
1 changed files with 14 additions and 3 deletions

17
abra
View File

@ -507,8 +507,13 @@ output_version_summary() {
local -a IS_AN_UPDATE="false"
local -a UNABLE_TO_DETECT="false"
local -a UNDEPLOYED_STATE="false"
local -a CHECKED_SERVICES # array
if ! docker stack ls --format "{{ .Name }}" | grep -q "$STACK_NAME"; then
UNDEPLOYED_STATE="true"
fi
IFS=':' read -ra COMPOSE_FILES <<< "$COMPOSE_FILE"
for COMPOSE in "${COMPOSE_FILES[@]}"; do
SERVICES=$($YQ e '.services | keys | .[]' "${APP_DIR}/${COMPOSE}")
@ -541,8 +546,14 @@ output_version_summary() {
echo " to de deployed: $(tput setaf 1)$app_version ($app_digest)$(tput sgr0)"
fi
else
warning "Unable to detect deployed version of ${STACK_NAME}_${SERVICE}, please proceed with caution"
UNABLE_TO_DETECT="true"
if [[ $UNDEPLOYED_STATE == "true" ]]; then
image=$($YQ e ".services.${SERVICE}.image" "${APP_DIR}/${COMPOSE}" | cut -d':' -f1)
echo " ${STACK_NAME}_${SERVICE} (${image}):"
echo " undeployed!"
else
warning "Unable to detect deployed version of ${STACK_NAME}_${SERVICE}, please proceed with caution"
UNABLE_TO_DETECT="true"
fi
fi
CHECKED_SERVICES+=("$SERVICE")
done
@ -551,7 +562,7 @@ output_version_summary() {
if [[ $IS_AN_UPDATE == "true" ]] && [[ $FORCE_DEPLOY != "true" ]]; then
require_consent_for_update
else
if [[ ! $UNABLE_TO_DETECT == "true" ]] && [[ $FORCE_DEPLOY != "true" ]]; then
if [[ ! $UNABLE_TO_DETECT == "true" ]] && [[ $FORCE_DEPLOY != "true" ]] && [[ ! $UNDEPLOYED_STATE == "true" ]]; then
success "Nothing to deploy, you're on latest (use --force to re-deploy anyway)"
exit 0
fi