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
- If a object property name is a CEL keyword (see RESERVED in [CEL Syntax](https://github.com/google/cel-spec/blob/master/doc/langdef.md#syntax)),
292
-
it will be escaped by prepending a _ prefix. To prevent this from causing a subsequent collision, all properties with a `_` prefix will always be
292
+
it will be escaped by prepending a _ prefix. To prevent this from causing a subsequent collision, properties named with a CEL keyword and a `_` prefix will be
293
293
prefixed by `__` (generally, N+1 the existing number of `_`s).
294
294
295
295
- If a object property name is a CEL language identifier (`int`, `uint`, `double`, `bool`, `string`,
296
296
`bytes`, `list`, `map`, `null_type`, `type`, see [CEL language
297
297
identifiers](https://github.com/google/cel-spec/blob/master/doc/langdef.md#values)) it is not
298
298
accessible as a root variable and must be accessed via `self`, .e.g. `self.int`.
299
299
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__`
305
+
300
306
- Rules may be written at the root of an object, and may make field selection into any fields
301
-
declared in the OpenAPIv3 schema of the CRD. This includes selection of fields in both the `spec`
302
-
and `status` in the same expression, e.g. `status.quantity <= spec.maxQuantity`. Because CRDs only
303
-
allow the `name` and `generatedName` to be declared in the `metadata` of an object, these are the
304
-
only metadata fields that may be validated using CEL validator rules. For example,
305
-
`metadata.name.endsWith('mySuffix')`is allowed, but only when the OpenAPIv3 schema explicitly
306
-
declares `metadata` as a field in the root object and declares the `name` field within `metadata`.
307
-
`size(metadata.labels) < 3`however, it not allowed. The limit on which `metadata` fields may be
308
-
validated is an intentional design choice (that aims to keep metadata behavior uniform across
309
-
types) and applies to all validation mechanisms (e.g. the OpenAPIV3 `maxItems` restriction), not
310
-
just CEL validator rules.
307
+
declared in the OpenAPIv3 schema of the CRD as well as `apiVersion`, `kind`, `metadata.name` and
308
+
`metadata.generateName`. This includes selection of fields in both the `spec` and `status` in the
309
+
same expression, e.g. `status.quantity <= spec.maxQuantity`. Because CRDs only allow the `name`
310
+
and `generatName` to be declared in the `metadata` of an object, these are the only metadata
311
+
fields that may be validated using CEL validator rules. For example,
312
+
`metadata.name.endsWith('mySuffix')`is allowed, but `size(metadata.labels) < 3` it not
313
+
allowed. The limit on which `metadata` fields may be validated is an intentional design choice
314
+
(that aims to keep metadata behavior uniform across types) and applies to all validation
315
+
mechanisms (e.g. the OpenAPIV3 `maxItems` restriction), not just CEL validator rules.
311
316
312
317
- We plan to allow access to the current state of the object to allow validation rules to check the
313
318
new value against the current value, e.g. for immutability checks (for validation racheting we would
0 commit comments