-
Notifications
You must be signed in to change notification settings - Fork 164
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
[Enhancement] Please clarify the use of double curly braces for jmesPath in external variables #1388
Comments
Thanks for opening your first issue here! Be sure to follow the issue template! |
Adding working samples, playground. |
By default for a plain JMESPath variable, no double curly brackets are needed in
Nested variables need to be wrapped with
|
/assign |
@realshuting Please /assign We already have a paragraph here mentioning the following: JMESPath expressions in most places in Kyverno must be enclosed in double curly braces like {{request.namespace}}. If an expression is used as the value of a field and contains nothing else, the expression needs to be wrapped in quotes: appns: "{{request.namespace}}". If the value field contains other text outside of the expression, then it can be unquoted and treated as a string but this isn’t strictly required: message: The namespace name is {{request.namespace}}. I think we can update the above text. Or do you think it should go in Variables over here: https://kyverno.io/docs/writing-policies/variables/ Or we can mention both places and add the example you have shared above in the Variables doc. Let me know what you guys think. |
@JimBugwadia @realshuting |
This makes sense to me! Since we have |
Description
It would be really nice if the docs could clearly explain the difference/possibility of using double curly braces in jmespath for external variables.
I tried to create a policy that would set a variable based in one optional annotation or fallback to another annotation ( mandatory ) , in this case prefixed by some path.
The only way that worked ( thanks to @realshuting ) was to mix part of the request without double curly brace and part of it with double curly brace like this.
It would be nice to have a better understanding of that in the docs. Is that only for concatenation? What else?
Thanks!
Slack discussion
https://kubernetes.slack.com/archives/CLGR9BJU9/p1728944204996649
The text was updated successfully, but these errors were encountered: