From 6eba84cf169d8239fb9f666aa6ceff86b992bb2a Mon Sep 17 00:00:00 2001 From: jbeemster Date: Thu, 25 Aug 2022 10:00:31 +0200 Subject: [PATCH] charts/service-deployment: Add ability to specify multiple files per config-map (closes #49) --- charts/service-deployment/Chart.yaml | 2 +- charts/service-deployment/templates/configmaps.yaml | 8 +++++++- charts/service-deployment/templates/deployment.yaml | 8 +++++++- charts/service-deployment/values.yaml | 6 ++++-- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/charts/service-deployment/Chart.yaml b/charts/service-deployment/Chart.yaml index 382b59d..a47b480 100644 --- a/charts/service-deployment/Chart.yaml +++ b/charts/service-deployment/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v2 name: service-deployment description: A Helm Chart to setup a generic deployment with optional service/hpa bindings -version: 0.1.3 +version: 0.2.0 icon: https://raw.githubusercontent.com/snowplow-devops/helm-charts/master/docs/logo/snowplow.png home: https://github.com/snowplow-devops/helm-charts sources: diff --git a/charts/service-deployment/templates/configmaps.yaml b/charts/service-deployment/templates/configmaps.yaml index d58b719..41d6907 100644 --- a/charts/service-deployment/templates/configmaps.yaml +++ b/charts/service-deployment/templates/configmaps.yaml @@ -5,7 +5,13 @@ kind: ConfigMap metadata: name: {{ $v.name }} binaryData: - {{ $v.key }}: "{{ $v.contentsB64 }}" + {{- range $f := $v.files }} + {{- if $f.contentsB64 }} + {{ $f.key }}: "{{ $f.contentsB64 }}" + {{- else }} + {{ $f.key }}: "{{ ($.Files.Get $f.contentsFile) | b64enc }}" + {{- end }} + {{- end }} --- {{- end }} {{- end }} diff --git a/charts/service-deployment/templates/deployment.yaml b/charts/service-deployment/templates/deployment.yaml index 7457422..25f3242 100644 --- a/charts/service-deployment/templates/deployment.yaml +++ b/charts/service-deployment/templates/deployment.yaml @@ -13,7 +13,13 @@ spec: annotations: {{- if .Values.configMaps }} {{- range $v := .Values.configMaps }} - checksum/{{ $v.name }}-{{ $v.key }}: "{{ $v.contentsB64 | sha256sum }}" + {{- range $f := $v.files }} + {{- if $f.contentsB64 }} + checksum/{{ $v.name }}-{{ $f.key }}: "{{ $f.contentsB64 | sha256sum }}" + {{- else }} + checksum/{{ $v.name }}-{{ $f.key }}: "{{ ($.Files.Get $f.contentsFile) | b64enc | sha256sum }}" + {{- end }} + {{- end }} {{- end }} {{- end }} spec: diff --git a/charts/service-deployment/values.yaml b/charts/service-deployment/values.yaml index 456d878..54c247d 100644 --- a/charts/service-deployment/values.yaml +++ b/charts/service-deployment/values.yaml @@ -31,10 +31,12 @@ config: # -- List of config maps to mount to the deployment configMaps: [] # - name: "volume-1" -# key: "file.cfg" -# contentsB64: "" # The file contents which have already been base-64 encoded # mountPath: "/etc/config" # Must be unique # mountPropagation: None # If unset will default to 'None' +# files: [] +# - key: "file.cfg" # Key must be unique for each file +# contentsB64: "" # The file contents which have already been base-64 encoded +# contentsFile: "" # The path to a local file (note: contentsB64 will take precedence if not-empty) # -- Map of resource constraints for the service resources: {}