Skip to content

Commit

Permalink
wip(charts): added common.secret.fromFolder
Browse files Browse the repository at this point in the history
  • Loading branch information
robinbourianes-kalisio committed Feb 16, 2022
1 parent 3e2cfb8 commit c17fe69
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions charts/common/templates/_secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,23 @@ data:
{{ $key }}: {{ include "common.tplvalues.render" (dict "value" $val "context" $) | b64enc }}
{{- 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.secret.fromFolder" -}}
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 }}
{{- end }}
{{- end -}}

0 comments on commit c17fe69

Please sign in to comment.