-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify ExtraObjects to be more flexible
Signed-off-by: Nicolas Pais <[email protected]>
- Loading branch information
Showing
1 changed file
with
18 additions
and
17 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,25 @@ | ||
{{- /* Define a recursive function to handle values */ -}} | ||
{{- define "handleValue" -}} | ||
{{- if typeIs "string" . -}} | ||
{{- . | quote -}} | ||
{{- else if typeIs "map[string]interface {}" . -}} | ||
{{- toYaml . | nindent 4 -}} | ||
{{- else if typeIs "array" . -}} | ||
{{- toYaml . | nindent 4 -}} | ||
{{- else -}} | ||
{{- . | quote -}} | ||
{{- end -}} | ||
{{- /* Define a recursive function to convert structured data to a plain string YAML */ -}} | ||
{{- define "structuredToPlainString" -}} | ||
{{- printf "%v" (toYaml . | trimSuffix "\n") -}} | ||
{{- end -}} | ||
|
||
{{- range .Values.extraObjects }} | ||
{{- range $objKey, $objValue := .Values.extraObjects }} | ||
--- | ||
{{- if typeIs "string" . -}} | ||
{{ tpl . $ }} | ||
{{- if and (eq $objValue.kind "Secret") (hasKey $objValue "stringData") }} | ||
apiVersion: v1 | ||
kind: Secret | ||
{{- range $key, $value := $objValue }} | ||
{{- if eq $key "stringData" }} | ||
stringData: | ||
{{- range $sdKey, $sdValue := $value }} | ||
{{ $sdKey }}: {{ include "structuredToPlainString" $sdValue }} | ||
{{- end }} | ||
{{- else }} | ||
{{- range $key, $value := . }} | ||
{{ $key }}: | ||
{{- include "handleValue" $value | nindent 2 -}} | ||
{{ $key }}: | ||
{{ toYaml $value | indent 2 }} | ||
{{- end }} | ||
{{- end }} | ||
{{- else }} | ||
{{ toYaml $objValue }} | ||
{{- end }} | ||
{{- end }} |