Implement edge-case handling for versioning

This commit is contained in:
decentral1se 2021-03-16 06:19:37 +01:00
parent d6caf03301
commit 79dacf557e
Signed by untrusted user who does not match committer: decentral1se
GPG Key ID: 92DAD76BD9567B8A

27
abra
View File

@ -419,6 +419,12 @@ require_vendor_dir() {
mkdir -p "$ABRA_VENDOR_DIR" mkdir -p "$ABRA_VENDOR_DIR"
} }
require_consent_for_update() {
if [ "$CONSENT_TO_UPDATE" = "false" ]; then
error "A new app state will be deployed! Please use --update to consent"
fi
}
require_app_latest() { require_app_latest() {
APP="$1" APP="$1"
APP_DIR="$ABRA_DIR/apps/$APP" APP_DIR="$ABRA_DIR/apps/$APP"
@ -496,6 +502,9 @@ load_abra_sh() {
output_version_summary() { output_version_summary() {
echo " Versions:" echo " Versions:"
CONSENT_TO_UPDATE=$abra___update
IS_AN_UPDATE="false"
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}")
@ -517,10 +526,24 @@ output_version_summary() {
app_version=${!app_version_lookup} app_version=${!app_version_lookup}
app_digest_lookup="ABRA_TYPE_${SERVICE^^}_DIGEST" app_digest_lookup="ABRA_TYPE_${SERVICE^^}_DIGEST"
app_digest=${!app_digest_lookup} app_digest=${!app_digest_lookup}
echo " to de deployed: $(tput setaf 3)$app_version ($app_digest)$(tput sgr0)"
if [ "$live_version" != "$app_version" ] || [ "$live_digest" != "$app_digest" ]; then
IS_AN_UPDATE="true"
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"
fi fi
done done
done done
if [[ $IS_AN_UPDATE == "true" ]]; then
require_consent_for_update
else
success "Nothing to deploy, you're on latest"
exit 0
fi
} }
###### FIXME 3wc: name this section ###### FIXME 3wc: name this section
@ -1745,7 +1768,7 @@ abra() {
abra__subcommands_ abra___skip_update abra___skip_check \ abra__subcommands_ abra___skip_update abra___skip_check \
abra__backup_file_ abra___verbose abra___debug abra___help \ abra__backup_file_ abra___verbose abra___debug abra___help \
abra___branch abra___volumes abra__provider_ abra___type \ abra___branch abra___volumes abra__provider_ abra___type \
abra___dev abra___dev abra___update
if ! type tput > /dev/null 2>&1; then if ! type tput > /dev/null 2>&1; then
tput() { tput() {