google / cel-spec

Common Expression Language -- specification and binary representation
https://cel.dev
Apache License 2.0
2.78k stars 222 forks source link

configurations support for the CEL? #216

Closed wzhanw closed 2 years ago

wzhanw commented 2 years ago

Hi experts,

CEL is great, we are moving some server functions to cel. We have some functions depending on the user environment configuration.
The function behavior and output depend on some user conf.

in a runtime application, we can have a configuration for the app, the applications can read this conf at start time.

and for the CEL, if there is any way to do the same thing? thanks.

TristonianJones commented 2 years ago

Hi @wzhanw,

Thanks for reaching out. Are you asking if there's a way to configure the CEL parser / type-checker from a configuration? Or something else. Or are you asking if you can embed CEL into a configuration?

-Tristan

wzhanw commented 2 years ago

Hi @TristonianJones, I'm looking for system configuration support for the CEL. For an application, we can have conf to configure the settings for that application, the application will pick the conf at startup.

For example, the default layouts of date are different between different countries. I hope user can configure their date layout somewhere and CEL function can get those system constant settings when doing the date conversion.

wzhanw commented 2 years ago

This is not a problem, we can use os.Getenv() and os.Setenv() in our functions

TristonianJones commented 2 years ago

Thanks for the context and the eventual solution. The string timestamp format we use followed RFC3339, so it's not designed for localized representations. I'm happy you found a good workaround though that allows you to do what you'd like.