sprig
sprig copied to clipboard
requiredEnv function
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.
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?
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.