Skip to content

Commit ce53145

Browse files
committed
Clean up shellcheck disables
1 parent 1ef5afd commit ce53145

2 files changed

Lines changed: 5 additions & 26 deletions

File tree

src/pgweb/refresh-bookmarks.sh

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
2-
set -e
2+
set -o errexit
3+
set -o pipefail
34

45
# Allow overriding via environment for local testing
56
readonly WB_EXE="${WB_EXE:-/usr/bin/wb}"
@@ -20,17 +21,13 @@ generate_iam_token() {
2021

2122
# Get credentials from Workbench
2223
local wb_creds
23-
# shellcheck disable=SC2312
2424
wb_creds=$(${WB_EXE} resource credentials --id "${resource_id}" --scope "${scope}" --format json 2>/dev/null) || return 1
2525
readonly wb_creds
2626

2727
# Extract AWS credentials
2828
local access_key secret_key session_token
29-
# shellcheck disable=SC2312
3029
access_key=$(echo "${wb_creds}" | jq -r '.AccessKeyId')
31-
# shellcheck disable=SC2312
3230
secret_key=$(echo "${wb_creds}" | jq -r '.SecretAccessKey')
33-
# shellcheck disable=SC2312
3431
session_token=$(echo "${wb_creds}" | jq -r '.SessionToken')
3532
readonly access_key secret_key session_token
3633

@@ -65,7 +62,6 @@ EOF
6562
}
6663

6764
refresh_bookmarks() {
68-
# shellcheck disable=SC2312
6965
echo "$(date): Refreshing pgweb bookmarks from Workbench resources..."
7066

7167
# Create temporary directory for new bookmarks (using PID for uniqueness)
@@ -76,15 +72,12 @@ refresh_bookmarks() {
7672

7773
# Get list of Aurora databases from Workbench
7874
local RESOURCES
79-
# shellcheck disable=SC2312
8075
RESOURCES=$(${WB_EXE} resource list --format json)
8176
readonly RESOURCES
8277

8378
# Process each resource
84-
# shellcheck disable=SC2312
8579
echo "${RESOURCES}" | jq -c '.[]' | while read -r resource; do
8680
local RESOURCE_TYPE
87-
# shellcheck disable=SC2312
8881
RESOURCE_TYPE=$(echo "${resource}" | jq -r '.resourceType')
8982

9083
# Skip non-Aurora resources
@@ -93,7 +86,6 @@ refresh_bookmarks() {
9386
fi
9487

9588
local RESOURCE_ID
96-
# shellcheck disable=SC2312
9789
RESOURCE_ID=$(echo "${resource}" | jq -r '.id')
9890
echo " Processing: ${RESOURCE_ID} (type: ${RESOURCE_TYPE})"
9991

@@ -102,25 +94,17 @@ refresh_bookmarks() {
10294
if [[ "${RESOURCE_TYPE}" == "AWS_AURORA_DATABASE" ]]; then
10395
DB_DATA="${resource}"
10496
else
105-
# shellcheck disable=SC2312
10697
DB_DATA=$(echo "${resource}" | jq -r '.referencedResource')
10798
fi
10899

109100
# Extract database connection info
110101
local DB_NAME RO_ENDPOINT RO_USER RW_ENDPOINT RW_USER PORT REGION
111-
# shellcheck disable=SC2312
112102
DB_NAME=$(echo "${DB_DATA}" | jq -r '.databaseName')
113-
# shellcheck disable=SC2312
114103
RO_ENDPOINT=$(echo "${DB_DATA}" | jq -r '.roEndpoint')
115-
# shellcheck disable=SC2312
116104
RO_USER=$(echo "${DB_DATA}" | jq -r '.roUser')
117-
# shellcheck disable=SC2312
118105
RW_ENDPOINT=$(echo "${DB_DATA}" | jq -r '.rwEndpoint')
119-
# shellcheck disable=SC2312
120106
RW_USER=$(echo "${DB_DATA}" | jq -r '.rwUser')
121-
# shellcheck disable=SC2312
122107
PORT=$(echo "${DB_DATA}" | jq -r '.port')
123-
# shellcheck disable=SC2312
124108
REGION=$(echo "${DB_DATA}" | jq -r '.region // "us-east-1"')
125109

126110
# Validate all required fields are present
@@ -137,7 +121,6 @@ refresh_bookmarks() {
137121
# Try to create READ_ONLY bookmark
138122
echo " Checking read access..."
139123
local RO_TOKEN
140-
# shellcheck disable=SC2310,SC2311,SC2312
141124
if RO_TOKEN=$(generate_iam_token "${RESOURCE_ID}" "READ_ONLY" "${RO_ENDPOINT}" "${PORT}" "${RO_USER}" "${REGION}"); then
142125
echo " Read access confirmed"
143126
echo " Creating read-only bookmark..."
@@ -151,7 +134,6 @@ refresh_bookmarks() {
151134
# Try to create WRITE_READ bookmark
152135
echo " Checking write access..."
153136
local RW_TOKEN
154-
# shellcheck disable=SC2310,SC2311,SC2312
155137
if RW_TOKEN=$(generate_iam_token "${RESOURCE_ID}" "WRITE_READ" "${RW_ENDPOINT}" "${PORT}" "${RW_USER}" "${REGION}"); then
156138
echo " Write access confirmed"
157139
echo " Creating write-read bookmark..."
@@ -165,24 +147,19 @@ refresh_bookmarks() {
165147
# Count bookmarks - must use find since the while loop runs in a subshell (due to pipe),
166148
# so a counter variable incremented in the loop would not be visible here
167149
local BOOKMARK_COUNT
168-
# shellcheck disable=SC2312
169150
BOOKMARK_COUNT=$(find "${TEMP_DIR}" -name "*.toml" -type f 2>/dev/null | wc -l)
170151
readonly BOOKMARK_COUNT
171-
# shellcheck disable=SC2312
172152
echo "$(date): Refresh complete. Created ${BOOKMARK_COUNT} bookmarks."
173153

174154
# Atomically update symlink to point to new bookmark directory
175-
# shellcheck disable=SC2312
176155
ln -sfn "$(basename "${TEMP_DIR}")" "${BOOKMARK_DIR}"
177156

178157
# Cleanup old bookmark directories (all except current)
179158
find "${PGWEB_BASE}" -maxdepth 1 -type d -name "bookmarks.tmp.*" ! -name "bookmarks.tmp.$$" -exec rm -rf {} \;
180159
}
181160

182161
# Run single refresh
183-
# shellcheck disable=SC2310
184162
if ! refresh_bookmarks; then
185-
# shellcheck disable=SC2312
186163
echo "$(date): ERROR: Bookmark refresh failed"
187164
exit 1
188165
fi

src/pgweb/start-bookmark-refresh.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
2-
set -e
2+
set -o errexit
3+
set -o pipefail
34

45
echo "Starting bookmark refresh for pgweb..."
56

@@ -15,6 +16,7 @@ echo "Running initial bookmark refresh..."
1516

1617
# Start background loop for continuous refresh (detached from parent)
1718
echo "Starting background bookmark refresh service (every 10 minutes)..."
19+
# Single quotes intentional: $(date) should expand at runtime, not now
1820
# shellcheck disable=SC2016
1921
nohup bash -c '
2022
while true; do

0 commit comments

Comments
 (0)