undistro/cel-playground

Support CEL optional values.

vinayakankugoyal opened this issue · 2 comments

Feature Description

Support optional values: https://github.com/google/cel-spec/wiki/proposal-246

Is your feature request related to a problem?

kubernetes has whacky defaults when a field is missing. Let's assume object is pod here. I'd like to do

object.spec.?hostUsers.orValue(true) ? 'yes' : 'no'

instead of

!has(object.spec.hostUsers)  ? 'yes' : (object.spec.hostUsers ? 'yes' : 'no')

kubernetes validation admission policy also already supports this. I would love if I can just copy a policy and run it in the playground.

What alternatives have you considered?

N/A

Additional Context

N/A

Hi @vinayakankugoyal
Thank you very much for opening this issue!

Optional types are already supported in CEL Playground! See this example.

The optional types CEL library is included in CEL environment options:

cel.OptionalTypes(),

Is this what you were expecting?

I'm closing this issue because optional values are already supported in CEL Playground as mentioned before.
Feel free to comment and share any thoughts on this.
Thanks!