From b554ee8c1a4e60c5d859ffdaf08e957aa558779c Mon Sep 17 00:00:00 2001 From: EliseCastle23 Date: Thu, 5 Oct 2023 15:03:49 -0600 Subject: [PATCH] adding logic to exit a gitops sync if the new json contains invalid json --- gen3/bin/gitops.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gen3/bin/gitops.sh b/gen3/bin/gitops.sh index 48ba6512c..fda6d4ffa 100644 --- a/gen3/bin/gitops.sh +++ b/gen3/bin/gitops.sh @@ -291,9 +291,15 @@ gen3_gitops_sync() { if g3kubectl get configmap manifest-versions; then oldJson=$(g3kubectl get configmap manifest-versions -o=json | jq ".data") fi - newJson=$(g3k_config_lookup ".versions") echo "old JSON is: $oldJson" - echo "new JSON is: $newJson" + newJson=$(g3k_config_lookup ".versions") + # Make sure the script exits if newJSON contains invalid JSON + if [ $? -ne 0 ]; then + echo "Error: g3k_config_lookup command failed- invalid JSON" + exit 1 + else + echo "new JSON is: $newJson" + fi if [[ -z $newJson ]]; then echo "Manifest does not have versions section. Unable to get new versions, skipping version update." elif [[ -z $oldJson ]]; then