Skip to content

Commit be7010b

Browse files
committed
infer the schema name for search_path in cncluster psql subcommand based on application name
[static] Signed-off-by: Mateusz Błażejewski <mateusz.blazejewski@digitalasset.com>
1 parent 7a1651b commit be7010b

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

build-tools/cncluster

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,7 @@ function subcmd_debug_shell() {
14581458
fi
14591459
repo="ghcr.io/digital-asset/decentralized-canton-sync-dev/docker"
14601460

1461-
local SHELL_COMMAND="${1:-/bin/bash}"
1461+
local SHELL_COMMAND="${*:-/bin/bash}"
14621462

14631463
_info "Deploying debug pod on version $VERSION_NUMBER"
14641464
kubectl apply --wait -f - <<EOF
@@ -2181,14 +2181,13 @@ subcommand_whitelist[psql]=""
21812181
function subcmd_psql() {
21822182
_cluster_must_exist
21832183

2184-
if [ $# -lt 2 ] || [ $# -gt 3 ]; then
2185-
_error "Usage: $SCRIPTNAME psql <namespace> <application> [search_path]"
2184+
if [ $# -ne 2 ]; then
2185+
_error "Usage: $SCRIPTNAME psql <namespace> <application>"
21862186
exit 1
21872187
fi
21882188

21892189
local NAMESPACE="$1"
21902190
local APPLICATION="$2"
2191-
local SEARCH_PATH=${3:-}
21922191

21932192
_info "Retrieving DB connection info from pod description..."
21942193
local DB_INIT_COMMAND
@@ -2297,16 +2296,29 @@ function subcmd_psql() {
22972296
exit 1
22982297
fi
22992298

2300-
subcmd_debug_shell " \
2301-
/bin/env
2302-
PGPASSWORD=$DB_PASSWORD \
2303-
${SEARCH_PATH:+PGOPTIONS=--search_path=$SEARCH_PATH} \
2304-
psql \
2305-
--host=$DB_HOST \
2306-
--port=$DB_PORT \
2307-
--username=$DB_USERNAME \
2308-
--dbname=$DB_NAME \
2309-
"
2299+
case "${APPLICATION}" in
2300+
participant-*)
2301+
local SEARCH_PATH="participant"
2302+
;;
2303+
sequencer-*)
2304+
local SEARCH_PATH="sequencer"
2305+
;;
2306+
mediator-*)
2307+
local SEARCH_PATH="mediator"
2308+
;;
2309+
*)
2310+
local SEARCH_PATH="$DB_NAME"
2311+
;;
2312+
esac
2313+
2314+
subcmd_debug_shell /bin/env \
2315+
PGPASSWORD="$DB_PASSWORD" \
2316+
PGOPTIONS="--search_path=${SEARCH_PATH},public" \
2317+
psql \
2318+
--host="$DB_HOST" \
2319+
--port="$DB_PORT" \
2320+
--username="$DB_USERNAME" \
2321+
--dbname="$DB_NAME"
23102322
}
23112323

23122324
################################

0 commit comments

Comments
 (0)