Skip to content

Commit 75f03d7

Browse files
authored
Synchrony: support additional env vars (#1057)
* Support additional env vars in synchrony * Support additional env vars in synchrony * Support additional env vars in synchrony * Fix helm output test
1 parent 1733118 commit 75f03d7

File tree

5 files changed

+29
-0
lines changed

5 files changed

+29
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,15 @@ Define additional Synchrony volume mounts here to allow template overrides when
427427
{{- end }}
428428
{{- end }}
429429

430+
{{/*
431+
Define additional environment variables here to allow template overrides when used as a sub chart
432+
*/}}
433+
{{- define "synchrony.additionalEnvironmentVariables" -}}
434+
{{- with .Values.synchrony.additionalEnvironmentVariables }}
435+
{{- toYaml . }}
436+
{{- end }}
437+
{{- end }}
438+
430439
{{/*
431440
Define additional environment variables here to allow template overrides when used as a sub chart
432441
*/}}

src/main/charts/confluence/templates/statefulset-synchrony.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ spec:
139139
{{ end }}
140140
{{- include "synchrony.databaseEnvVars" . | nindent 12 }}
141141
{{- include "synchrony.clusteringEnvVars" . | nindent 12 }}
142+
{{- include "synchrony.additionalEnvironmentVariables" . | nindent 12 }}
142143
{{- if .Values.synchrony.nodeSelector }}
143144
nodeSelector:
144145
{{- toYaml .Values.synchrony.nodeSelector | nindent 8 }}

src/main/charts/confluence/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,9 @@ synchrony:
12571257
podAnnotations: {}
12581258
# name: <value>
12591259

1260+
# -- Additional environment variables passed to synchrony container
1261+
additionalEnvironmentVariables: []
1262+
12601263
# K8s Synchrony Service configuration
12611264
#
12621265
service:

src/test/java/test/ContainersTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,21 @@ void additionalEnvironmentVariables(Product product) throws Exception {
4040
env.assertHasValue("MY_ENV_VAR", "env-value");
4141
}
4242

43+
@ParameterizedTest
44+
@EnumSource(value = Product.class, names = {"confluence"}, mode = EnumSource.Mode.INCLUDE)
45+
void additionalSynchronyEnvironmentVariables(Product product) throws Exception {
46+
final var pname = product.name().toLowerCase();
47+
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of(
48+
"synchrony.enabled", "true",
49+
"synchrony.additionalEnvironmentVariables[0].name", "MY_ENV_VAR",
50+
"synchrony.additionalEnvironmentVariables[0].value", "env-value"
51+
));
52+
53+
final var statefulSet = resources.getStatefulSet(product.getHelmReleaseName() + "-synchrony");
54+
final var env = statefulSet.getContainer().getEnv();
55+
env.assertHasValue("MY_ENV_VAR", "env-value");
56+
}
57+
4358
@ParameterizedTest
4459
@EnumSource(value = Product.class, names = {"bamboo_agent"}, mode = EnumSource.Mode.EXCLUDE)
4560
void additionalPorts(Product product) throws Exception {

src/test/resources/expected_helm_output/confluence/output.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ data:
349349
securityContext: {}
350350
secretList: []
351351
secretName: null
352+
additionalEnvironmentVariables: []
352353
additionalJvmArgs: []
353354
additionalLibraries: []
354355
additionalPorts: []

0 commit comments

Comments
 (0)