Topics

Helm : referencing the parent template field in sub chart.


lmadan@...
 
Edited

Hi all, i have a quick question. I have the chart
hierarchy

-- parentChart
  -- template
    -- _helpers.tpl— charts
  -- charts
    -- chart1
      -- template
        -- _helpers.tpl
    --  chart2
       -- template
         -- _helpers.tpl

Values.yaml in parentChart has
 global:
   somekey: values
   someotherpath: someValue

  common:
    mypath: someValue
    someMoreKeys: andSomeMoreValues

In parent chart i have defined
{{- define “mypath" -}}
{{- if .Values.common -}}
{{- required "common.mypath is required !" .Values.common.mypath -}}
{{- else -}}
{{- required ".Values.global.someotherpath is required !" .Values.global.someotherpath}}
{{- end -}}
{{- end -}}And now in chart1 i am trying to refer{{- define "mypath" }}
from: parentChart
{{- end -}}{{- define “copyMyPath” -}}
{{- include "mypath" "need value"}}
{{- end -}}I am getting below errortemplate: parentChart/charts/chart1/templates/deployment.yaml:37:20: executing “parentChart/charts/chart1/templates/deployment.yaml" at <include “copyMyPath” .>: error calling include: template: parentChart/charts/chart1/templates/_helpers.tpl:43:4: executing “copyMyPath" at <include “mypath” "need value">: error calling include: template: parentChart/templates/_helpers.tpl:112:14: executing “mypath” at <.Values.common>: can't evaluate field Values in type string

Am i missing something ?

Idea is i want to refer what's defined in parent chart template

Any help on this really appreciated


I posted the message the message on #helm-users slack channel, but haven't got any response.