Skip to content

Commit 2180258

Browse files
committed
chore(database): add init database configure
1 parent a9654da commit 2180258

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

charts/database/templates/_helper.tpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ env:
3636
value: '0.0.0.0:5432'
3737
- name: PATRONI_RESTAPI_LISTEN
3838
value: '0.0.0.0:8008'
39+
- name: "DRYCC_DATABASE_INIT_NAMES"
40+
value: "{{.Values.initDatabases}}"
3941
- name: DRYCC_DATABASE_SUPERUSER
4042
valueFrom:
4143
secretKeyRef:

charts/database/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ replicator: "standby"
5656
replicatorPassword: ""
5757
user: ""
5858
password: ""
59+
initDatabases: "controller,passport"
5960

6061
global:
6162
# Set the location of Workflow's Object Storage

rootfs/usr/share/scripts/patroni/post_init.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ if [[ ( -n "$DRYCC_DATABASE_USER") && ( -n "$DRYCC_DATABASE_PASSWORD")]]; then
55
echo "Creating user ${DRYCC_DATABASE_USER}"
66
psql "$1" -w -c "create user ${DRYCC_DATABASE_USER} WITH LOGIN ENCRYPTED PASSWORD '${DRYCC_DATABASE_PASSWORD}'"
77

8-
echo "Creating passport and controller databases"
9-
psql "$1" -w -c "CREATE DATABASE passport OWNER ${DRYCC_DATABASE_USER}"
10-
psql "$1" -w -c "CREATE DATABASE controller OWNER ${DRYCC_DATABASE_USER}"
11-
8+
for dbname in ${DRYCC_DATABASE_INIT_NAMES//,/ }
9+
do
10+
echo "Creating database ${dbname}"
11+
psql "$1" -w -c "CREATE DATABASE ${dbname} OWNER ${DRYCC_DATABASE_USER}"
12+
done
1213
else
1314
echo "Skipping user creation"
1415
echo "Skipping database creation"

0 commit comments

Comments
 (0)