Skip to content

Commit

Permalink
adding logic to exit a gitops sync if the new json contains invalid json
Browse files Browse the repository at this point in the history
  • Loading branch information
EliseCastle23 committed Oct 5, 2023
1 parent 220788e commit b554ee8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions gen3/bin/gitops.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b554ee8

Please sign in to comment.