Skip to content

Commit ea82c76

Browse files
VIA-653 AJ update s3-version-viewer.sh to work for all vaccines
1 parent 4cec2b0 commit ea82c76

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

scripts/content/s3-version-viewer.sh

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
set -euo pipefail
33

44
# --- Argument Parsing ---
5-
if [[ $# -ne 2 ]]; then
6-
echo "Usage: $0 <aws_account_id> <aws_profile_name>"
7-
echo "Example: $0 825765425922 vita-preprod"
5+
if [[ $# -ne 3 ]]; then
6+
echo "Usage: $0 <aws_account_id> <aws_profile_name> <vaccine-json-file-name>"
7+
echo "Example: $0 825765425922 vita-preprod hpv-vaccine.json"
88
exit 1
99
fi
1010

1111
aws_account="$1"
1212
profile="$2"
13+
object="$3"
1314

1415
bucket="gh-vita-$aws_account-content-cache"
15-
object="rsv-vaccine.json"
1616

1717
CONFIG_FILE="/tmp/s3_viewer.conf"
1818
trap 'rm -f "$CONFIG_FILE"' EXIT
@@ -21,18 +21,19 @@ echo "PROFILE_NAME=\"$profile\"" >> "$CONFIG_FILE"
2121
echo "OBJECT_KEY=\"$object\"" >> "$CONFIG_FILE"
2222

2323
VERSION_LIST=$(aws s3api list-object-versions --bucket "$bucket" --prefix "$object" --profile "$profile" | \
24-
jq -r '.Versions[] | "\(.IsLatest | tostring)\t\(.LastModified)\t\(.VersionId)"')
24+
jq -r '.Versions[] | "\(.IsLatest | tostring)\t\(.Size)\t\(.LastModified)\t\(.VersionId)"')
2525

2626
CHOSEN_LINE=$(echo -e "$VERSION_LIST" | fzf --header="Select a version (live preview on the right)" \
2727
--preview-window="right:60%:wrap" \
28-
--preview='scripts/content/preview.sh {3}')
28+
--preview='scripts/content/preview.sh {4}')
2929

3030
if [[ -z "$CHOSEN_LINE" ]]; then
3131
echo "No version selected. Exiting."
3232
exit 0
3333
fi
3434

35-
chosen_version_id=$(echo "$CHOSEN_LINE" | awk '{print $3}')
35+
chosen_version_id=$(echo "$CHOSEN_LINE" | awk '{print $4}')
36+
updated_timestamp=$(echo "$CHOSEN_LINE" | awk '{print $3}')
3637

3738
DOWNLOAD_TMP_FILE=$(mktemp)
3839
trap 'rm -f "$DOWNLOAD_TMP_FILE"' EXIT
@@ -44,4 +45,6 @@ aws s3api get-object \
4445
--profile "$profile" \
4546
"$DOWNLOAD_TMP_FILE" > /dev/null
4647

47-
cat "$DOWNLOAD_TMP_FILE" | jq . > before.temp.json
48+
output_file_name="$updated_timestamp.$chosen_version_id.json"
49+
cat "$DOWNLOAD_TMP_FILE" | jq . > "$output_file_name"
50+
echo "Wrote $3 => $output_file_name"

0 commit comments

Comments
 (0)