helmfile icon indicating copy to clipboard operation
helmfile copied to clipboard

feat: add "fileExists" function

Open bitsofinfo opened this issue 6 years ago • 4 comments
trafficstars

I'm generating a list of additional values files for a release driven by some other dynamic configuration. I'd like to be able to detect existence of those files prior to declaring them in each release to avoid unexpected helm errors when the configured "extra value file" does not actually exist.

Would be great if we had a simple fileExists function available that could work like

{{ if fileExists $relativePath }}
...

somewhat related to #761

currently if I try to put some logic around readFile to hack an existence check its not possible as readfile throws errors on non-existence.

Right now I'm doing something like this: https://github.com/bitsofinfo/helmfile-deploy/blob/master/fileexists.sh https://github.com/bitsofinfo/helmfile-deploy/blob/25a339335765e0767d7251851503cdaa545b6bbf/conduits.helmfile.yaml#L163

bitsofinfo avatar Jul 23 '19 14:07 bitsofinfo

Yes! This would be awesome!

Currently I hardcode an array of what files exists:

    values:
{{ if has (env "ENV") (list "dev" "stage" "prod")}}
      - values-{{ env "ENV" }}.yaml
{{ end }}

Something like this would be much better:

    values:
{{ if fileExists "values-{{ env "ENV" }}.yaml" }}
      - values-{{ env "ENV" }}.yaml
{{ end }}

morganchristiansson avatar Jul 11 '20 06:07 morganchristiansson

@bitsofinfo I think that you can set missingFileHandler to Info (per #2063 ) for it

AssafKatz3 avatar Jan 25 '22 07:01 AssafKatz3