technosophos / common-chart

A base Helm chart with shared definitions
https://technosophos.github.io/common-chart/
Other
97 stars 16 forks source link

can't evaluate field Release in type []interface {} #5

Open cch0 opened 6 years ago

cch0 commented 6 years ago

This is what I did.

1. Followed the instruction to create a new chart

helm create mychart

2. add common

cd mychart/charts helm fetch common/common

Note that the last command (helm fetch) is different from what is described in the instruction. If I used helm fetch common I then got Error: Non-absolute URLs should be in form of repo_name/path_to_chart, got: common

3. add a some.yaml file under mychart/templates/

{{- template "common.deployment" (list . "mychart.deployment") -}}
{{- define "mychart.deployment" -}}
## Define overrides for your Deployment resource here, e.g.
spec:
  template:
    spec:
      containers:
      - {{ template "common.container" (list . "mychart.deployment.container") }}
{{- end -}}
{{- define "mychart.deployment.container" -}}
## Define overrides for your Container here, e.g.
livenessProbe:
  httpGet:
    path: /
    port: 80
readinessProbe:
  httpGet:
    path: /
    port: 80
{{- end -}}

4. ran this command

helm template --name myrelease mychart

and then got Error: render error in "mychart/templates/some.yaml": template: mychart/charts/common/templates/_common.tpl:17:27: executing "common.fullname" at <.Release.Name>: can't evaluate field Release in type []interface {}

Question:

Where did I do wrong?

prydonius commented 6 years ago

@cch0 does helm install --name myrelease --dry-run --debug mychart work for you? Also what version of Helm do you have?

cch0 commented 6 years ago

helm install --name myrelease --dry-run --debug mychart


[debug] Created tunnel using local port: '62377'

[debug] SERVER: "127.0.0.1:62377"

[debug] Original chart version: ""
[debug] CHART PATH: /Users/xxx/playground/tmp/mychart

Error: render error in "mychart/templates/some.yaml": template: mychart/charts/common/templates/_common.tpl:17:27: executing "common.fullname" at <.Release.Name>: can't evaluate field Release in type []interface {}

Helm version

Client: &version.Version{SemVer:"v2.10.0", GitCommit:"9ad53aac42165a5fadc6c87be0dea6b115f93090", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.10.0", GitCommit:"9ad53aac42165a5fadc6c87be0dea6b115f93090", GitTreeState:"clean"}
prydonius commented 6 years ago

hmm, I'm not sure why .Release would be empty. @bacongobbler have you seen this before?

bacongobbler commented 6 years ago

Can't say that I have, no :S

cfedersp commented 5 years ago

I'm also using that version of Helm, 2.10.0 and when I use {{ .Release.Name }} in a particular spot, I get a similar error: executing "demo/templates/ingress.yaml" at <.Release.Name>: can't evaluate field Name in type interface {}

Had to work around it by defining $releaseName at the top of the file and using that instead: {{- $releaseName := .Release.Name -}}

LucidNeko commented 5 years ago

@cfedersp $ let's you reference values in the parent scope: {{ $.Release.Name }}