Add a resource.update convenience function#98
Merged
negz merged 3 commits intocrossplane:mainfrom Oct 10, 2024
Merged
Conversation
negz
commented
Oct 9, 2024
negz
commented
Oct 9, 2024
| @@ -0,0 +1,301 @@ | |||
| # generated by datamodel-codegen: | |||
Member
Author
There was a problem hiding this comment.
This is all generated code - no need to review it.
negz
commented
Oct 9, 2024
| "grpcio==1.*", | ||
| "grpcio-reflection==1.*", | ||
| "protobuf==5.27.2", | ||
| "pydantic==2.*", |
Member
Author
There was a problem hiding this comment.
I don't love introducing a dependency on pydantic just for the type annotation really. I think if it proves to be a pain we could move it out to an optional dependency.
I don't think pydantic has a lot of dependencies though, so it may not be so bad.
This function can be used to add or update a resource. For example, to add a desired composed bucket (assuming the "bucket" resource doesn't yet exist): ```python resource.update(rsp.desired.resources["bucket"], bucket) ``` Or to update the desired XR: ```python resource.update(rsp.desired.composite.resource, partial_xr) ``` The source resource can be a dictionary, a protobuf struct, or a Pydantic model. Signed-off-by: Nic Cope <[email protected]>
Signed-off-by: Nic Cope <[email protected]>
This was introduced in 3.10, and seems like a much better way to handle matching a type. Signed-off-by: Nic Cope <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of your changes
This function can be used to add or update a resource.
For example, to add a desired composed bucket (assuming the "bucket" resource doesn't yet exist):
Or to update the desired XR:
The source resource can be a dictionary, a protobuf struct, or a Pydantic model.
I have: