Closed TristonianJones closed 1 year ago
when will this proposal be implemented in cel-go?
@zhqu1148980644 some of the groundwork has been implemented in cel-go, but there are a couple more sizable chunks of work.
@zhqu1148980644 The majority of the cel-go optional value implementation will be committed by the end of this week. The only features missing will be the macros, and they should follow in another week or so.
CEL supports presence testing using the
has
macro which can be useful for building ternary statements to provide alternative values duringmap
, and protobuf object literals; however, there's no way to indicate that the value should be unset at the end of the computation. For example, it is possible to construct a protobuf message literal where the field is set to the default value, but once the field is referenced it cannot be marked as conditionally "unset" based on the result of the field initialization expression.Optional values should leverage CEL's opaque types to be able to specify that a value with a strong type "might" exist, and if it does, to perform some sort of computation on it. This is akin to the feature requested in #245 where keys in a map are optionally set.
The following would indicate that if the
event.user
value is present, it should be set to the value of"user"
in the map literal:This is roughly equivalent to the following:
The CEL grammar and type-checker would need to be updated to support this feature, and it should probably be opt-in as it expands the expressive power of CEL in ways that users may not have anticipated.