Skip to content

Commit 3857e26

Browse files
committed
fix: revert webmodeler externaldb change
1 parent f8cbf82 commit 3857e26

File tree

3 files changed

+42
-52
lines changed

3 files changed

+42
-52
lines changed

charts/camunda-platform-8.8/templates/web-modeler/_helpers.tpl

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,8 @@ Define match labels for Web Modeler websockets to be used in matchLabels selecto
191191
(include "webModeler.postgresql.fullname" .)
192192
(.Values.webModelerPostgresql.auth.database)
193193
-}}
194-
{{- else if .Values.webModeler.restapi.externalDatabase.url -}}
194+
{{- else -}}
195195
{{- .Values.webModeler.restapi.externalDatabase.url -}}
196-
{{- else if .Values.webModeler.restapi.externalDatabase.host -}}
197-
{{- printf "jdbc:postgresql://%s:%s/%s"
198-
.Values.webModeler.restapi.externalDatabase.host
199-
(toString (.Values.webModeler.restapi.externalDatabase.port))
200-
(.Values.webModeler.restapi.externalDatabase.database)
201-
-}}
202196
{{- end -}}
203197
{{- end -}}
204198

charts/camunda-platform-8.8/test/unit/web-modeler/configmap_restapi_test.go

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type configmapRestAPITemplateTest struct {
2626
var requiredValues = map[string]string{
2727
"webModeler.enabled": "true",
2828
"webModeler.restapi.mail.fromAddress": "[email protected]",
29+
"webModelerPostgresql.enabled": "true",
2930
"global.identity.auth.connectors.existingSecret.name": "foo",
3031
"global.identity.auth.orchestration.existingSecret.name": "foo",
3132
}
@@ -277,11 +278,42 @@ func (s *configmapRestAPITemplateTest) TestContainerShouldSetSmtpCredentials() {
277278
func (s *configmapRestAPITemplateTest) TestContainerShouldSetExternalDatabaseConfiguration() {
278279
// given
279280
values := map[string]string{
280-
"identity.enabled": "true",
281-
"webModelerPostgresql.enabled": "false",
282-
"webModeler.restapi.externalDatabase.url": "jdbc:postgresql://postgres.example.com:65432/modeler-database",
283-
"webModeler.restapi.externalDatabase.user": "modeler-user",
284-
"webModeler.restapi.externalDatabase.password": "modeler-password",
281+
"identity.enabled": "true",
282+
"webModelerPostgresql.enabled": "false",
283+
"webModeler.restapi.externalDatabase.url": "jdbc:postgresql://postgres.example.com:65432/modeler-database",
284+
}
285+
// Copy required values and then override with test-specific values
286+
finalValues := make(map[string]string)
287+
maps.Insert(finalValues, maps.All(requiredValues))
288+
maps.Insert(finalValues, maps.All(values))
289+
290+
options := &helm.Options{
291+
SetValues: finalValues,
292+
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace),
293+
}
294+
295+
// when
296+
output := helm.RenderTemplate(s.T(), options, s.chartPath, s.release, s.templates)
297+
var configmap corev1.ConfigMap
298+
var configmapApplication WebModelerRestAPIApplicationYAML
299+
helm.UnmarshalK8SYaml(s.T(), output, &configmap)
300+
301+
err := yaml.Unmarshal([]byte(configmap.Data["application.yaml"]), &configmapApplication)
302+
if err != nil {
303+
s.Fail("Failed to unmarshal yaml. error=", err)
304+
}
305+
306+
// then
307+
s.Require().Equal("jdbc:postgresql://postgres.example.com:65432/modeler-database", configmapApplication.Spring.Datasource.Url)
308+
// Username is not set in the ConfigMap for external databases - it comes from environment variables
309+
}
310+
311+
func (s *configmapRestAPITemplateTest) TestContainerShouldSetInternalDatabaseConfiguration() {
312+
// given
313+
values := map[string]string{
314+
"identity.enabled": "true",
315+
"webModelerPostgresql.enabled": "true",
316+
"webModelerPostgresql.auth.database": "internal-modeler-db",
285317
}
286318
maps.Insert(values, maps.All(requiredValues))
287319
options := &helm.Options{
@@ -301,8 +333,9 @@ func (s *configmapRestAPITemplateTest) TestContainerShouldSetExternalDatabaseCon
301333
}
302334

303335
// then
304-
s.Require().Equal("jdbc:postgresql://postgres.example.com:65432/modeler-database", configmapApplication.Spring.Datasource.Url)
305-
s.Require().Equal("modeler-user", configmapApplication.Spring.Datasource.Username)
336+
// Should generate the internal PostgreSQL JDBC URL
337+
s.Require().Equal("jdbc:postgresql://camunda-platform-test-postgresql-web-modeler:5432/internal-modeler-db", configmapApplication.Spring.Datasource.Url)
338+
s.Require().Equal("web-modeler", configmapApplication.Spring.Datasource.Username) // Default username from PostgreSQL chart
306339
}
307340

308341
func (s *configmapRestAPITemplateTest) TestContainerShouldConfigureClusterFromSameHelmInstallationWithCustomValues() {
@@ -550,33 +583,3 @@ func (s *configmapRestAPITemplateTest) TestContainerShouldSetJwkSetUriFromKeyclo
550583
// then
551584
s.Require().Equal("https://example.com:443/test/protocol/openid-connect/certs", configmapApplication.Spring.Security.OAuth2.ResourceServer.JWT.JwkSetURI)
552585
}
553-
554-
func (s *configmapRestAPITemplateTest) TestContainerShouldSetJdbcUrlFromHostPortDatabase() {
555-
// given
556-
values := map[string]string{
557-
"identity.enabled": "true",
558-
"webModelerPostgresql.enabled": "false",
559-
"webModeler.restapi.externalDatabase.host": "custom-db.example.com",
560-
"webModeler.restapi.externalDatabase.port": "65432",
561-
"webModeler.restapi.externalDatabase.database": "custom-modeler-db",
562-
}
563-
maps.Insert(values, maps.All(requiredValues))
564-
options := &helm.Options{
565-
SetValues: values,
566-
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace),
567-
}
568-
569-
// when
570-
output := helm.RenderTemplate(s.T(), options, s.chartPath, s.release, s.templates)
571-
var configmap corev1.ConfigMap
572-
var configmapApplication WebModelerRestAPIApplicationYAML
573-
helm.UnmarshalK8SYaml(s.T(), output, &configmap)
574-
575-
err := yaml.Unmarshal([]byte(configmap.Data["application.yaml"]), &configmapApplication)
576-
if err != nil {
577-
s.Fail("Failed to unmarshal yaml. error=", err)
578-
}
579-
580-
// then
581-
s.Require().Equal("jdbc:postgresql://custom-db.example.com:65432/custom-modeler-db", configmapApplication.Spring.Datasource.Url)
582-
}

