My helmfile release uses the values template values.yaml.gotmpl, which contains the following
licenseData: {{ .Files.Get "license.bin" | b64enc }}
The intent is that this reads the binary file and makes it available to the Helm Chart.
The Helm Chart uses this value in a ConfigMap as follows:
binaryData:
license.bin: {{ .Values.licenseData }}
And then mounts the ConfigMap onto a path in a container. So then the container reads the "license.bin" file specified by the Helmfile.
But when I run "helmfile sync" I get the following error
in ./helmfile.yaml: failed processing release my-release: failed to render values files "values.yaml.gotmpl": failed to render [values.yaml.gotmpl], because of template: stringTemplate:14:24: executing "stringTemplate" at <.Files.Get>: can't evaluate field Files in type state.EnvironmentTemplateData
Am I allowed to use Files.Get and Files.Glob in a Helmfile values template just like I am from a template in the Helm Chart?
@smeierhofer Hey! Files.Get nor Fields.Glob don't exist in helmfile. But {{ readFile "license.bin" | b64enc }} should work.
Hey mumoshu. Thanks much for the solution!
I want to do something similar with Files.Glob and the tpl function. I want the following in a values template referenced by a Helmfile release:
configData:
{{ (tpl (.Files.Glob "config/*").AsConfig . ) | indent 2 }}
And the Helm Chart defines a ConfigMap with the following:
data:
{{ toYaml .Values.configData | indent 2 }}
The ConfigMap is mounted into a container which makes all the config files specified by the Helmfile release available to the container. The container reads the config files to determine its configuration.
FYI, the reason to use the tpl function is because I want to use Go Template syntax the config files to include other files as a way to re-use some portions of those config across releases.
@smeierhofer Sounds great! Would you mind creating a dedicated feature request for that?
Also, probably it would be nicer to name readFile to .Files.Get so that it will be consistent with .Files.Glob
I created an issue #761 but not sure how to label it as a feature request.
Closed issue as I have created the feature request.