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

Fix/master: add envOrDefault helper #1461

Merged

Conversation

jtrinklein
Copy link
Contributor

Addresses issue #829

Adds a helper envOrDefault as a compliment to the env helper. This behaves similar to how keyOrDefault behaves.

The helper will attempt to retrieve an environment variable. If the variable is found and if the value has a non-zero length, the value is used. Otherwise, the default value is used.

Change includes tests and documentation.

Adds a helper function called envOrDefault which behaves similar to keyOrDefault
If an environment variable exists and its value has a non-zero length, that value will be used, otherwise the default value specified will be used.
@hashicorp-cla
Copy link

hashicorp-cla commented Mar 30, 2021

CLA assistant check
All committers have signed the CLA.

@jtrinklein
Copy link
Contributor Author

Hi @eikenb here's the PR for the envOrDefault helper

template/funcs.go Outdated Show resolved Hide resolved
@eikenb eikenb added hashicat-update-required Changes that need to be ported to hashicat waiting-reply labels Apr 23, 2021
This accepts environment variables that are set to empty string. The
only time default will be used is if the variable is not present.
Update the documentation for the new behavior of envOrDefault with
respect to environment variables which are set but to empty strings.
@eikenb eikenb merged commit d2ca976 into hashicorp:master May 21, 2021
@eikenb eikenb added this to the 0.26.0 milestone May 21, 2021
@jtrinklein jtrinklein deleted the fix/master/add-envOrDefault-helper branch May 25, 2021 22:03
@eikenb eikenb added the hashicat-update-complete Completed porting changes to hashicat label Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement hashicat-update-complete Completed porting changes to hashicat hashicat-update-required Changes that need to be ported to hashicat
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants