-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[codegen/python] Support <Resource>Args
classes
#6525
Conversation
Diff for pulumi-random with merge commit 1c9cc8d |
Diff for pulumi-azuread with merge commit 1c9cc8d |
Diff for pulumi-kubernetes with merge commit 1c9cc8d |
Diff for pulumi-gcp with merge commit 1c9cc8d |
Diff for pulumi-azure with merge commit 1c9cc8d |
Diff for pulumi-aws with merge commit 1c9cc8d |
Diff for pulumi-azure-native with merge commit 1c9cc8d |
Diff for pulumi-random with merge commit 6896908 |
Diff for pulumi-azuread with merge commit 6896908 |
Diff for pulumi-kubernetes with merge commit 6896908 |
Diff for pulumi-gcp with merge commit 6896908 |
Diff for pulumi-azure with merge commit 6896908 |
Diff for pulumi-aws with merge commit 6896908 |
Diff for pulumi-azure-native with merge commit 6896908 |
pkg/codegen/python/gen.go
Outdated
mod.genInitDocstring(w, res) | ||
// Now generate __init__ overloads along with an implementation... | ||
|
||
// First, generate an __init__ overload that accepts the resource's inputs from the args class. |
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.
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.
I'd propose having the keyword-based style first ahead of the args-based given that's what people are currently using. We could choose to flip this order for 3.0 to encourage the args-based as the 'default'
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.
Diff for pulumi-random with merge commit c764181 |
Diff for pulumi-azuread with merge commit c764181 |
Diff for pulumi-kubernetes with merge commit c764181 |
Diff for pulumi-gcp with merge commit c764181 |
Diff for pulumi-azure with merge commit c764181 |
Diff for pulumi-aws with merge commit c764181 |
Diff for pulumi-azure-native with merge commit c764181 |
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.
LGTM. Do we know what impact this will have on docs and how we will handle presenting the overloads there?
Diff for pulumi-azuread with merge commit c7fb9da |
Diff for pulumi-random with merge commit c7fb9da |
Diff for pulumi-kubernetes with merge commit c7fb9da |
Diff for pulumi-gcp with merge commit c7fb9da |
Diff for pulumi-azure with merge commit c7fb9da |
Diff for pulumi-aws with merge commit c7fb9da |
Diff for pulumi-azure-native with merge commit c7fb9da |
Oh, I realized that all the tests here are of the codegen itself. Could we add some tests of this in use? |
Add support for creating instances of resources in Python using a `<Resource>Args` class. This capability aligns with how args are passed to resources in all the other language SDKs and the separate object bag allows the properties to be manipulated/validated/passed-around before creating the resource.
Emit the overload that accepts the new args class last, so code completion shows the existing function-arg-based overload first.
Fix a regression that was causing function inputs to be incorrectly wrapped as `Input[T]`.
Diff for pulumi-random with merge commit bc61f9e |
Diff for pulumi-kubernetes with merge commit bc61f9e |
Diff for pulumi-azuread with merge commit bc61f9e |
Diff for pulumi-gcp with merge commit bc61f9e |
Diff for pulumi-azure with merge commit bc61f9e |
Diff for pulumi-aws with merge commit bc61f9e |
Diff for pulumi-azure-native with merge commit bc61f9e |
- [sdk/go] Fix Go resource registrations (pulumi/pulumi#6641) - [sdk/python] Support `<Resource>Args` classes (pulumi/pulumi#6525)
- [sdk/go] Fix Go resource registrations (pulumi/pulumi#6641) - [sdk/python] Support `<Resource>Args` classes (pulumi/pulumi#6525)
- [sdk/go] Fix Go resource registrations (pulumi/pulumi#6641) - [sdk/python] Support `<Resource>Args` classes (pulumi/pulumi#6525)
- [sdk/go] Fix Go resource registrations (pulumi/pulumi#6641) - [sdk/python] Support `<Resource>Args` classes (pulumi/pulumi#6525)
Add support for creating instances of resources in Python using a
<Resource>Args
class. This capability aligns with how args are passed to resources in all the other language SDKs and the separate object bag allows the properties to be manipulated/validated/passed-around before creating the resource.Part of #5146