Skip to content

Commit e5bb167

Browse files
committed
DEVPROD-3580 Extracted and re-used common logic.
1 parent 2fcda43 commit e5bb167

45 files changed

Lines changed: 359 additions & 453 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONTRIBUTING.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@ For any pull requests, code owners should review the changes thoroughly and make
2525

2626
For external contributions, any Github action workflow related changes are not acceptable.
2727

28+
## Windows Users
29+
30+
This repository uses **symlinks** to share common Helm templates across product charts
31+
(see `src/main/charts/common_templates/`). Git on Windows doesn't enable symlinks by default — without them,
32+
Helm template rendering will fail.
33+
34+
To enable symlinks on Windows:
35+
36+
1. Enable **Developer Mode** in Windows Settings (Settings → Update & Security → For Developers), or run Git as Administrator
37+
2. Configure Git to create real symlinks:
38+
```
39+
git config --global core.symlinks true
40+
```
41+
3. Re-clone the repository after changing this setting (existing clones won't retroactively fix symlinks)
42+
43+
2844
### How to run E2E tests
2945

3046
The Data Center Helm Charts uses the latest release of [Deployment Automation for Atlassian DC on K8s](https://github.com/atlassian-labs/data-center-terraform#deployment-automation-for-atlassian-dc-on-k8s) for end-to-end testing. Internal reviewers can run the tests by adding `e2e` label on a pull request (for external contributions, be mindful of the changes as it will run on internal cloud environment).

src/main/charts/bamboo-agent/.helmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@
2121
.idea/
2222
*.tmproj
2323
.vscode/
24+
# Ignore non-template files from symlinked common_templates
25+
templates/common_templates/*.md

src/main/charts/bamboo/.helmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@
2121
.idea/
2222
*.tmproj
2323
.vscode/
24+
# Ignore non-template files from symlinked common_templates
25+
templates/common_templates/*.md

src/main/charts/bamboo/templates/NOTES.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ To see the custom values you used for this release:
1313

1414
$ helm get values {{ .Release.Name }} -n {{ .Release.Namespace }}
1515

16-
{{ if or .Values.ingress.create .Values.gateway.create -}}
17-
{{ title .Chart.Name }} service URL: {{ if .Values.gateway.create }}{{ ternary "https" "http" .Values.gateway.https }}{{ else }}{{ ternary "https" "http" .Values.ingress.https }}{{ end -}}://{{ include "bamboo.hostname" . }}{{ include "bamboo.ingressPath" . }}
16+
{{ if eq (include "common.gateway.isConfigured" .) "true" -}}
17+
{{ title .Chart.Name }} service URL: {{ include "bamboo.baseUrl" . }}
1818
{{- else }}
1919
Get the {{ title .Chart.Name }} URL by running these commands in the same shell:
2020
{{- if contains "NodePort" .Values.bamboo.service.type }}

src/main/charts/bamboo/templates/_helpers.tpl

Lines changed: 16 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -62,45 +62,31 @@
6262
Deduce the base URL for bamboo.
6363
*/}}
6464
{{- define "bamboo.baseUrl" -}}
65-
{{- if or .Values.ingress.host .Values.gateway.create -}}
66-
{{ ternary "https" "http" (include "bamboo.https" . | trim | eq "true") -}}
67-
://
68-
{{- include "bamboo.hostname" . -}}
69-
{{- if .Values.gateway.create -}}
70-
{{- if .Values.gateway.path -}}
71-
{{- .Values.gateway.path -}}
72-
{{- end -}}
73-
{{- else if .Values.ingress.path -}}
74-
{{- .Values.ingress.path -}}
75-
{{- end }}
76-
{{- else -}}
77-
{{- print "http://localhost:8085/" }}
78-
{{- end }}
65+
{{- if eq (include "common.gateway.isConfigured" .) "true" -}}
66+
{{- include "common.gateway.origin" . -}}{{ include "bamboo.path" . -}}
67+
{{- else -}}
68+
{{- print "http://localhost:8085/" -}}
69+
{{- end -}}
7970
{{- end }}
8071

