I am working on helmfile and stuck at the point where I want the conditional variable declaration. Roughly like this but in go standard templates.
ENV = "prod"
folder = ""
if ENV == "prod":
folder = "production"
elif ENV == "qa"
folder == "qa"
else
folder = "dev"
How can I achieve something like that? Thanks
Use the
{{if}}action and theeqtemplate function to compare theENVvariable to certain values:Note that this is not "conditional declaration". We declare
$folder"unconditionally" and used{{if}}to change its value.Here's a runnable demo to test the above template:
Output (try it on the Go Playground):