You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm doing something similar to Kubernetes, using CEL for validation. One of the things Kubernetes does is define escaping rules. These rules are (as far as I can tell) specifically for property names, which makes sense because the authors of CEL expressions can control what they name things (they know they're writing CEL), but when referring to OpenAPI objects the properties are what they are, but may not be CEL-compatible because CEL doesn't support -, /, or . in property names while OpenAPI does.
I'm curious about the __{keyword}__ escapes though. I've done a bunch of testing and there are definitely some reserved keywords that you have to escape in a CEL expression: self.true and self.false don't work, but many others like self.namespace and self.break seem to work fine, at least with the Env I've configured. Kubernetes escapes these anyway though, including namespace which is very commonly used.
My question is: Is there actual guidance on what keywords need to be escaped and which don't? Especially in context of struct fields?
Kubernetes just used a hammer and escaped them all, but .namespaceseems to actually work. Since it works, I think you couldn't just suddenly make it stop working as you'd break existing expressions. .break, .const (and various others) also seem to work fine.
The text was updated successfully, but these errors were encountered:
The following identifiers are reserved due to their use as literal values or in the syntax:
false in null true
The following identifiers are reserved to allow easier embedding of CEL into a host language.
as break const continue else for function if import let loop package
namespace return var void while
Which maybe is saying: "If you're not talking about an embedding, you need to escape false, in, null, true ONLY" - am I interpreting that right?
I'm doing something similar to Kubernetes, using CEL for validation. One of the things Kubernetes does is define escaping rules. These rules are (as far as I can tell) specifically for property names, which makes sense because the authors of CEL expressions can control what they name things (they know they're writing CEL), but when referring to OpenAPI objects the properties are what they are, but may not be CEL-compatible because CEL doesn't support
-
,/
, or.
in property names while OpenAPI does.I'm curious about the
__{keyword}__
escapes though. I've done a bunch of testing and there are definitely some reserved keywords that you have to escape in a CEL expression:self.true
andself.false
don't work, but many others likeself.namespace
andself.break
seem to work fine, at least with theEnv
I've configured. Kubernetes escapes these anyway though, includingnamespace
which is very commonly used.My question is:
Is there actual guidance on what keywords need to be escaped and which don't? Especially in context of struct fields?
Kubernetes just used a hammer and escaped them all, but
.namespace
seems to actually work. Since it works, I think you couldn't just suddenly make it stop working as you'd break existing expressions..break
,.const
(and various others) also seem to work fine.The text was updated successfully, but these errors were encountered: