Heml check If nil pointer

3/2/2020

In my template to deploy an application i have the following:

{{- if .Values.application.rbac.enabled -}}
  serviceAccountName: service-account-cache
{{- else -}}

{{- end -}}

the point is that such file is used dynamically, I mean, I have several microservice that uses such files but algo when I use:

helm upgrade --install ${releaseName} -f ../folder/secrets/${env.appId}.yaml

depending on the microservive it also adds differents -f yaml file. Some of thems have

application:
  rbac:
    enabled: true

but another doesn't.

in those who don't have such additinal properties i have the following error:

<.Values.application.rbac.enabled>: nil pointer evaluating interface {}.enabled

because Values.application.rbac of course is not defined.

How can I do it so that additionally if it is not defined, do not do the if but no nil pointer occurs?

Thanks in advance

-- Gabriel GarcĂ­a Garrido
deployment
kubernetes-helm
null
nullpointerexception

0 Answers