Skip to content

Conversation

@negz
Copy link
Member

@negz negz commented Oct 9, 2024

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):

resource.update(rsp.desired.resources["bucket"], bucket)

Or to update the desired XR:

resource.update(rsp.desired.composite.resource, partial_xr)

The source resource can be a dictionary, a protobuf struct, or a Pydantic model.

I have:

@@ -0,0 +1,301 @@
# generated by datamodel-codegen:
Copy link
Member Author

Choose a reason for hiding this comment

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

This is all generated code - no need to review it.

"grpcio==1.*",
"grpcio-reflection==1.*",
"protobuf==5.27.2",
"pydantic==2.*",
Copy link
Member Author

@negz negz Oct 9, 2024

Choose a reason for hiding this comment

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

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.

negz added 3 commits October 9, 2024 18:04
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]>
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]>
@negz negz merged commit 33ee9e1 into crossplane:main Oct 10, 2024
@negz negz deleted the pydants branch October 10, 2024 02:11
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.

2 participants