From c306acc6a9d9a74bbb86685ee79513e850247789 Mon Sep 17 00:00:00 2001 From: Tomas Adomavicius Date: Fri, 27 Aug 2021 13:08:23 +0300 Subject: [PATCH] add JDBC compliant URI to kubernetes secret --- .../postgresuser/postgresuser_controller.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/controller/postgresuser/postgresuser_controller.go b/pkg/controller/postgresuser/postgresuser_controller.go index c425bf541..0fcdd9e50 100644 --- a/pkg/controller/postgresuser/postgresuser_controller.go +++ b/pkg/controller/postgresuser/postgresuser_controller.go @@ -263,6 +263,7 @@ func (r *ReconcilePostgresUser) addFinalizer(reqLogger logr.Logger, m *dbv1alpha func (r *ReconcilePostgresUser) newSecretForCR(cr *dbv1alpha1.PostgresUser, role, password, login string) *corev1.Secret { pgUserUrl := fmt.Sprintf("postgresql://%s:%s@%s/%s", role, password, r.pgHost, cr.Status.DatabaseName) + pgJDBCUrl := fmt.Sprintf("jdbc:postgresql://%s/%s", r.pgHost, cr.Status.DatabaseName) labels := map[string]string{ "app": cr.Name, } @@ -273,12 +274,13 @@ func (r *ReconcilePostgresUser) newSecretForCR(cr *dbv1alpha1.PostgresUser, role Labels: labels, }, Data: map[string][]byte{ - "POSTGRES_URL": []byte(pgUserUrl), - "HOST": []byte(r.pgHost), - "DATABASE_NAME": []byte(cr.Status.DatabaseName), - "ROLE": []byte(role), - "PASSWORD": []byte(password), - "LOGIN": []byte(login), + "POSTGRES_URL": []byte(pgUserUrl), + "POSTGRES_JDBC_URL": []byte(pgJDBCUrl), + "HOST": []byte(r.pgHost), + "DATABASE_NAME": []byte(cr.Status.DatabaseName), + "ROLE": []byte(role), + "PASSWORD": []byte(password), + "LOGIN": []byte(login), }, } }