I am trying to get some values from Umbrella chart in helm in _helpers.tpl
but I for some reason I am getting the error executing "gluu.ldaplist" at <.Values.ldap.extraHo...>: can't evaluate field extraHosts in type interface {}
This is what I am trying to do.
_helpers.ptl
{{- define "gluu.ldaplist" -}}
{{- $hosts := .Values.ldap.extraHosts -}}
{{- $genLdap := dict "host" (printf "%s-%s" .Release.Name .Values.ldapType) "port" .Values.ldapPort -}}
{{- $hosts := prepend $hosts $genLdap -}}
{{- $local := dict "first" true -}}
{{- range $k, $v := $hosts -}}
{{- if not $local.first -}},{{- end -}}{{- printf "%s:%.f" $v.host $v.port -}}{{- $_ := set $local "first" false -}}
{{- end -}}
{{- end -}}
And this is part of values.yml
for the umbrella chart
values.yml
ldap:
enabled: true
type: opendj
extraHosts: [
host: opendj,
port: 3434
] #array of k,v e.g host: host1, port: port1
Directory structure
helm/
charts/
chart_a/
templates/
configMap.yml ----->>> this is where I want to use it
templates/
_helpers.tpl ---->>>> where the failing function is
requirements.yml
values.yml ---------->>> where the ldap values are
The configMap.yml
looks like below
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "oxauth.fullname" . }}-cm
data:
GLUU_CONFIG_ADAPTER: {{ .Values.global.configAdapterName | quote }}
GLUU_LDAP_URL: {{ template "gluu.ldaplist" . }}
NOTE: The _helpers.tpl
is under the main/umbrella chart. chart_a
is a subchart.
Expected results are something like GLUU_LDAP_URL:"opendj:3434"
Helm version:
Client: &version.Version{SemVer:"v2.10.0", GitCommit:"9ad53aac42165a5fadc6c87be0dea6b115f93090", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.10.0", GitCommit:"9ad53aac42165a5fadc6c87be0dea6b115f93090", GitTreeState:"clean"}
Expected result is that the function {{- define "gluu.ldaplist" -}}
in _helpers.tpl
completes without error even if no values are provided in the array.
If there are values provided, the expected string is host:port
as output.
If this can be done in another way, I welcome any suggestion.