Helm: Usage of definitions across files

1 min read

Sometimes writting helm charts can be very challenging due to the weird errors we might get:

<sha256sum>: wrong type for value; expected string; got chartutil.Values

This specific error can be triggered when we are using a definition as part of another definition that it's not defined on the same file. For exemple, if we create a file named _example.tpl with the following:

{{- define "clouddriverconfig" }}
sha256: {{ include "pet2cattle.name" . | sha256sum }}
{{- end }}

Since the pet2cattle.name is (typically) defined on the _helpers.tpl file, it won't work trowing this error. If we cannot move the definition to the other file for some reason we can always copy the definition with another name or just "include" onw into the other:

sha256:  {{ default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" | sha256sum }}

Posted on 26/11/2021

Categories