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

Conditional statement as default value in getenv? #285

Closed
xrayrey opened this issue Apr 13, 2018 · 1 comment
Closed

Conditional statement as default value in getenv? #285

xrayrey opened this issue Apr 13, 2018 · 1 comment

Comments

@xrayrey
Copy link

xrayrey commented Apr 13, 2018

Hi All,

Is there a way of using a conditional statement as the default value for getenv? Something like this:

{{ getenv "ENV_VAR" '{{if (datasourceExists "myvar")}}{{(ds "myvar").Value}}{{else}}foobar{{end}}' }}

I want to use the value of the environment variable if it exists. If it doesn't exist I would like to use the value of the data source. If that doesn't exist either then I would like to use a default value.

Thanks!

@xrayrey
Copy link
Author

xrayrey commented Apr 13, 2018

Never mind. I found a solution:

{{if eq (getenv "ENV_VAR" "") ""}}{{if (datasourceExists "myvar")}}{{(ds "myvar").Value}}{{else}}foobar{{end}}{{else}}{{getenv "ENV_VAR"}}{{end}}

@xrayrey xrayrey closed this as completed Apr 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant