Skip to content

Commit c8ebf3a

Browse files
author
Corneil du Plessis
committed
[CI] Improve Secret management.
1 parent 8bc3db3 commit c8ebf3a

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

src/deploy/carvel/configure-database.sh

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,24 +67,37 @@ if [ "$JDBC_DRIVER_CLASS" != "" ]; then
6767
yq ".scdf.${APP}.database.driverClassName=\"$JDBC_DRIVER_CLASS\"" -i ./scdf-values.yml
6868
fi
6969

70-
SECRET_NAME=$4
71-
if [ "$5" != "" ]; then
72-
SECRET_USERNAME_KEY="$5"
73-
else
74-
SECRET_USERNAME_KEY=username
75-
fi
7670
if [ "$6" != "" ]; then
71+
SECRET_NAME=$4
72+
SECRET_USERNAME_KEY="$5"
7773
SECRET_PASSWORD_KEY="$6"
74+
elif [ "$5" != "" ]; then
75+
USERNAME="$4"
76+
PASSWORD="$5"
7877
else
78+
SECRET_NAME=$4
79+
SECRET_USERNAME_KEY=username
7980
SECRET_PASSWORD_KEY=password
8081
fi
81-
82-
if [ "$DEBUG" == "true" ]; then
83-
echo "DEBUG: SECRET_NAME=$SECRET_NAME"
82+
if [ "$SECRET_NAME" != "" ]; then
83+
if [ "$DEBUG" == "true" ]; then
84+
echo "DEBUG: SECRET_NAME=$SECRET_NAME, SECRET_USERNAME_KEY=$SECRET_USERNAME_KEY, SECRET_PASSWORD_KEY=$SECRET_PASSWORD_KEY"
85+
fi
86+
yq ".scdf.${APP}.database.secretName=\"$SECRET_NAME\"" -i ./scdf-values.yml
87+
yq ".scdf.${APP}.database.secretUsernameKey=\"$SECRET_USERNAME_KEY\"" -i ./scdf-values.yml
88+
yq ".scdf.${APP}.database.secretPasswordKey=\"$SECRET_PASSWORD_KEY\"" -i ./scdf-values.yml
89+
else
90+
if [ "$USERNAME" = "" ]; then
91+
echo "Expected $USERNAME"
92+
exit 1
93+
fi
94+
if [ "$PASSWORD" = "" ]; then
95+
echo "Expected $PASSWORD"
96+
exit 1
97+
fi
98+
yq ".scdf.${APP}.database.username=\"$USERNAME\"" -i ./scdf-values.yml
99+
yq ".scdf.${APP}.database.password=\"$PASSWORD\"" -i ./scdf-values.yml
84100
fi
85-
yq ".scdf.${APP}.database.secretName=\"$SECRET_NAME\"" -i ./scdf-values.yml
86-
yq ".scdf.${APP}.database.secretUsernameKey=\"$SECRET_USERNAME_KEY\"" -i ./scdf-values.yml
87-
yq ".scdf.${APP}.database.secretPasswordKey=\"$SECRET_PASSWORD_KEY\"" -i ./scdf-values.yml
88101

89102
echo "Set ${APP} JDBC url: $JDBC_URL"
90103
echo "Set ${APP} JDBC class: $JDBC_DRIVER_CLASS"

0 commit comments

Comments
 (0)