Last active
September 4, 2020 22:01
-
-
Save mill5james/54c366207de891bcd24e25c7cc85b658 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{/* | |
Convert YAML to envirment variables for .NET Core hosting environment naming | |
*/}} | |
{{- define "translateEnv" -}} | |
{{- range $key, $value := . }} | |
{{- if or (kindIs "map" $value) (kindIs "slice" $value) }} | |
{{- include "prefixItem" (dict $key $value) }} | |
{{- else }} | |
- name: {{ $key }} | |
value: {{ $value | squote }} | |
{{- end }} | |
{{- end }} | |
{{- end }} | |
{{/* | |
Used by the translateEnv template. | |
Expects a dict as a parameter where the key is the prefix and the value is the map to iterate over | |
*/}} | |
{{- define "prefixItem" -}} | |
{{- range $prefix, $map := . }} | |
{{- range $key, $value := $map }} | |
{{- if or (kindIs "map" $value) (kindIs "slice" $value) }} | |
{{- include "prefixItem" (dict (printf "%v__%v" $prefix $key) $value) }} | |
{{- else }} | |
- name: {{printf "%v__%v" $prefix $key }} | |
value: {{ $value | squote }} | |
{{- end }} | |
{{- end }} | |
{{- end }} | |
{{- end }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment