From dbe025909c91286063b2b2511fd1a334cb1e7a22 Mon Sep 17 00:00:00 2001 From: Lawrence Date: Tue, 19 Nov 2024 11:03:14 +0000 Subject: [PATCH] fix: argument expansion in bash wrapper --- graphviz/buildpack.toml | 2 +- graphviz/wrapper.sh | 2 +- psql/Makefile | 2 +- psql/buildpack.toml | 2 +- psql/fixtures/bash/docker-compose.yml | 13 +++++++++++++ psql/fixtures/bash/test.sh | 10 ++++++++++ psql/wrapper.sh | 2 +- 7 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 psql/fixtures/bash/docker-compose.yml diff --git a/graphviz/buildpack.toml b/graphviz/buildpack.toml index 892d831..a868d51 100644 --- a/graphviz/buildpack.toml +++ b/graphviz/buildpack.toml @@ -3,7 +3,7 @@ api = "0.8" [buildpack] id = "acodeninja/graphviz" name = "ACodeNinja Buildpack for Graphviz" - version = "1.0.0" + version = "1.0.1" homepage = "https://github.com/acodeninja/buildpacks/graphviz" [[buildpack.licenses]] diff --git a/graphviz/wrapper.sh b/graphviz/wrapper.sh index 5fd3d0c..576e32e 100644 --- a/graphviz/wrapper.sh +++ b/graphviz/wrapper.sh @@ -5,4 +5,4 @@ LD_LIBRARY_PATH="{{range $val := .LibLocations}}{{$val}}:{{end}}$LD_LIBRARY_PATH LIBRARY_PATH="{{range $val := .LibLocations}}{{$val}}:{{end}}$LD_LIBRARY_PATH" \ FONTCONFIG_PATH="{{.FontConfigLocation}}" \ GVBINDIR="{{.GraphvizBinDir}}" \ -{{.Command}} $@ +{{.Command}} "$@" diff --git a/psql/Makefile b/psql/Makefile index 1a2df25..73d23fc 100644 --- a/psql/Makefile +++ b/psql/Makefile @@ -13,4 +13,4 @@ test: test-bash .PHONY: test-bash test-bash: package @cd fixtures/bash && pack build --clear-cache test-psql-bash - @docker run --rm --platform linux/amd64 --entrypoint test test-psql-bash + @cd fixtures/bash && docker-compose up --abort-on-container-exit diff --git a/psql/buildpack.toml b/psql/buildpack.toml index 5b2313a..958cdd5 100644 --- a/psql/buildpack.toml +++ b/psql/buildpack.toml @@ -3,7 +3,7 @@ api = "0.8" [buildpack] id = "acodeninja/psql" name = "ACodeNinja Buildpack for PostgreSQL client" - version = "1.1.1" + version = "1.1.2" homepage = "https://github.com/acodeninja/buildpacks/tree/main/psql" [[buildpack.licenses]] diff --git a/psql/fixtures/bash/docker-compose.yml b/psql/fixtures/bash/docker-compose.yml new file mode 100644 index 0000000..d814029 --- /dev/null +++ b/psql/fixtures/bash/docker-compose.yml @@ -0,0 +1,13 @@ +services: + app: + image: test-psql-bash + entrypoint: test + environment: + DATABASE_URL: postgresql://postgres:example@database:5432/postgres + links: + - database + + database: + image: postgres:latest + environment: + POSTGRES_PASSWORD: example diff --git a/psql/fixtures/bash/test.sh b/psql/fixtures/bash/test.sh index 2b03d6b..db250b7 100644 --- a/psql/fixtures/bash/test.sh +++ b/psql/fixtures/bash/test.sh @@ -34,6 +34,16 @@ for COMMAND_TO_TEST in $COMMANDS_TO_TEST; do run_test "$COMMAND_TO_TEST server" "$COMMAND_TO_TEST --version" "PostgreSQL" done +QUERY_OUTPUT="$(psql "$DATABASE_URL" -c "SELECT datname FROM pg_database;")" + +if [[ "$QUERY_OUTPUT" =~ "template1" ]]; then + echo "[psql][run query]: passed 🟢" +else + echo "[psql][run query]: failed 🔴" + diff <(echo "$QUERY_OUTPUT" ) <(echo "$QUERY_EXPECTED") + TESTS_FAILED="yes" +fi + if [[ -z "$TESTS_FAILED" ]] then exit 0 diff --git a/psql/wrapper.sh b/psql/wrapper.sh index a0942b4..5d5a2a9 100644 --- a/psql/wrapper.sh +++ b/psql/wrapper.sh @@ -5,4 +5,4 @@ PATH="{{.PostgresClientPath}}:$PATH" LD_LIBRARY_PATH="{{range $val := .LibLocations}}{{$val}}:{{end}}$LD_LIBRARY_PATH" LIBRARY_PATH="{{range $val := .LibLocations}}{{$val}}:{{end}}$LD_LIBRARY_PATH" -{{.PostgresCommand}} $@ +{{.PostgresCommand}} "$@"