8172
{{/*
82-
Create default value for ingress port
73+
Create default value for the service path.
74+
Works with both Ingress and Gateway API.
8375
*/}}
84-
{{- define "bamboo.ingressPort" -}}
85-
{{ default (ternary "443" "80" .Values.ingress.https) .Values.ingress.port -}}
76+
{{- define "bamboo.path" -}}
77+
{{- include "common.gateway.path" (dict
78+
"useGatewayMode" (include "common.gateway.useGatewayMode" .)
79+
"gatewayPath" .Values.gateway.path
80+
"ingressPath" .Values.ingress.path
81+
"contextPath" .Values.bamboo.service.contextPath
82+
) -}}
8683
{{- end }}
8784

8885
{{/*
89-
Create default value for ingress path.
90-
91-
When using Gateway API, prefer gateway.path to keep URL/path
92-
behavior consistent with ingress.path.
86+
Alias for backward compatibility with ingress templates.
9387
*/}}
9488
{{- define "bamboo.ingressPath" -}}
95-
{{- if .Values.gateway.create -}}
96-
{{- if .Values.gateway.path -}}
97-
{{- .Values.gateway.path -}}
98-
{{- end -}}
99-
{{- else if .Values.ingress.path -}}
100-
{{- .Values.ingress.path -}}
101-
{{- else -}}
102-
{{ default ( "/" ) .Values.bamboo.service.contextPath -}}
103-
{{- end }}
89+
{{- include "bamboo.path" . -}}
10490
{{- end }}
10591

10692
{{/*
@@ -458,51 +444,4 @@ set -e; cp $JAVA_HOME/lib/security/cacerts /var/ssl/cacerts; chmod 664 /var/ssl/
458444
{{- end }}
459445
{{- end }}
460446

461-
{{/*
462-
Validate Gateway API configuration
463-
*/}}
464-
{{- define "bamboo.validateGatewayConfig" -}}
465-
{{- if and .Values.gateway.create .Values.ingress.create -}}
466-
{{- fail "ERROR: Cannot enable both gateway.create and ingress.create" -}}
467-
{{- end -}}
468-
{{- if and .Values.gateway.create (not .Values.gateway.gatewayName) -}}
469-
{{- fail "ERROR: gateway.gatewayName is required when gateway.create is true" -}}
470-
{{- end -}}
471-
{{- if and .Values.gateway.create (not .Values.gateway.hostnames) -}}
472-
{{- fail "ERROR: gateway.hostnames must contain at least one hostname when gateway.create is true" -}}
473-
{{- end -}}
474-
{{- end -}}
475447

