Skip to content

Commit 4e06bd5

Browse files
authored
fix: use joinPath helper to fix double slash issues in console configmap (#4562)
1 parent bd77b49 commit 4e06bd5

File tree

8 files changed

+167
-45
lines changed

8 files changed

+167
-45
lines changed

charts/camunda-platform-8.6/templates/camunda/_helpers.tpl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ Usage: {{ include "camundaPlatform.getExternalURL" (dict "component" "operate" "
423423
{{- printf "%s://%s" $proto (index .context.Values .component "ingress" "host") -}}
424424
{{- else if $.context.Values.global.ingress.enabled -}}
425425
{{ $proto := ternary "https" "http" .context.Values.global.ingress.tls.enabled -}}
426-
{{- printf "%s://%s%s" $proto .context.Values.global.ingress.host (index .context.Values .component "contextPath") -}}
426+
{{- printf "%s://%s%s" $proto .context.Values.global.ingress.host (include "camundaPlatform.joinpath" (list (index .context.Values .component "contextPath"))) -}}
427427
{{- else -}}
428428
{{- $portMapping := (dict
429429
"operate" "8081"
@@ -653,8 +653,8 @@ Release templates.
653653
id: operate
654654
version: {{ include "camundaPlatform.imageTagByParams" (dict "base" .Values.global "overlay" .Values.operate) }}
655655
url: {{ include "camundaPlatform.operateExternalURL" . }}
656-
readiness: {{ printf "%s%s%s" $baseURLInternal .Values.operate.contextPath .Values.operate.readinessProbe.probePath }}
657-
metrics: {{ printf "%s%s%s" $baseURLInternal .Values.operate.contextPath .Values.operate.metrics.prometheus }}
656+
readiness: {{ printf "%s%s" $baseURLInternal (include "camundaPlatform.joinpath" (list .Values.operate.contextPath .Values.operate.readinessProbe.probePath)) }}
657+
metrics: {{ printf "%s%s" $baseURLInternal (include "camundaPlatform.joinpath" (list .Values.operate.contextPath .Values.operate.metrics.prometheus)) }}
658658
{{- end }}
659659

660660
{{- if .Values.optimize.enabled }}
@@ -663,7 +663,7 @@ Release templates.
663663
id: optimize
664664
version: {{ include "camundaPlatform.imageTagByParams" (dict "base" .Values.global "overlay" .Values.optimize) }}
665665
url: {{ include "camundaPlatform.optimizeExternalURL" . }}
666-
readiness: {{ printf "%s:%v%s%s" $baseURLInternal .Values.optimize.service.port .Values.optimize.contextPath .Values.optimize.readinessProbe.probePath }}
666+
readiness: {{ printf "%s:%v%s" $baseURLInternal .Values.optimize.service.port (include "camundaPlatform.joinpath" (list .Values.optimize.contextPath .Values.optimize.readinessProbe.probePath)) }}
667667
metrics: {{ printf "%s:%v%s" $baseURLInternal .Values.optimize.service.managementPort .Values.optimize.metrics.prometheus }}
668668
{{- end }}
669669

@@ -673,8 +673,8 @@ Release templates.
673673
id: tasklist
674674
version: {{ include "camundaPlatform.imageTagByParams" (dict "base" .Values.global "overlay" .Values.tasklist) }}
675675
url: {{ include "camundaPlatform.tasklistExternalURL" . }}
676-
readiness: {{ printf "%s%s%s" $baseURLInternal .Values.tasklist.contextPath .Values.tasklist.readinessProbe.probePath }}
677-
metrics: {{ printf "%s%s%s" $baseURLInternal .Values.tasklist.contextPath .Values.tasklist.metrics.prometheus }}
676+
readiness: {{ printf "%s%s" $baseURLInternal (include "camundaPlatform.joinpath" (list .Values.tasklist.contextPath .Values.tasklist.readinessProbe.probePath)) }}
677+
metrics: {{ printf "%s%s" $baseURLInternal (include "camundaPlatform.joinpath" (list .Values.tasklist.contextPath .Values.tasklist.metrics.prometheus)) }}
678678
{{- end }}
679679

680680
{{- if .Values.webModeler.enabled }}
@@ -695,8 +695,8 @@ Release templates.
695695
urls:
696696
grpc: {{ include "camundaPlatform.zeebeGatewayGRPCExternalURL" . }}
697697
http: {{ include "camundaPlatform.zeebeGatewayExternalURL" . }}
698-
readiness: {{ printf "%s%s%s" $baseURLInternal .Values.zeebeGateway.contextPath .Values.zeebeGateway.readinessProbe.probePath }}
699-
metrics: {{ printf "%s%s%s" $baseURLInternal .Values.zeebeGateway.contextPath .Values.zeebeGateway.metrics.prometheus }}
698+
readiness: {{ printf "%s%s" $baseURLInternal (include "camundaPlatform.joinpath" (list .Values.zeebeGateway.contextPath .Values.zeebeGateway.readinessProbe.probePath)) }}
699+
metrics: {{ printf "%s%s" $baseURLInternal (include "camundaPlatform.joinpath" (list .Values.zeebeGateway.contextPath .Values.zeebeGateway.metrics.prometheus)) }}
700700
{{- $baseURLInternal := printf "http://%s.%s:%v" (include "zeebe.names.broker" . | trimAll "\"") .Release.Namespace .Values.zeebe.service.httpPort }}
701701
- name: Zeebe
702702
id: zeebe

charts/camunda-platform-8.6/test/unit/console/configmap_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,35 @@ func (s *configMapTemplateTest) TestDifferentValuesInputs() {
6565

6666
testhelpers.RunTestCases(s.T(), s.chartPath, s.release, s.namespace, s.templates, testCases)
6767
}
68+
69+
func (s *configMapTemplateTest) TestContextPathRootDoesNotCreateDoubleSlashes() {
70+
testCases := []testhelpers.TestCase{
71+
{
72+
Name: "ContextPathRootShouldNotCauseDoubleSlashesInURLs",
73+
Values: map[string]string{
74+
"console.enabled": "true",
75+
"identity.enabled": "true",
76+
"operate.enabled": "true",
77+
"tasklist.enabled": "true",
78+
"optimize.enabled": "true",
79+
"global.ingress.enabled": "true",
80+
"global.ingress.host": "camunda.example.com",
81+
"operate.contextPath": "/",
82+
"tasklist.contextPath": "/",
83+
"optimize.contextPath": "/",
84+
},
85+
Verifier: func(t *testing.T, output string, err error) {
86+
require.NoError(t, err)
87+
// Verify that URLs don't contain double slashes (except in http://)
88+
// Looking for patterns like "://hostname//" which indicate double slashes
89+
require.NotContains(t, output, ".com//", "URLs should not contain double slashes after hostname")
90+
require.NotContains(t, output, ":80//", "URLs should not contain double slashes after port")
91+
require.NotContains(t, output, ":82//", "URLs should not contain double slashes after port")
92+
require.NotContains(t, output, ":8080//", "URLs should not contain double slashes after port")
93+
require.NotContains(t, output, ":9600//", "URLs should not contain double slashes after port")
94+
},
95+
},
96+
}
97+
98+
testhelpers.RunTestCasesE(s.T(), s.chartPath, s.release, s.namespace, s.templates, testCases)
99+
}

charts/camunda-platform-8.7/templates/camunda/_helpers.tpl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ Usage: {{ include "camundaPlatform.getExternalURL" (dict "component" "operate" "
423423
{{- printf "%s://%s" $proto (index .context.Values .component "ingress" "host") -}}
424424
{{- else if $.context.Values.global.ingress.enabled -}}
425425
{{ $proto := ternary "https" "http" .context.Values.global.ingress.tls.enabled -}}
426-
{{- printf "%s://%s%s" $proto .context.Values.global.ingress.host (index .context.Values .component "contextPath") -}}
426+
{{- printf "%s://%s%s" $proto .context.Values.global.ingress.host (include "camundaPlatform.joinpath" (list (index .context.Values .component "contextPath"))) -}}
427427
{{- else -}}
428428
{{- $portMapping := (dict
429429
"operate" "8081"
@@ -677,8 +677,8 @@ Release templates.
677677
id: operate
678678
version: {{ include "camundaPlatform.imageTagByParams" (dict "base" .Values.global "overlay" .Values.operate) }}
679679
url: {{ include "camundaPlatform.operateExternalURL" . }}
680-
readiness: {{ printf "%s%s%s" $baseURLInternal .Values.operate.contextPath .Values.operate.readinessProbe.probePath }}
681-
metrics: {{ printf "%s%s%s" $baseURLInternal .Values.operate.contextPath .Values.operate.metrics.prometheus }}
680+
readiness: {{ printf "%s%s" $baseURLInternal (include "camundaPlatform.joinpath" (list .Values.operate.contextPath .Values.operate.readinessProbe.probePath)) }}
681+
metrics: {{ printf "%s%s" $baseURLInternal (include "camundaPlatform.joinpath" (list .Values.operate.contextPath .Values.operate.metrics.prometheus)) }}
682682
{{- end }}
683683

684684
{{- if .Values.optimize.enabled }}
@@ -687,7 +687,7 @@ Release templates.
687687
id: optimize
688688
version: {{ include "camundaPlatform.imageTagByParams" (dict "base" .Values.global "overlay" .Values.optimize) }}
689689
url: {{ include "camundaPlatform.optimizeExternalURL" . }}
690-
readiness: {{ printf "%s:%v%s%s" $baseURLInternal .Values.optimize.service.port .Values.optimize.contextPath .Values.optimize.readinessProbe.probePath }}
690+
readiness: {{ printf "%s:%v%s" $baseURLInternal .Values.optimize.service.port (include "camundaPlatform.joinpath" (list .Values.optimize.contextPath .Values.optimize.readinessProbe.probePath)) }}
691691
metrics: {{ printf "%s:%v%s" $baseURLInternal .Values.optimize.service.managementPort .Values.optimize.metrics.prometheus }}
692692
{{- end }}
693693

@@ -698,7 +698,7 @@ Release templates.
698698
id: connectors
699699
version: {{ include "camundaPlatform.imageTagByParams" (dict "base" .Values.global "overlay" .Values.connectors) }}
700700
url: {{ include "camundaPlatform.connectorsExternalURL" . }}
701-
readiness: {{ printf "%s:%v%s%s" $baseURLInternal .Values.connectors.service.serverPort .Values.connectors.contextPath .Values.connectors.readinessProbe.probePath }}
701+
readiness: {{ printf "%s:%v%s" $baseURLInternal .Values.connectors.service.serverPort (include "camundaPlatform.joinpath" (list .Values.connectors.contextPath .Values.connectors.readinessProbe.probePath)) }}
702702
metrics: {{ printf "%s:%v%s" $baseURLInternal .Values.connectors.service.serverPort .Values.connectors.metrics.prometheus }}
703703
{{- end }}
704704

@@ -708,8 +708,8 @@ Release templates.
708708
id: tasklist
709709
version: {{ include "camundaPlatform.imageTagByParams" (dict "base" .Values.global "overlay" .Values.tasklist) }}
710710
url: {{ include "camundaPlatform.tasklistExternalURL" . }}
711-
readiness: {{ printf "%s%s%s" $baseURLInternal .Values.tasklist.contextPath .Values.tasklist.readinessProbe.probePath }}
712-
metrics: {{ printf "%s%s%s" $baseURLInternal .Values.tasklist.contextPath .Values.tasklist.metrics.prometheus }}
711+
readiness: {{ printf "%s%s" $baseURLInternal (include "camundaPlatform.joinpath" (list .Values.tasklist.contextPath .Values.tasklist.readinessProbe.probePath)) }}
712+
metrics: {{ printf "%s%s" $baseURLInternal (include "camundaPlatform.joinpath" (list .Values.tasklist.contextPath .Values.tasklist.metrics.prometheus)) }}
713713
{{- end }}
714714

715715
{{- if .Values.webModeler.enabled }}
@@ -730,8 +730,8 @@ Release templates.
730730
urls:
731731
grpc: {{ include "camundaPlatform.zeebeGatewayGRPCExternalURL" . }}
732732
http: {{ include "camundaPlatform.zeebeGatewayExternalURL" . }}
733-
readiness: {{ printf "%s%s%s" $baseURLInternal .Values.zeebeGateway.contextPath .Values.zeebeGateway.readinessProbe.probePath }}
734-
metrics: {{ printf "%s%s%s" $baseURLInternal .Values.zeebeGateway.contextPath .Values.zeebeGateway.metrics.prometheus }}
733+
readiness: {{ printf "%s%s" $baseURLInternal (include "camundaPlatform.joinpath" (list .Values.zeebeGateway.contextPath .Values.zeebeGateway.readinessProbe.probePath)) }}
734+
metrics: {{ printf "%s%s" $baseURLInternal (include "camundaPlatform.joinpath" (list .Values.zeebeGateway.contextPath .Values.zeebeGateway.metrics.prometheus)) }}
735735
{{- $baseURLInternal := printf "http://%s.%s:%v" (include "zeebe.names.broker" . | trimAll "\"") .Release.Namespace .Values.zeebe.service.httpPort }}
736736
- name: Zeebe
737737
id: zeebe

charts/camunda-platform-8.7/test/unit/console/configmap_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,37 @@ func (s *configMapTemplateTest) TestDifferentValuesInputs() {
6565

6666
testhelpers.RunTestCases(s.T(), s.chartPath, s.release, s.namespace, s.templates, testCases)
6767
}
68+
69+
func (s *configMapTemplateTest) TestContextPathRootDoesNotCreateDoubleSlashes() {
70+
testCases := []testhelpers.TestCase{
71+
{
72+
Name: "ContextPathRootShouldNotCauseDoubleSlashesInURLs",
73+
Values: map[string]string{
74+
"console.enabled": "true",
75+
"identity.enabled": "true",
76+
"operate.enabled": "true",
77+
"tasklist.enabled": "true",
78+
"optimize.enabled": "true",
79+
"connectors.enabled": "true",
80+
"global.ingress.enabled": "true",
81+
"global.ingress.host": "camunda.example.com",
82+
"operate.contextPath": "/",
83+
"tasklist.contextPath": "/",
84+
"optimize.contextPath": "/",
85+
"connectors.contextPath": "/",
86+
},
87+
Verifier: func(t *testing.T, output string, err error) {
88+
require.NoError(t, err)
89+
// Verify that URLs don't contain double slashes (except in http://)
90+
// Looking for patterns like "://hostname//" which indicate double slashes
91+
require.NotContains(t, output, ".com//", "URLs should not contain double slashes after hostname")
92+
require.NotContains(t, output, ":80//", "URLs should not contain double slashes after port")
93+
require.NotContains(t, output, ":82//", "URLs should not contain double slashes after port")
94+
require.NotContains(t, output, ":8080//", "URLs should not contain double slashes after port")
95+
require.NotContains(t, output, ":9600//", "URLs should not contain double slashes after port")
96+
},
97+
},
98+
}
99+
100+
testhelpers.RunTestCasesE(s.T(), s.chartPath, s.release, s.namespace, s.templates, testCases)
101+
}

charts/camunda-platform-8.8/templates/common/_helpers.tpl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ Usage: {{ include "camundaPlatform.getExternalURL" (dict "component" "operate" "
362362
[camunda-platform] Operate external URL.
363363
*/}}
364364
{{- define "camundaPlatform.operateExternalURL" }}
365-
{{- printf "%s/operate" (include "camundaPlatform.orchestrationExternalURL" .) -}}
365+
{{- printf "%s/operate" (include "camundaPlatform.orchestrationExternalURL" . | trimSuffix "/") -}}
366366
{{- end -}}
367367

368368

@@ -400,7 +400,7 @@ Tasklist templates.
400400
[camunda-platform] Tasklist external URL.
401401
*/}}
402402
{{- define "camundaPlatform.tasklistExternalURL" }}
403-
{{- printf "%s/tasklist" (include "camundaPlatform.orchestrationExternalURL" .) -}}
403+
{{- printf "%s/tasklist" (include "camundaPlatform.orchestrationExternalURL" . | trimSuffix "/") -}}
404404
{{- end -}}
405405

406406

@@ -414,7 +414,7 @@ Orchestration Identity templates.
414414
[camunda-platform] Orchestration Identity external URL.
415415
*/}}
416416
{{- define "camundaPlatform.orchestrationIdentityExternalURL" }}
417-
{{- printf "%s/identity" (include "camundaPlatform.orchestrationExternalURL" .) -}}
417+
{{- printf "%s/identity" (include "camundaPlatform.orchestrationExternalURL" . | trimSuffix "/") -}}
418418
{{- end -}}
419419

420420

@@ -566,7 +566,7 @@ Zeebe templates.
566566
{{- define "camundaPlatform.orchestrationExternalURL" }}
567567
{{- if .Values.global.ingress.enabled -}}
568568
{{ $proto := ternary "https" "http" .Values.global.ingress.tls.enabled -}}
569-
{{- printf "%s://%s%s" $proto .Values.global.ingress.host .Values.orchestration.contextPath -}}
569+
{{- printf "%s://%s%s" $proto .Values.global.ingress.host (include "camundaPlatform.joinpath" (list .Values.orchestration.contextPath)) -}}
570570
{{- else -}}
571571
{{- printf "http://localhost:8088" -}}
572572
{{- end -}}
@@ -666,7 +666,7 @@ Release templates.
666666
id: optimize
667667
version: {{ include "camundaPlatform.imageTagByParams" (dict "base" .Values.global "overlay" .Values.optimize) }}
668668
url: {{ include "camundaPlatform.optimizeExternalURL" . }}
669-
readiness: {{ printf "%s:%v%s%s" $baseURLInternal .Values.optimize.service.port .Values.optimize.contextPath .Values.optimize.readinessProbe.probePath }}
669+
readiness: {{ printf "%s:%v%s" $baseURLInternal .Values.optimize.service.port (include "camundaPlatform.joinpath" (list .Values.optimize.contextPath .Values.optimize.readinessProbe.probePath)) }}
670670
metrics: {{ printf "%s:%v%s" $baseURLInternal .Values.optimize.service.managementPort .Values.optimize.metrics.prometheus }}
671671
{{- end }}
672672

@@ -677,7 +677,7 @@ Release templates.
677677
id: connectors
678678
version: {{ include "camundaPlatform.imageTagByParams" (dict "base" .Values.global "overlay" .Values.connectors) }}
679679
url: {{ include "camundaPlatform.connectorsExternalURL" . }}
680-
readiness: {{ printf "%s:%v%s%s" $baseURLInternal .Values.connectors.service.serverPort .Values.connectors.contextPath .Values.connectors.readinessProbe.probePath }}
680+
readiness: {{ printf "%s:%v%s" $baseURLInternal .Values.connectors.service.serverPort (include "camundaPlatform.joinpath" (list .Values.connectors.contextPath .Values.connectors.readinessProbe.probePath)) }}
681681
metrics: {{ printf "%s:%v%s" $baseURLInternal .Values.connectors.service.serverPort .Values.connectors.metrics.prometheus }}
682682
{{- end }}
683683

@@ -688,29 +688,29 @@ Release templates.
688688
id: operate
689689
version: {{ include "camundaPlatform.imageTagByParams" (dict "base" .Values.global "overlay" .Values.orchestration) }}
690690
url: {{ include "camundaPlatform.operateExternalURL" . }}
691-
readiness: {{ printf "%s%s%s" $baseURLInternal .Values.orchestration.contextPath .Values.orchestration.readinessProbe.probePath }}
692-
metrics: {{ printf "%s%s%s" $baseURLInternal .Values.orchestration.contextPath .Values.orchestration.metrics.prometheus }}
691+
readiness: {{ printf "%s%s" $baseURLInternal (include "camundaPlatform.joinpath" (list .Values.orchestration.contextPath .Values.orchestration.readinessProbe.probePath)) }}
692+
metrics: {{ printf "%s%s" $baseURLInternal (include "camundaPlatform.joinpath" (list .Values.orchestration.contextPath .Values.orchestration.metrics.prometheus)) }}
693693
- name: Tasklist
694694
id: tasklist
695695
version: {{ include "camundaPlatform.imageTagByParams" (dict "base" .Values.global "overlay" .Values.orchestration) }}
696696
url: {{ include "camundaPlatform.tasklistExternalURL" . }}
697-
readiness: {{ printf "%s%s%s" $baseURLInternal .Values.orchestration.contextPath .Values.orchestration.readinessProbe.probePath }}
698-
metrics: {{ printf "%s%s%s" $baseURLInternal .Values.orchestration.contextPath .Values.orchestration.metrics.prometheus }}
697+
readiness: {{ printf "%s%s" $baseURLInternal (include "camundaPlatform.joinpath" (list .Values.orchestration.contextPath .Values.orchestration.readinessProbe.probePath)) }}
698+
metrics: {{ printf "%s%s" $baseURLInternal (include "camundaPlatform.joinpath" (list .Values.orchestration.contextPath .Values.orchestration.metrics.prometheus)) }}
699699
- name: Orchestration Identity
700700
id: orchestrationIdentity
701701
version: {{ include "camundaPlatform.imageTagByParams" (dict "base" .Values.global "overlay" .Values.orchestration) }}
702702
url: {{ include "camundaPlatform.orchestrationIdentityExternalURL" . }}
703-
readiness: {{ printf "%s%s%s" $baseURLInternal .Values.orchestration.contextPath .Values.orchestration.readinessProbe.probePath }}
704-
metrics: {{ printf "%s%s%s" $baseURLInternal .Values.orchestration.contextPath .Values.orchestration.metrics.prometheus }}
703+
readiness: {{ printf "%s%s" $baseURLInternal (include "camundaPlatform.joinpath" (list .Values.orchestration.contextPath .Values.orchestration.readinessProbe.probePath)) }}
704+
metrics: {{ printf "%s%s" $baseURLInternal (include "camundaPlatform.joinpath" (list .Values.orchestration.contextPath .Values.orchestration.metrics.prometheus)) }}
705705

706706
- name: Orchestration Cluster
707707
id: orchestration
708708
version: {{ include "camundaPlatform.imageTagByParams" (dict "base" .Values.global "overlay" .Values.orchestration) }}
709709
urls:
710710
grpc: {{ include "camundaPlatform.orchestrationGRPCExternalURL" . }}
711711
http: {{ include "camundaPlatform.orchestrationExternalURL" . }}
712-
readiness: {{ printf "%s%s%s" $baseURLInternal .Values.orchestration.contextPath .Values.orchestration.readinessProbe.probePath }}
713-
metrics: {{ printf "%s%s%s" $baseURLInternal .Values.orchestration.contextPath .Values.orchestration.metrics.prometheus }}
712+
readiness: {{ printf "%s%s" $baseURLInternal (include "camundaPlatform.joinpath" (list .Values.orchestration.contextPath .Values.orchestration.readinessProbe.probePath)) }}
713+
metrics: {{ printf "%s%s" $baseURLInternal (include "camundaPlatform.joinpath" (list .Values.orchestration.contextPath .Values.orchestration.metrics.prometheus)) }}
714714
{{- end }}
715715
{{- end -}}
716716

0 commit comments

Comments
 (0)