Skip to content

Commit

Permalink
Add defaultMode to additionalConfigMaps (#647)
Browse files Browse the repository at this point in the history
Co-authored-by: Yevhen Ivantsov <[email protected]>
  • Loading branch information
bianchi2 and Yevhen Ivantsov authored Aug 21, 2023
1 parent 804005b commit 203a119
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/charts/bamboo/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ spec:
- name: {{ .fileName | replace "_" "-" | replace "." "-" }}
configMap:
name: {{ include "common.names.fullname" $ }}-{{ $key.name }}
{{- if .defaultMode }}
defaultMode: {{ .defaultMode }}
{{- end }}
items:
- key: {{ .fileName }}
path: {{ .fileName }}
Expand Down
1 change: 1 addition & 0 deletions src/main/charts/bamboo/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,7 @@ additionalConfigMaps: []
# keys:
# - fileName: hello.properties
# mountPath: /opt/atlassian/jira/atlassian-jira/WEB-INF/classes
# defaultMode:
# content: |
# foo=bar
# hello=world
Expand Down
3 changes: 3 additions & 0 deletions src/main/charts/bitbucket/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ spec:
- name: {{ .fileName | replace "_" "-" | replace "." "-" }}
configMap:
name: {{ include "common.names.fullname" $ }}-{{ $key.name }}
{{- if .defaultMode }}
defaultMode: {{ .defaultMode }}
{{- end }}
items:
- key: {{ .fileName }}
path: {{ .fileName }}
Expand Down
1 change: 1 addition & 0 deletions src/main/charts/bitbucket/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,7 @@ additionalConfigMaps: []
# keys:
# - fileName: hello.properties
# mountPath: /opt/atlassian/jira/atlassian-jira/WEB-INF/classes
# defaultMode:
# content: |
# foo=bar
# hello=world
Expand Down
3 changes: 3 additions & 0 deletions src/main/charts/confluence/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ spec:
- name: {{ .fileName | replace "_" "-" | replace "." "-" }}
configMap:
name: {{ include "common.names.fullname" $ }}-{{ $key.name }}
{{- if .defaultMode }}
defaultMode: {{ .defaultMode }}
{{- end }}
items:
- key: {{ .fileName }}
path: {{ .fileName }}
Expand Down
1 change: 1 addition & 0 deletions src/main/charts/confluence/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,7 @@ additionalConfigMaps: []
# keys:
# - fileName: hello.properties
# mountPath: /opt/atlassian/jira/atlassian-jira/WEB-INF/classes
# defaultMode:
# content: |
# foo=bar
# hello=world
Expand Down
3 changes: 3 additions & 0 deletions src/main/charts/crowd/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ spec:
- name: {{ .fileName | replace "_" "-" | replace "." "-" }}
configMap:
name: {{ include "common.names.fullname" $ }}-{{ $key.name }}
{{- if .defaultMode }}
defaultMode: {{ .defaultMode }}
{{- end }}
items:
- key: {{ .fileName }}
path: {{ .fileName }}
Expand Down
1 change: 1 addition & 0 deletions src/main/charts/crowd/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,7 @@ additionalConfigMaps: []
# keys:
# - fileName: hello.properties
# mountPath: /opt/atlassian/jira/atlassian-jira/WEB-INF/classes
# defaultMode:
# content: |
# foo=bar
# hello=world
Expand Down
3 changes: 3 additions & 0 deletions src/main/charts/jira/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ spec:
- name: {{ .fileName | replace "_" "-" | replace "." "-" }}
configMap:
name: {{ include "common.names.fullname" $ }}-{{ $key.name }}
{{- if .defaultMode }}
defaultMode: {{ .defaultMode }}
{{- end }}
items:
- key: {{ .fileName }}
path: {{ .fileName }}
Expand Down
2 changes: 2 additions & 0 deletions src/main/charts/jira/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1041,11 +1041,13 @@ additionalConfigMaps: []
# keys:
# - fileName: hello.properties
# mountPath: /opt/atlassian/jira/atlassian-jira/WEB-INF/classes
# defaultMode:
# content: |
# foo=bar
# hello=world
# - fileName: hello.xml
# mountPath: /opt/atlassian/jira/atlassian-jira/WEB-INF/classes
# defaultMode:
# content: |
# <xml>
# </xml>
21 changes: 21 additions & 0 deletions src/test/java/test/AdditionalConfigMapsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,31 @@ void additional_configmap_volumes(Product product) throws Exception {

JsonNode configMapVolume = getStsVolume(statefulset, "configMap");
assertThat(configMapVolume.path("name")).hasTextEqualTo(product.getHelmReleaseName() + "-extra-configmap");
assertThat(configMapVolume.path("defaultMode")).isEmpty();
assertThat(configMapVolume.path("items").path(0).path("key")).hasTextEqualTo("hello.txt");
assertThat(configMapVolume.path("items").path(0).path("path")).hasTextEqualTo("hello.txt");
}

@ParameterizedTest
@EnumSource(value = Product.class, names = {"bamboo_agent"}, mode = EnumSource.Mode.EXCLUDE)
void additional_configmap_volumes_default_mode(Product product) throws Exception {
final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of(
"additionalConfigMaps[0].name", "extra-configmap",
"additionalConfigMaps[0].keys[0].defaultMode", "487",
"additionalConfigMaps[0].keys[0].fileName", "hello.txt",
"additionalConfigMaps[0].keys[0].mountPath", "/opt/files",
"additionalConfigMaps[0].keys[0].content", "helloworld"
));

StatefulSet statefulset = resources.getStatefulSet(product.getHelmReleaseName());
assertThat(statefulset.getVolumes().get(0).get("name")).hasTextEqualTo("hello-txt");

JsonNode configMapVolume = getStsVolume(statefulset, "configMap");
assertThat(configMapVolume.path("name")).hasTextEqualTo(product.getHelmReleaseName() + "-extra-configmap");
assertThat(configMapVolume.path("defaultMode")).hasValueEqualTo(487);
assertThat(configMapVolume.path("items").path(0).path("key")).hasTextEqualTo("hello.txt");
assertThat(configMapVolume.path("items").path(0).path("path")).hasTextEqualTo("hello.txt");
}
@ParameterizedTest
@EnumSource(value = Product.class, names = {"bamboo_agent"}, mode = EnumSource.Mode.EXCLUDE)
void additional_configmap_volume_mounts(Product product) throws Exception {
Expand Down

0 comments on commit 203a119

Please sign in to comment.