From a4f3fc5ce21d76703011e8c332719dcdada4d2c1 Mon Sep 17 00:00:00 2001 From: 3wc <3wc.git@doesthisthing.work> Date: Sun, 30 May 2021 00:18:24 +0200 Subject: [PATCH] Bad YAML = showstopper Fixes #154 --- CHANGELOG.md | 1 + abra | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c105638..da68e2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - Fix secret length generation ([f537417](https://git.autonomic.zone/coop-cloud/abra/commit/1b85bf3d37280e9632c315d759c0f2d09c039fef)) - Fix checking out new apps ([#164](https://git.autonomic.zone/coop-cloud/abra/issues/164) +- Give up if YAML is invalid ([#154](https://git.autonomic.zone/coop-cloud/abra/issues/154)) # abra 0.7.4 (2021-05-10) diff --git a/abra b/abra index 3d56bb8..78d4ec6 100755 --- a/abra +++ b/abra @@ -478,6 +478,16 @@ require_docker_version() { done } +require_valid_json() { + require_jq + $JQ "$1" > /dev/null || error "Invalid JSON '$1'" +} + +require_valid_yaml() { + require_yq + $YQ e "$1" > /dev/null || error "Invalid YAML '$1'" +} + ###### Download and update data require_apps_json() { @@ -702,6 +712,7 @@ output_version_summary() { IFS=':' read -ra COMPOSE_FILES <<< "$COMPOSE_FILE" for COMPOSE in "${COMPOSE_FILES[@]}"; do + require_valid_yaml "$APP_DIR/$COMPOSE" SERVICES=$($YQ e '.services | keys | .[]' "${APP_DIR}/${COMPOSE}") for SERVICE in $SERVICES; do