Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for extension functions #56

Open
NoamSherr opened this issue Mar 11, 2024 · 2 comments
Open

Support for extension functions #56

NoamSherr opened this issue Mar 11, 2024 · 2 comments
Labels
documentation Improvements or additions to documentation question Further information is requested

Comments

@NoamSherr
Copy link

cel-go has support for the strings and math function extensions - is the extension supported? And if so how can it be set up in the environment
ext/strings.go

@slott56 slott56 added the question Further information is requested label May 21, 2024
@slott56
Copy link
Collaborator

slott56 commented May 21, 2024

Yes.

Seen https://github.com/cloud-custodian/cel-python/blob/main/src/celpy/__init__.py which has a functions = {}. This is the mapping from a CEL-visible name to a Python function.

@slott56 slott56 added the documentation Improvements or additions to documentation label May 21, 2024
@NoamSherr
Copy link
Author

Cool yeah I used it like that but it meant implementing the lambdas for the functions on my own - is there any intention of supporting the extensions that Go/Java have (String, Math and Optional) without the need for custom implementation?
So expressions like the following could run as well -
woops.title == "something" ? optional.none() : optional.of(woops.description)
or
my_string.upper()
without the need to pass the functions dict to the celpy.Environment().program.

Additionally if I want the optional to be recognized as a namespace without declaring it as a var in the context (a bit "hack-ish") how can I do so? (with the existing functionality)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants