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

Add CEL function library #108312

Merged
merged 1 commit into from
Mar 3, 2022
Merged

Add CEL function library #108312

merged 1 commit into from
Mar 3, 2022

Conversation

jpbetz
Copy link
Contributor

@jpbetz jpbetz commented Feb 23, 2022

This extends the available CEL functions available for use in x-kubernetes-validations rules to include:

  • isSorted
  • sum
  • min
  • max
  • indexOf
  • lastIndexOf
  • find
  • findAll
  • URL type with converter (url()), checker (isURL()) and accessors (get{Scheme,Hostname,Host,Port,Path,Query})

This completes all additions proposed in the function library KEP update for CEL

Sum only supports numeric and duration types. The KEP proposed supporting bytes and strings, but after more consideration, that is more cleanly implemented directly in cel-go as a join function. (per discussion with CEL author @TristonianJones)

What type of PR is this?

/kind feature

What this PR does / why we need it:

Which issue(s) this PR fixes:

part of #107573

Special notes for your reviewer:

Does this PR introduce a user-facing change?

CRD x-kubernetes-validations rules now support the CEL functions: isSorted, sum, min, max, indexOf, lastIndexOf, find and findAll.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

Please use the following format for linking documentation:

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Feb 23, 2022
@k8s-ci-robot k8s-ci-robot added the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Feb 23, 2022
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Feb 23, 2022
@jpbetz
Copy link
Contributor Author

jpbetz commented Feb 23, 2022

/assign @liggitt

Also, @TristonianJones would you be willing to give this a review pass?

@DangerOnTheRanger
Copy link
Contributor

/cc @DangerOnTheRanger

@jpbetz jpbetz changed the title Implement list and regex function additions to CEL function library Add CEL function library Feb 24, 2022
@jpbetz
Copy link
Contributor Author

jpbetz commented Feb 24, 2022

/priority important-soon
/triage accepted

@k8s-ci-robot k8s-ci-robot added priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Feb 24, 2022
@jpbetz jpbetz force-pushed the stdlib branch 2 times, most recently from 2c813c8 to 3649175 Compare February 24, 2022 16:58
@jpbetz
Copy link
Contributor Author

jpbetz commented Feb 26, 2022

/test pull-kubernetes-unit

@liggitt
Copy link
Member

liggitt commented Mar 1, 2022

/lgtm
/approve
/hold in case you wanted any other eyes on this, unhold at will

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Mar 1, 2022
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Mar 1, 2022
@jpbetz jpbetz force-pushed the stdlib branch 2 times, most recently from 51ced0a to 569cc52 Compare March 2, 2022 03:38
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jpbetz, liggitt

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jpbetz
Copy link
Contributor Author

jpbetz commented Mar 3, 2022

/hold cancel

This is ready now that @TristonianJones's feedback has been applied. We have a niche case where a CEL typesystem update is needed ([].sum == 0). We'll merge the CEL fix before the release. This PR doesn't need to change based on that so I don't see any big reason to hold it back.

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 3, 2022
@jpbetz
Copy link
Contributor Author

jpbetz commented Mar 3, 2022

@liggitt would you retag this? The changes are primarily CEL library organization/consistency things, the functions are otherwise unchanged.

@liggitt
Copy link
Member

liggitt commented Mar 3, 2022

/lgtm
/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants