Skip to content

Commit 7a1651b

Browse files
committed
correct the DB name resolution in the cncluster psql command
[static] Signed-off-by: Mateusz Błażejewski <mateusz.blazejewski@digitalasset.com>
1 parent b3f8ac9 commit 7a1651b

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

build-tools/cncluster

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2205,8 +2205,7 @@ function subcmd_psql() {
22052205
exit 1
22062206
fi
22072207

2208-
# shellcheck disable=SC2086
2209-
set -- $DB_INIT_COMMAND
2208+
eval "set -- $DB_INIT_COMMAND"
22102209
while [ $# -gt 0 ]; do
22112210
case "$1" in
22122211
-h|--host)
@@ -2233,12 +2232,12 @@ function subcmd_psql() {
22332232
local DB_USERNAME="${1#*=}"
22342233
shift
22352234
;;
2236-
-d|--dbname)
2237-
local DB_NAME="$2"
2235+
-c|--command)
2236+
local DB_CREATE_STATEMENT="$2"
22382237
shift 2
22392238
;;
2240-
-d=*|--dbname=*)
2241-
local DB_NAME="${1#*=}"
2239+
-c=*|--command=*)
2240+
local DB_CREATE_STATEMENT="${1#*=}"
22422241
shift
22432242
;;
22442243
*)
@@ -2262,7 +2261,11 @@ function subcmd_psql() {
22622261
exit 1
22632262
fi
22642263

2265-
if [ -z "${DB_NAME:-}" ]; then
2264+
# shellcheck disable=SC2086
2265+
set -- $DB_CREATE_STATEMENT
2266+
if [ "${1,,}" == "create" ] && [ "${2,,}" == "database" ] && [ -n "$3" ]; then
2267+
DB_NAME="$3"
2268+
else
22662269
_error "Failed to retrieve DB name from pod description."
22672270
exit 1
22682271
fi

0 commit comments

Comments
 (0)