Helm


Matt Fisher <matt.fisher@...>
 

In your example, you are passing a variable of type string ("need value") to your function "mypath". Inside your "mypath" function,. it's looking for an object with a field called Values.

If you change your `include` function call to {{ include "mypath" $ }}, what happens?

1504220459230_microsoft.png

Matthew Fisher

Caffeinated Software Engineer

Microsoft Canada


From: cncf-helm@... <cncf-helm@...> on behalf of lmadan via Lists.Cncf.Io <lmadan=alumni.usc.edu@...>
Sent: Thursday, March 19, 2020 2:57 PM
To: cncf-helm@... <cncf-helm@...>
Cc: cncf-helm@... <cncf-helm@...>
Subject: [cncf-helm] Helm
 
Hi all, i have a quick question. I have the chart hierarchyparentChart
— template
— _helpers.tpl— charts
— chart1
—template
— _helpers.tpl
— chart2In 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.


Matt Fisher <matt.fisher@...>
 

In other words, you are passing a function a string when it expected an object. If you change your function call to the type it expects, that should solve your error.

1504220459230_microsoft.png

Matthew Fisher

Caffeinated Software Engineer

Microsoft Canada


From: Matt Fisher <Matt.Fisher@...>
Sent: Friday, March 20, 2020 9:09 AM
To: cncf-helm@... <cncf-helm@...>; lmadan@... <lmadan@...>
Subject: Re: [cncf-helm] Helm
 
In your example, you are passing a variable of type string ("need value") to your function "mypath". Inside your "mypath" function,. it's looking for an object with a field called Values.

If you change your `include` function call to {{ include "mypath" $ }}, what happens?

1504220459230_microsoft.png

Matthew Fisher

Caffeinated Software Engineer

Microsoft Canada


From: cncf-helm@... <cncf-helm@...> on behalf of lmadan via Lists.Cncf.Io <lmadan=alumni.usc.edu@...>
Sent: Thursday, March 19, 2020 2:57 PM
To: cncf-helm@... <cncf-helm@...>
Cc: cncf-helm@... <cncf-helm@...>
Subject: [cncf-helm] Helm
 
Hi all, i have a quick question. I have the chart hierarchyparentChart
— template
— _helpers.tpl— charts
— chart1
—template
— _helpers.tpl
— chart2In 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.


lmadan@...
 

Thanks Matthew, for your response.

I don't believe the problem is with type. I tried with $, but getting the null pointer exception. <.Values.common >: nil pointer evaluating interface {}.mypath. I believe there's some scoping issues or some hidden bug, because if i remove the sub charts then parent chart is able to resolve the value, but if i have the sub charts then it barfs about the issue.

Regards,
Lokesh