I want to express in a template string "when var.m...
# 🤖|ask-kapa
f
@microscopic-river-74022 I want to express in a template string "when var.message is not set". Can I use bang to negate? For instance,
${!var.message}
. How else would I express "when var.message is undefined"?
m
Please stand by @fresh-yak-35965 as I search the knowledge base. I normally take about 20 seconds or so. :wave:
---------------------- In Garden, you can express "when var.message is undefined" by using the optional values feature in template strings. You can add a
?
after the template to allow it to resolve to an undefined value without throwing an error. For example,
${var.message}?
. This is useful when you don't want to provide any value unless one is explicitly set. Here's an example:
Copy code
yaml
kind: Project
providers:
  - name: kubernetes
    kubeconfig: ${var.kubeconfig}?
In this case,
kubeconfig
will not be set unless
var.kubeconfig
is explicitly set. However, the documentation does not mention the use of a bang (
!
) to negate or check for undefined values in template strings. It's recommended to follow the documented syntax to avoid unexpected behavior. For more information, you can refer to the Garden documentation on variables and templating (). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
message has been deleted