Handle undeployed state for version output summary
Closes coop-cloud/abra#104.
This commit is contained in:
parent
54b6acc46c
commit
6e61c08b2c
13
abra
13
abra
@ -507,8 +507,13 @@ output_version_summary() {
|
|||||||
|
|
||||||
local -a IS_AN_UPDATE="false"
|
local -a IS_AN_UPDATE="false"
|
||||||
local -a UNABLE_TO_DETECT="false"
|
local -a UNABLE_TO_DETECT="false"
|
||||||
|
local -a UNDEPLOYED_STATE="false"
|
||||||
local -a CHECKED_SERVICES # array
|
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"
|
IFS=':' read -ra COMPOSE_FILES <<< "$COMPOSE_FILE"
|
||||||
for COMPOSE in "${COMPOSE_FILES[@]}"; do
|
for COMPOSE in "${COMPOSE_FILES[@]}"; do
|
||||||
SERVICES=$($YQ e '.services | keys | .[]' "${APP_DIR}/${COMPOSE}")
|
SERVICES=$($YQ e '.services | keys | .[]' "${APP_DIR}/${COMPOSE}")
|
||||||
@ -540,10 +545,16 @@ output_version_summary() {
|
|||||||
IS_AN_UPDATE="true"
|
IS_AN_UPDATE="true"
|
||||||
echo " to de deployed: $(tput setaf 1)$app_version ($app_digest)$(tput sgr0)"
|
echo " to de deployed: $(tput setaf 1)$app_version ($app_digest)$(tput sgr0)"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
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
|
else
|
||||||
warning "Unable to detect deployed version of ${STACK_NAME}_${SERVICE}, please proceed with caution"
|
warning "Unable to detect deployed version of ${STACK_NAME}_${SERVICE}, please proceed with caution"
|
||||||
UNABLE_TO_DETECT="true"
|
UNABLE_TO_DETECT="true"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
CHECKED_SERVICES+=("$SERVICE")
|
CHECKED_SERVICES+=("$SERVICE")
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
@ -551,7 +562,7 @@ output_version_summary() {
|
|||||||
if [[ $IS_AN_UPDATE == "true" ]] && [[ $FORCE_DEPLOY != "true" ]]; then
|
if [[ $IS_AN_UPDATE == "true" ]] && [[ $FORCE_DEPLOY != "true" ]]; then
|
||||||
require_consent_for_update
|
require_consent_for_update
|
||||||
else
|
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)"
|
success "Nothing to deploy, you're on latest (use --force to re-deploy anyway)"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user