sprig icon indicating copy to clipboard operation
sprig copied to clipboard

requiredEnv function

Open maver1ck opened this issue 6 years ago • 2 comments

I'd like to have requiredEnv which would work similar to this https://github.com/roboll/helmfile

The required_env function allows you to declare a particular environment variable as required for template rendering. If the environment variable is unset or empty, the template rendering will fail with an error message.

maver1ck avatar Jul 17 '18 15:07 maver1ck

I'm unsure of this one because it brings data into the templates from a new direction that does not exist today. That has an impact on those that implement it and their intentions. I will have to think about this one more and the implications of a feature like this.

@technosophos any thoughts?

mattfarina avatar Nov 19 '18 19:11 mattfarina

Rather than requireEnv, I'd much prefer to see a general require function that errors when the argument is empty. This can then be called with env output as an arg if users wish to require that an env var is populated, but remains generally useful for other use-cases. Slightly more complex as it needs to be type-aware rather than only dealing with strings, but logic already exists for that in the empty function. Extracting relevant context to populate the error message meaningfully may be the more challenging problem.

pdf avatar Jan 11 '19 04:01 pdf