<p>I am trying to get some values from Umbrella chart in helm in <code>_helpers.tpl</code> but I for some reason I am getting the error <code>executing "gluu.ldaplist" at &lt;.Values.ldap.extraHo...&gt;: can't evaluate field extraHosts in type interface {}</code></p>

<p>This is what I am trying to do.
<code>_helpers.ptl</code></p>

<pre><code>{{- 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 -}}
</code></pre>

<p>And this is part of <code>values.yml</code> for the umbrella chart
<code>values.yml</code></p>

<pre><code>ldap:
  enabled: true
  type: opendj
  extraHosts: [
    host: opendj,
    port: 3434
  ] #array of k,v e.g host: host1, port: port1
</code></pre>

<p>Directory structure</p>

<pre><code>helm/
  charts/
     chart_a/
       templates/
          configMap.yml -----&gt;&gt;&gt; this is where I want to use it
  templates/
     _helpers.tpl ----&gt;&gt;&gt;&gt; where the failing function is
  requirements.yml
  values.yml ----------&gt;&gt;&gt; where the ldap values are

</code></pre>

<p>The <code>configMap.yml</code> looks like below</p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ template "oxauth.fullname" . }}-cm
data:
  GLUU_CONFIG_ADAPTER: {{ .Values.global.configAdapterName | quote }}
  GLUU_LDAP_URL: {{ template "gluu.ldaplist" . }}
</code></pre>

<p>NOTE: The <code>_helpers.tpl</code> is under the main/umbrella chart. <code>chart_a</code> is a subchart.</p>

<p>Expected results are something like <code>GLUU_LDAP_URL:"opendj:3434"</code></p>

<p>Helm version:  </p>

<pre><code>Client: &amp;version.Version{SemVer:"v2.10.0", GitCommit:"9ad53aac42165a5fadc6c87be0dea6b115f93090", GitTreeState:"clean"}
Server: &amp;version.Version{SemVer:"v2.10.0", GitCommit:"9ad53aac42165a5fadc6c87be0dea6b115f93090", GitTreeState:"clean"}
</code></pre>

<p>Expected result is that the function <code>{{- define "gluu.ldaplist" -}}</code> in <code>_helpers.tpl</code> completes without error even if no values are provided in the array. 
If there are values provided, the expected string is <code>host:port</code> as output.</p>

<p>If this can be done in another way, I welcome any suggestion.</p>

Shammir
<p>This can be solved with global values which allow values in the parent chart to override (or supply unspecified) values in the child subcharts.</p>

<p>From the <a href="https://helm.sh/docs/chart_template_guide/#subcharts-and-global-values" rel="nofollow noreferrer">Helm docs on <em>Subcharts and Global Values</em></a>:</p>

<blockquote>
  <ol>
  <li>A subchart is considered “stand-alone”, which means a subchart can never explicitly depend on its parent chart.</li>
  <li>For that reason, <strong>a subchart cannot access the values of its parent</strong>.</li>
  <li>A parent chart can override values for subcharts.</li>
  <li><strong>Helm has a concept of <em>global values</em> that can be accessed by all charts</strong>.</li>
  </ol>
</blockquote>

<p>(At first I didn't think to search for "helm subchart" but once I did an Internet search for that term, this was the first or second result)</p>

<p>Here's a minimal example that solves your issue:</p>

<h3>Directory Structure</h3>

<pre><code>helm
├── Chart.yaml
├── charts
│   └── chart_a
│       ├── Chart.yaml
│       └── templates
│           └── configMap.yml
├── templates
│   └── _helpers.tpl
└── values.yaml
</code></pre>

<p>Note: I added <code>Chart.yaml</code> files to make it actually work, renamed <code>values.yml</code> to <code>values.yaml</code> so that it works by default without extra flags, and removed <code>requirements.yml</code> since it wasn't necessary to reproduce the problem and solution.</p>

<h3><code>values.yaml</code></h3>

<pre><code>global:
  ldap:
    enabled: true
    type: opendj
    extraHosts:
    - host: opendj
      port: 3434
  ldapType: xxx
  ldapPort: 123
</code></pre>

<p>The key was to nest what you had under a special <code>global</code> key. Note, I also added <code>ldapType</code> and <code>ldapPort</code> since they were in your <code>_helpers.tpl</code>, and I fixed the YAML structure you had under <code>extraHosts</code>. What was there before didn't actually represent a list of maps with <code>host</code> and <code>port</code> keys. Without this fix, the <code>helm</code> command doesn't fail but doesn't output what you want either.</p>

<h3>Result</h3>

<pre><code>$ helm template .
---
# Source: helm/charts/chart_a/templates/configMap.yml
apiVersion: v1
kind: ConfigMap
metadata:
  name: cm
data:
  GLUU_LDAP_URL: release-name-xxx:123,opendj:3434
</code></pre>
