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

feat: adds derive from cel query readiness policy #247

Merged
merged 1 commit into from
Jun 4, 2024

Conversation

zach-source
Copy link
Contributor

@zach-source zach-source commented May 18, 2024

Description of your changes

Adds new readiness policy called "DeriveFromCelQuery". This policy allows the use of a cel query to check if an object is ready. This is handy to check conditions on objects with non-standard methods of determining if it ready such as the argocd applictation object.

Probably closes #192

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable test to ensure this PR is ready for review.

How has this code been tested

I've written several test caes that cover the usage of the new feature.

@zach-source zach-source changed the title feat: adds cel readiness feat: adds derive from cel query readiness policy May 18, 2024
@bobh66
Copy link
Contributor

bobh66 commented May 22, 2024

@zach-source this looks great - do you have an example of how to reference a status condition with a specific type in a CEL query? I have been looking at CEL examples and I haven't found an equivalent syntax to the JSONPath $.status.conditions[?(@.type=="Completed")].status syntax.

@bobh66
Copy link
Contributor

bobh66 commented May 22, 2024

@zach-source this looks great - do you have an example of how to reference a status condition with a specific type in a CEL query? I have been looking at CEL examples and I haven't found an equivalent syntax to the JSONPath $.status.conditions[?(@.type=="Completed")].status syntax.

I think I figured it out:

status.conditions.exists(w, w.type=='Foo' && w.status == 'True')

@zach-source
Copy link
Contributor Author

zach-source commented May 22, 2024

Ah yea, exactly. And you can combine them if you want multiple. I've pushed up changes to make it pass all the reviewable checks. It's been a minute since I worked on a provider and I always have a hard time getting that submodule to sync correctly. You can see the list of all the available macros here: https://github.com/google/cel-spec/blob/master/doc/langdef.md#macros

I'll add a test case for ya.

@bobh66
Copy link
Contributor

bobh66 commented May 22, 2024

@zach-source Please run go mod tidy and make generate and commit the results.

@zach-source zach-source force-pushed the feat/addCelReadiness branch 2 times, most recently from 2943164 to 3764119 Compare May 22, 2024 19:54
@zach-source
Copy link
Contributor Author

Should be good to go now @bobh66

@bobh66
Copy link
Contributor

bobh66 commented May 23, 2024

@turkenh can you take a look at this? It would be great to get this into the next release if possible - thanks!

Copy link
Collaborator

@phisco phisco left a comment

Choose a reason for hiding this comment

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

Looking good! A few minor comments

internal/controller/object/object.go Outdated Show resolved Hide resolved
internal/controller/object/object.go Outdated Show resolved Hide resolved
internal/controller/object/object.go Outdated Show resolved Hide resolved
@zach-source
Copy link
Contributor Author

Looking good! A few minor comments

Thanks for the review - I'll do a bit of work on it this weekend and push it up. Probably tomorrow.

@zach-source zach-source force-pushed the feat/addCelReadiness branch 2 times, most recently from d9f0694 to e0857b8 Compare May 29, 2024 03:49
@zach-source
Copy link
Contributor Author

@phisco comments have been addressed.

@zach-source zach-source requested review from phisco and bobh66 May 31, 2024 02:29
Copy link
Collaborator

@phisco phisco left a comment

Choose a reason for hiding this comment

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

Looking good! just a few small nits, we can address them in a follow up pr if needed

internal/controller/object/object.go Outdated Show resolved Hide resolved
internal/controller/object/object.go Show resolved Hide resolved
internal/controller/object/object.go Outdated Show resolved Hide resolved
Signed-off-by: Zachary Taylor <[email protected]>
@zach-source
Copy link
Contributor Author

@phisco Added your recommended changes/nits.

@lsviben lsviben merged commit a9c6ef8 into crossplane-contrib:main Jun 4, 2024
6 checks passed
@zach-source zach-source deleted the feat/addCelReadiness branch June 10, 2024 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend the readinessChecks Policy options to allow for a list of Condition types and values to match
4 participants