Skip to content

Commit f1bec78

Browse files
committed
Describe how to handle characters not allowed in CEL identifiers in escaping rules
1 parent 566b0ea commit f1bec78

File tree

1 file changed

+10
-5
lines changed
  • keps/sig-api-machinery/2876-crd-validation-expression-language

1 file changed

+10
-5
lines changed

keps/sig-api-machinery/2876-crd-validation-expression-language/README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,16 @@ like the `all` macro, e.g. `self.all(listItem, <predicate>)` or `self.all(mapKey
297297
identifiers](https://github.com/google/cel-spec/blob/master/doc/langdef.md#values)) it is not
298298
accessible as a root variable and must be accessed via `self`, .e.g. `self.int`.
299299

300-
- If a object property name contains characters not allowed in CEL identifiers it is escaped using these rules:
301-
- `.` (period) is escaped as `__dot__`
302-
- `-` (slash) is escaped as `__slash__`
303-
- ` ` (space) is escaped as `__space__`
304-
- `__` (2 underscores) is escaped as `__underscores__`
300+
- If a object property name contains characters not allowed in CEL identifiers (`[a-zA-Z_][a-zA-Z0-9_]*`) it is escaped using these rules:
301+
- Property names starting with a number are prefixed by `_`. Property names prefixed with `_`
302+
followed by a number are prefixed with `__` and the number.
303+
- `__` (2 underscores) is escaped as `__underscores__` (and is used as the escape char for the below rules)
304+
- All characters except `[a-zA-Z0-9]` are escaped either as `__{symbolName}__` or `__0x{unicodeHex}__`, the recognized symbol names are:
305+
- `dot` (`.`)
306+
- `dash` (`-`)
307+
- `space` (` `)
308+
- `dollar` (`$`)
309+
- `slash` (`/`)
305310

306311
- Rules may be written at the root of an object, and may make field selection into any fields
307312
declared in the OpenAPIv3 schema of the CRD as well as `apiVersion`, `kind`, `metadata.name` and

0 commit comments

Comments
 (0)