Skip to content

Commit

Permalink
Be able to override a configmap name in a volume
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Sep 11, 2024
1 parent 906008f commit af34e2d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ volumes:
{{- else if eq ( default "self" $value.configMap.name ) "self-metadata" }}
name: {{ include "common.fullname" ( dict "root" $root "service" $root.Values "serviceName" "metadata" ) }}
{{- else }}
name: {{ $value.configMap.name }}
name: {{ default $value.configMap.name ( get $root.Values.global.configMapNameOverride $value.configMap.name ) | quote }}
{{- end }}
{{- with $value.configMap.items }}
items: {{- . | toYaml | nindent 6 }}
Expand Down
8 changes: 8 additions & 0 deletions tests/expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,9 @@ spec:
port: http

volumes:
- name: config-map-override
configMap:
name: "test-overridden"
- name: my-device-volume
persistentVolumeClaim:
claimName: pvc-name
Expand Down Expand Up @@ -1014,6 +1017,11 @@ spec:
image: "camptocamp/image:latest"
imagePullPolicy: IfNotPresent
env:
- name: "CONFIG_MAP_OVERRIDE"
valueFrom:
configMapKeyRef:
name: "test-overridden"
key: "testSingleLine"
- name: "SELF_CONFIGMAP"
valueFrom:
configMapKeyRef:
Expand Down
11 changes: 11 additions & 0 deletions tests/values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
global:
configMapNameOverride:
test-override: test-overridden

metadata:
enabled: true

Expand Down Expand Up @@ -250,6 +254,9 @@ services:
items:
- key: hostname
path: hostname.txt
config-map-override:
configMap:
name: test-override

service: &servicedefinition
type: ClusterIP
Expand Down Expand Up @@ -571,3 +578,7 @@ services:
type: secret
name: self-external-secret-app
key: hostname
CONFIG_MAP_OVERRIDE:
type: configMap
name: test-override
key: testSingleLine

0 comments on commit af34e2d

Please sign in to comment.