Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPE-1122 adding logic to exit a gitops sync if the new json contains invalid json #2377

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this update will make sure it fails if any part of the manifest is invalid json, not just the "versions" section, if that's the case could you update the PR description

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes! Thanks so much Pauline :D Just updated the description

# 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
Loading