Skip to content

Commit

Permalink
Modify ExtraObjects to be more flexible
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Pais <[email protected]>
  • Loading branch information
Nickmman committed Aug 21, 2023
1 parent 5990e81 commit c786594
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions charts/opensearch/templates/extraManifests.yaml
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 }}

0 comments on commit c786594

Please sign in to comment.