-
Notifications
You must be signed in to change notification settings - Fork 16
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
Adding composed.To() method #150
base: main
Are you sure you want to change the base?
Conversation
c2e4a48
to
92b9428
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @BigGold1310!
Could you provide a little more context around how you'd expect to use this function? Is the idea that you'd convert observed composed resources to their real types?
When a function deserializes the Protobuf request the resources are a *structpb.Struct
. Behind the scenes we're already using resource.AsObject
to convert the Struct
to a *composed.Unstructured
when you call request.GetObservedComposedResources
. Part of me wonders whether we should make it possible to go straight from Struct
-> your desired type and skip the Unstructured
in the middle, to avoid a layer of serialization. Not a blocker for this PR though given there's already the From
function here that has a similar issue.
Thank you @negz for taking a look at this PR. The idea of this function is to make it easier writing functions with strongly typed objects. So the function should help converting from the composed.Unstructured to a structured resource. Converting the object directly from the |
e793c9b
to
2c5fa80
Compare
Signed-off-by: Cyrill Näf <[email protected]>
Signed-off-by: bakito <[email protected]>
Simplify error handling by directly returning the error Co-authored-by: Nic Cope <[email protected]> Signed-off-by: Cyrill Näf <[email protected]>
@negz Please review again, the DCO bot should be fixed now and I rebased to the latest version of the branch |
Description of your changes
Adds the composed.To() method to allow an easy conversion from a function-sdk-go Unstructured to a concrete/strongly typed object.
Fixes #93
I have:
make reviewable
to ensure this PR is ready for review.How has this code been tested
Code is tested by unit-testing.