Skip to content

Commit

Permalink
wip(charts): make configMap.fromFolder more like secret.fromFolder.
Browse files Browse the repository at this point in the history
  • Loading branch information
robinbourianes-kalisio committed Feb 16, 2022
1 parent c17fe69 commit 8f11206
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions charts/common/templates/_configMapFromFolder.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,19 @@
{{/*
Builds a config map from all the files in a folder. Files can be templated.
@parap .root The caller's root scope
@parap .context The caller's context
@param .name The name for the created config map
@param .folder The folder to scan to create the config map
*/}}
{{- define "common.configMapFromFolder" -}}
{{- define "common.configMap.fromFolder" -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .name }}
namespace: {{ .root.Release.Namespace }}
data:
{{- range $path, $_ := (.root.Files.Glob (printf "%s/*" .folder)) }}
{{ trimPrefix (printf "%s/" $.folder) $path }}: |
{{- tpl ($.root.Files.Get $path) $.root | nindent 4 }}
{{- end }}
{{- end -}}

{{/*
Builds a secret from all the files in a folder. Files can be templated.
@parap .context The caller's context
@param .name The name for the created secret
@param .folder The folder to scan to create the secret
*/}}
{{- define "common.secretFromFolder" -}}
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: {{ .name }}
namespace: {{ .context.Release.Namespace }}
data:
{{- range $path, $_ := (.context.Files.Glob (printf "%s/*" .folder)) }}
{{ trimPrefix (printf "%s/" $.folder) $path }}: |
{{- tpl ($.context.Files.Get $path) $.context | b64enc | nindent 4 }}
{{- tpl ($.context.Files.Get $path) $.context | nindent 4 }}
{{- end }}
{{- end -}}

0 comments on commit 8f11206

Please sign in to comment.