Skip to content

Commit 5163311

Browse files
committed
Add trap for temp file cleanup and fix Go version
- Add EXIT trap to ensure password file cleanup even on initdb failure - Update Go version from invalid 1.24.11 to 1.23 in workflows - Ensure consistent Go version across all CI workflows
1 parent 587f796 commit 5163311

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

.github/workflows/pr_test_latest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ jobs:
114114
- name: Set up Go
115115
uses: actions/setup-go@v5
116116
with:
117-
go-version: '1.24.11'
117+
go-version: '1.23'
118118
cache-dependency-path: tests/go.sum
119119

120120
- name: Pull image

.github/workflows/test_images.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ jobs:
9999
- name: Set up Go
100100
uses: actions/setup-go@v5
101101
with:
102-
go-version: '1.24.11'
102+
go-version: '1.23'
103103
cache-dependency-path: tests/go.sum
104104

105105
- name: Pull image

docker-entrypoint.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ docker_init_database_dir() {
117117
# Create a temporary password file to avoid command injection via POSTGRES_INITDB_ARGS
118118
local pwfile
119119
pwfile="$(mktemp)"
120+
# Ensure cleanup on exit (including errors) to prevent password file from being left on disk
121+
trap 'rm -f "$pwfile"' EXIT
120122
printf '%s\n' "$POSTGRES_PASSWORD" > "$pwfile"
121123

122124
# Build initdb command arguments safely using an array
@@ -143,8 +145,10 @@ docker_init_database_dir() {
143145
# Execute initdb with the safely constructed arguments
144146
initdb "${initdb_args[@]}"
145147

146-
# Clean up temporary password file
148+
# Clean up temporary password file (trap will also handle this on exit, but explicit cleanup is good)
147149
rm -f "$pwfile"
150+
# Remove the trap since we've cleaned up manually
151+
trap - EXIT
148152

149153
# unset/cleanup "nss_wrapper" bits
150154
if [[ "${LD_PRELOAD:-}" == */libnss_wrapper.so ]]; then

tests/tests

9.9 MB
Binary file not shown.

0 commit comments

Comments
 (0)