charts/camunda-platform-8.8/values.yaml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,15 +1422,8 @@ webModeler:
14221422

14231423
## @extra webModeler.restapi.externalDatabase can be used to configure a connection to an external database; will only be applied if the postgresql dependency chart is disabled (with `postgresql.enabled=false`)
14241424
externalDatabase:
1425-
## @param webModeler.restapi.externalDatabase.url (DEPRECATED - use host, port, and database instead) defines the JDBC url of the database instance.
1426-
# Note: If url is provided, it takes precedence over individual connection parameters (host, port, database)
1425+
## @param webModeler.restapi.externalDatabase.url defines the JDBC url of the database instance.
14271426
url: ""
1428-
## @param webModeler.restapi.externalDatabase.host Database host (used when url is not provided)
1429-
host: ""
1430-
## @param webModeler.restapi.externalDatabase.port Database port number (used when url is not provided)
1431-
port: 5432
1432-
## @param webModeler.restapi.externalDatabase.database The database name (used when url is not provided)
1433-
database: "web-modeler"
14341427
## @param webModeler.restapi.externalDatabase.user defines the database user
14351428
user: ""
14361429
## @param webModeler.restapi.externalDatabase.password (DEPRECATED - use webModeler.restapi.externalDatabase.secret instead) can be used to provide the database user's password; ignored if `webModeler.restapi.externalDatabase.existingSecret` is set

0 commit comments

Comments
 (0)