Skip to content

Commit

Permalink
Merge pull request #223 from camptocamp/config-map-override
Browse files Browse the repository at this point in the history
Be able to override a configmap name in a volume
sbrunner authored Sep 11, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 906008f + af34e2d commit dd9bcee
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
@@ -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 }}
8 changes: 8 additions & 0 deletions tests/expected.yaml
Original file line number Diff line number Diff line change
@@ -630,6 +630,9 @@ spec:
port: http

volumes:
- name: config-map-override
configMap:
name: "test-overridden"
- name: my-device-volume
persistentVolumeClaim:
claimName: pvc-name
@@ -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:
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

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

service: &servicedefinition
type: ClusterIP
@@ -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 dd9bcee

Please sign in to comment.