var.* on the environment level
# 🌱|help-and-getting-started
Hello. I'm insecure is it bug or feature that's why I decided to write here first. I use individual variables set with --var in CLI flags and define it on the environments level in the project file but I have the error. For example: use this command -> garden deploy --var name=username have this line in project file -> defaultNamespace: user-${} get this error -> Invalid template string (user-${}): Could not find key name under var.
Hey @nutritious-kitchen-29367 sorry for taking so long to answer this issue, I see that this command is documented in our docs but I can't see it reflected when I'm running it with my CLI. I'm going to reach back to the OSS Devs to ask about this problem. For the time being here are a couple of workarounds you could try: 1. Create a
file and store your variables there in a KEY=VALUE format. 2. You can set variables at the environment level using this structure: 3. You can also set variables at the project level by using: I hope that helps for the time being!
Hey @nutritious-kitchen-29367 I was able to reproduce the scenario and setting variables with --var works for me! Would you mind giving it a try, maybe you can use this simple project to compare with yours and find the issue?
Hello Shanky. Thanks for answer. Your scenario works because you use var - "installCRDs" in the module level. I spoke about environment level. If you define var in the I supose you will have the same error as like me.
Is it possible that you could share some pieces of your garden config to try to reproduce it? I think I get your idea, basically it fails if you set an environment variable at the env level but you override it with the —var flag?
Hey @nutritious-kitchen-29367 I was able to reproduce this issue, you are right. It seems like we are not being able to provide variables that are added as an argument to the deploy command specifically to the defaultNamespace field. A little workaround that you could use to fix this issue is; Instead of doing:
defaultNamespace: user-${}
you can do
defaultNamespace: user-${local.user}
which will resolve to the user of the terminal you are using ($USER) or $WHOAMI. Also, I would like to ask you if you would be open to submit a
directly into our Github repository so the Core Developers can tackle this issue as part of future releases? Thanks a lot!
Thanks a lot. I will submit a bug.
Hey @nutritious-kitchen-29367 where you able to submit a bug for this one? ❤️
Ahh just ran into this issue for the exact same scenario (trying to set
) Was an issue made for this?
the workaround I'm using is environment variables which seems to work (e.g.
Sadly Ruslan wasn’t able to submit the issue, would you be able to create it?✨