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

Validation: add documentation and use CEL pre-processor #3333

Merged
merged 6 commits into from
Jan 1, 2025

Conversation

howardjohn
Copy link
Member

Depends on istio/tools#3050.

This PR adds support for a new cel pre-processor: https://github.com/howardjohn/celpp.

This avoids the need to write incredibly verbose and error prone boilerplate to workaround limitations in the CEL language.


This PR has a few commits:

  • Run with no changes. The pre-processor formats the CEL expression, so this has some trivial changes
  • Incrementally migrate things to the new CEL macros where it makes sense to simplify
  • Add documentation for validation (includes more than just the new stuff)

@howardjohn howardjohn added the do-not-merge/hold Block automatic merging of a PR. label Oct 10, 2024
@howardjohn howardjohn requested review from a team as code owners October 10, 2024 21:10
@istio-testing istio-testing added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 10, 2024
Comment on lines +268 to +270
* **default**. Usage: `default(self.x, 'DEF')`.
* **oneof**. Usage: `oneof(self.x, self.y, self.z)`. This checks that 0 or 1 of these fields is set.
* **index**. Usage: `self.index({}, x, z, b)`. This does `self.x.z.b` and returns `{}` if any of these is not set.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the difference 'DEF' must be a concrete value whereas {} could be an expression of some sort?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both 'DEF' and {} are just examples of the same thing -- the default value. In one example I return a string and the other an empty object, but there is not a difference.

Copy link
Contributor

@ilrudie ilrudie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This really improves readability. It looks good to me

Copy link
Member

@linsun linsun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@istio-testing istio-testing added the needs-rebase Indicates a PR needs to be rebased before being merged label Dec 20, 2024
@istio-testing istio-testing removed the needs-rebase Indicates a PR needs to be rebased before being merged label Dec 20, 2024
@howardjohn howardjohn added release-notes-none Indicates a PR that does not require release notes. and removed do-not-merge/hold Block automatic merging of a PR. labels Dec 31, 2024
@howardjohn howardjohn requested a review from ilrudie December 31, 2024 17:40
@istio-testing istio-testing merged commit a684e69 into istio:master Jan 1, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes-none Indicates a PR that does not require release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants