helm templates with helpers dont reconigze .Values
16:10 29 Jan 2025

i get errors using a template with one parameter, no .Values is recognized inside the template on _helpers.tpl, but only inside define "mychart.virtualserver" section. Another sections with out get paremeters works well with .Values, any solution?

configmap.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-virtual-servers
data:
  default.conf: |
      {{- include "mychart.virtualserver"  (dict "subdomain" "domain") | nindent 6 }}

_helpers.tpl

{{- define "mychart.virtualserver" -}}
{{- $subdomain := .subdomain | default "domain" }}
{{ .Values.domain}};
{{- end -}}

values.yaml

domain: devazure.peruprop.com

i get this error:

Error: template: mychart/templates/nginx-virtual-servers.yaml:7:10: executing "mychart/templates/nginx-virtual-servers.yaml" at : error calling include: template: mychart/templates/_helpers.tpl:85:10: executing "mychart.virtualserver" at <.Values.domain>: nil pointer evaluating interface {}.domain
helm.go:86: 2025-01-29 20:26:05.484493 +0100 CET m=+0.105932542 [debug] template: mychart/templates/nginx-virtual-servers.yaml:7:10: executing "mychart/templates/nginx-virtual-servers.yaml" at : error calling include: template: mychart/templates/_helpers.tpl:85:10: executing "mychart.virtualserver" at <.Values.domain>: nil pointer evaluating interface {}.domain
kubernetes-helm