Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when values template uses Files.Get to read a file #757

Closed
smeierhofer opened this issue Jul 16, 2019 · 6 comments
Closed

Error when values template uses Files.Get to read a file #757

smeierhofer opened this issue Jul 16, 2019 · 6 comments
Labels

Comments

@smeierhofer
Copy link

smeierhofer commented Jul 16, 2019

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?

@mumoshu
Copy link
Collaborator

mumoshu commented Jul 16, 2019

@smeierhofer Hey! Files.Get nor Fields.Glob don't exist in helmfile. But {{ readFile "license.bin" | b64enc }} should work.

@smeierhofer
Copy link
Author

smeierhofer commented Jul 17, 2019

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.

@mumoshu
Copy link
Collaborator

mumoshu commented Jul 18, 2019

@smeierhofer Sounds great! Would you mind creating a dedicated feature request for that?

@mumoshu
Copy link
Collaborator

mumoshu commented Jul 18, 2019

Also, probably it would be nicer to name readFile to .Files.Get so that it will be consistent with .Files.Glob

@smeierhofer
Copy link
Author

I created an issue #761 but not sure how to label it as a feature request.

@smeierhofer
Copy link
Author

Closed issue as I have created the feature request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants