Skip to content

Commit 01c59b3

Browse files
committed
Clarify sum/min/max
1 parent 7d6a890 commit 01c59b3

File tree

1 file changed

+13
-9
lines changed
  • keps/sig-api-machinery/2876-crd-validation-expression-language

1 file changed

+13
-9
lines changed

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,10 @@ Proposal:
361361
- Keep all the CEL standard functions and macros as well as the extended string library.
362362
- Introduce a new "kubernetes" CEL extension library.
363363
- Add `isSorted` for lists with comparable elements. This is useful for ensuring that a list is kept in-order.
364-
- Add `sum`, `min` and `max` functions for lists of summable/comparable elements. This is the
365-
core set of aggregate functions for lists, with CEL they can also be used on scalars by using defining list literals
366-
inline , e.g. `[self.val1, self.val2].max()`
364+
- Add `sum` for lists of {int, uint, double, duration, string, bytes} (consistent with the [CEL _+_ operation](https://github.com/google/cel-spec/blob/master/doc/langdef.md#list-of-standard-definitions) )
365+
and add `min`, `max` for lists of {bool, int, uint, double, string, bytes, duration, timestamp} (consistent with the [CEL comparison operations](https://github.com/google/cel-spec/blob/master/doc/langdef.md#list-of-standard-definitions)).
366+
These operations can also be used in CEL on scalars by defining list literals
367+
inline , e.g. `[self.val1, self.val2].max()`. Overflow will raise the same error raised by arithmetic operation [overflow](https://github.com/google/cel-spec/blob/master/doc/langdef.md#overflow).
367368
- Add `indexOf` / `lastIndexOf` support for lists (overloading the existing string functions), this can be useful for
368369
validating partial order (i.e. the tasks of a workflow)
369370

@@ -393,7 +394,7 @@ CEL standard [macros](https://github.com/google/cel-spec/blob/master/doc/langdef
393394
- `filter`
394395

395396
CEL [extended string function library](https://github.com/google/cel-go/blob/master/ext/strings.go) includes:
396-
-
397+
397398
- `charAt`
398399
- `indexOf`, `lastIndexOf`
399400
- `upperAscii`, `lowerAscii`
@@ -468,6 +469,8 @@ of any future work done involving CEL and mutating admission control:
468469
Any changes to the CEL function library will make it possible for CRD authors to create CRDs that are incompatible with
469470
all previous Kubernetes releases that supported CEL. Because of this incompatibility, changing the function library
470471
will need to carefully considered and kept to a minimum. All changes will need to be limited to function additions.
472+
We will not add functions to do things that can already be accomplished with existing functions. Improving ease-of-use
473+
at the cost of fragmentation / incompatibility with older servers is not a good trade-off.
471474

472475
Any function library change must follow the [API Changes](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api_changes.md)
473476
guidelines. Since a change to the function library is a change to the `x-kubernetes-validations.rule` field, it must be
@@ -480,15 +483,16 @@ introduced one Kubernetes release prior to when it may be included in create/upd
480483

481484
The mechanism for this will be:
482485

483-
- All new functions, macros, or overloads of existing functions, will be added to a separate "kubernetes-future-compatibility" CEL extension library. (Better naming suggestions welcome).
486+
- All new functions, macros, or overloads of existing functions, will be added to a separate "future compatibility" CEL
487+
extension library (which extension library a function is in is an internal detail that is not visible to users).
484488
- For create requests, and for any CEL expressions that are changed as part of an update, the CEL expression will be
485-
compiled **without** the "kubernetes-future-compatibility" CEL extension.
489+
compiled **without** the "future compatibility" CEL extension library.
486490
- For CEL expressions not changed in an update, the CEL expression will be compiled **with** the
487491
"kubernetes-future-compatibility" CEL extension. This ensures that persisted fields that already use the change continue
488492
to compile.
489-
- The "kubernetes-future-compatibility" CEL extension will always be included when CEL expressions are evaluated.
490-
- When the next version of Kubernetes is release, the library functions are be moved from "kubernetes-future-compatibility"
491-
- to the "kubernetes" library.
493+
- The "future compatibility" CEL extension library will always be included when CEL expressions are evaluated.
494+
- When the next version of Kubernetes is release, the library functions will be moved from "future compatibility"
495+
- to the main CEL extension library we use to extend CEL for Kubernetes.
492496

493497
Alternatives considered:
494498

0 commit comments

Comments
 (0)