List specific value from datasource depending on env var #1634
-
Hello, I would like to render my template with a datasource but I would like to state the specific value from the datasource file as a variable (which is an env var). It would be good if I could solve the problem with only one env.yml file and only one test.template file. So for example, I have the following files
and env.yml
If I set Is there any way to do that? I had a look at nested template but that is not my use case as I want to variablize the map path and not the datasource file. Besides, I have only one env.yml file. I would appreciate any help, thanks in advance.
My attempts that did not work
This works when I do gomplate command twice, but I would be curious if there is a way to do it with just one gomplate command. Also, the syntax is difficult to maintain I believe.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @viet-ng95! I've converted this to a discussion since this is a usage question and not a bug report. What you need here is the What might work is something like:
Or, if you want to be less verbose and do it on a single line:
Hope that helps! |
Beta Was this translation helpful? Give feedback.
Hi @viet-ng95! I've converted this to a discussion since this is a usage question and not a bug report.
What you need here is the
index
function, and its usage for accessing maps (such as was provided by your datasource) is documented here.What might work is something like:
Or, if you want to be less verbose and do it on a single line:
Hope that helps!