问题描述
这是values.yaml文件.它包含以下内容,当我尝试将其放入_helper.tpl时,我会立即获取Helm template failed. Error: render error in "windows/templates/ingresses/windows.yaml": template: windows/templates/_helpers.tpl:38:18: executing "windows.certificate" at <.Values.ingress.enab...>: can't evaluate field ingress in type interface {} : exit status 1
This is values.yaml file. It contains the following and when I am trying to get it into _helper.tpl im getting Helm template failed. Error: render error in "windows/templates/ingresses/windows.yaml": template: windows/templates/_helpers.tpl:38:18: executing "windows.certificate" at <.Values.ingress.enab...>: can't evaluate field ingress in type interface {} : exit status 1
values.yaml
ingress:
enabled: true
tls: true
certificate: ''
issuer:
name: letsencrypt-staging
hosts:
windows:
- name: ''
path: /
_helpers.tpl
{{/*
Calculate certificate
*/}}
{{- define "windows.certificate" }}
{{- printf .Values.ingress.enabled }} // error line is this. line no 38
{{- end }}
在windows.yaml中
- secretName: {{ template "windows.certificate" . }} // calling the helper method.
推荐答案
问题是缩进尝试
values.yaml
ingress:
enabled: true
tls: true
certificate: ''
issuer:
name: letsencrypt-staging
hosts:
windows:
- name: ''
path: /
在辅助程序上也进行了一些更改,以控制定义块的输出
Also some changes on the helpers to control the output of the define block
_helpers.tpl
{{/*
Calculate certificate
*/}}
{{- define "windows.certificate" }}
{{- if .Values.ingress.enabled }}
{{- printf .Values.ingress.certificate }}
{{- end }}
{{- end }}
这篇关于如何在头盔图表中从values.yaml到_helpers.tpl获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!