476-
{{/*
477-
Get the hostname for the service - works with both Ingress and Gateway API
478-
Returns the first hostname from gateway.hostnames if gateway is enabled, otherwise ingress.host
479-
*/}}
480-
{{- define "bamboo.hostname" -}}
481-
{{- if .Values.gateway.create -}}
482-
{{- index .Values.gateway.hostnames 0 -}}
483-
{{- else -}}
484-
{{- .Values.ingress.host -}}
485-
{{- end -}}
486-
{{- end -}}
487-
488-
{{/*
489-
Returns true if HTTPS is enabled (gateway.https if gateway is enabled, otherwise ingress.https)
490-
*/}}
491-
{{- define "bamboo.https" -}}
492-
{{- if .Values.gateway.create -}}
493-
{{- .Values.gateway.https -}}
494-
{{- else -}}
495-
{{- .Values.ingress.https -}}
496-
{{- end -}}
497-
{{- end -}}
498-
499-
{{/*
500-
Returns the proxy port (gateway or ingress-based)
501-
*/}}
502-
{{- define "bamboo.proxyPort" -}}
503-
{{- if .Values.gateway.create -}}
504-
{{- ternary "443" "80" .Values.gateway.https -}}
505-
{{- else -}}
506-
{{- default (ternary "443" "80" .Values.ingress.https) .Values.ingress.port -}}
507-
{{- end -}}
508-
{{- end -}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../common_templates

src/main/charts/bamboo/templates/configmap-server-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ data:
3232
protocol="{{ .Values.bamboo.tomcatConfig.protocol | default "HTTP/1.1" }}"
3333
redirectPort="{{ .Values.bamboo.tomcatConfig.redirectPort | default "8443" }}"
3434
acceptCount="{{ .Values.bamboo.tomcatConfig.acceptCount | default "100" }}"
35-
secure="{{ default (ternary "true" "false" (eq (include "bamboo.https" . | trim) "true")) .Values.bamboo.tomcatConfig.secure }}"
36-
scheme="{{ default (ternary "https" "http" (eq (include "bamboo.https" . | trim) "true")) .Values.bamboo.tomcatConfig.scheme }}"
37-
proxyName="{{ .Values.bamboo.tomcatConfig.proxyName | default (include "bamboo.hostname" .) }}"
38-
proxyPort="{{ .Values.bamboo.tomcatConfig.proxyPort | default (include "bamboo.proxyPort" .) }}"
35+
secure="{{ default (include "common.gateway.https" .) .Values.bamboo.tomcatConfig.secure }}"
36+
scheme="{{ default (include "common.gateway.scheme" .) .Values.bamboo.tomcatConfig.scheme }}"
37+
proxyName="{{ .Values.bamboo.tomcatConfig.proxyName | default (include "common.gateway.hostname" .) }}"
38+
proxyPort="{{ .Values.bamboo.tomcatConfig.proxyPort | default (include "common.gateway.externalPort" .) }}"
3939

4040
{{- if .Values.bamboo.tomcatConfig.address }}
4141
address="{{ .Values.bamboo.tomcatConfig.address }}"

src/main/charts/bamboo/templates/httproute.yaml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
{{- if .Values.gateway.create }}
2-
{{- if .Values.ingress.create }}
3-
{{- fail "Cannot enable both gateway.create and ingress.create. Please set one to false." }}
4-
{{- end }}
5-
{{- if not .Values.gateway.gatewayName }}
6-
{{- fail "gateway.gatewayName is required when gateway.create is true" }}
7-
{{- end }}
8-
{{- if not .Values.gateway.hostnames }}
9-
{{- fail "gateway.hostnames is required when gateway.create is true. Provide at least one hostname." }}
10-
{{- end }}
2+
{{- include "common.gateway.validateConfig" . -}}
113
apiVersion: gateway.networking.k8s.io/v1
124
kind: HTTPRoute
135
metadata:

src/main/charts/bamboo/templates/statefulset.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- include "bamboo.validateGatewayConfig" . -}}
1+
{{- include "common.gateway.validateConfig" . -}}
22
apiVersion: apps/v1
33
kind: StatefulSet
44
metadata:
@@ -118,7 +118,7 @@ spec:
118118
image: {{ include "bamboo.image" . | quote }}
119119
imagePullPolicy: {{ .Values.image.pullPolicy }}
120120
env:
121-
{{ if eq (include "bamboo.https" . | trim) "true" }}
121+
{{ if eq (include "common.gateway.https" .) "true" }}
122122
- name: ATL_TOMCAT_SCHEME
123123
value: "https"
124124
- name: ATL_TOMCAT_SECURE
@@ -132,11 +132,11 @@ spec:
132132
{{ end }}
133133
- name: ATL_TOMCAT_PORT
134134
value: {{ .Values.bamboo.ports.http | quote }}
135-
{{ if or .Values.ingress.host .Values.gateway.create }}
135+
{{ if eq (include "common.gateway.isConfigured" .) "true" }}
136136
- name: ATL_PROXY_NAME
137-
value: {{ include "bamboo.hostname" . | quote }}
137+
value: {{ include "common.gateway.hostname" . | quote }}
138138
- name: ATL_PROXY_PORT
139-
value: {{ include "bamboo.proxyPort" . | quote }}
139+
value: {{ include "common.gateway.externalPort" . | quote }}
140140
{{ end }}
141141
{{- include "bamboo.databaseEnvVars" . | nindent 12 }}
142142
- name: SET_PERMISSIONS

src/main/charts/bamboo/values.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,18 @@ gateway:
484484
# - bamboo.example.com
485485
# - ci.example.com
486486

487-
# -- Set to 'true' if browser communication with the application should be TLS
488-
# (HTTPS) enforced. This affects the service URL and proxy port configuration.
487+
# -- Whether users access the application over HTTPS. This does NOT configure TLS
488+
# on the Gateway itself — it tells the application to generate https:// URLs and
489+
# set Tomcat's secure flag. Set this to match your actual Gateway/load balancer TLS config.
489490
#
490491
https: true
491492

493+
# -- The external port the application is accessed on. Defaults to 443 (https) or 80 (http).
494+
# This does NOT configure the Gateway itself — it tells the application which port users connect on,
495+
# so it generates correct URLs. Set this to match your actual Gateway/load balancer port.
496+
#
497+
# externalPort:
498+
492499
# -- The base path for routing. Defaults to "/" to route all paths.
493500
#
494501
path: "/"

0 commit comments

Comments
 (0)