-
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/go] Improve optional params in invoke #8839
Conversation
Diff for pulumi-random with merge commit 4352872 |
Diff for pulumi-azuread with merge commit 4352872 |
Diff for pulumi-kubernetes with merge commit 4352872 |
Diff for pulumi-gcp with merge commit 4352872 |
Diff for pulumi-azure with merge commit 4352872 |
Diff for pulumi-aws with merge commit 4352872 |
Codecov Report
@@ Coverage Diff @@
## master #8839 +/- ##
===========================================
- Coverage 59.35% 44.26% -15.10%
===========================================
Files 641 635 -6
Lines 99407 97214 -2193
Branches 1389 1389
===========================================
- Hits 59006 43033 -15973
- Misses 37038 51198 +14160
+ Partials 3363 2983 -380
Continue to review full report at Codecov.
|
Diff for pulumi-azure-native with merge commit 4352872 |
Let me return to this tomorrow |
} | ||
|
||
|
||
resource "aws_iam_policy" "example" { |
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 think it panics because "example" is not a valid resource type. It tries to lookup a provider which is supposed to come from that resource type.
resource "aws_iam_policy" "example" { | |
resource aws_iam_policy "aws:iam:Policy" { |
@@ -0,0 +1,53 @@ | |||
data "aws_iam_policy_document" "example" { |
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.
This likely needs to be an invoke
, see
subnets = invoke("aws:ec2:getSubnetIds", { |
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.
Ah, for my understanding this is because the .pp
files are in PCL?
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.
Yes, I think pp = pulumi program.
Apologies, slipping again, will look on Monday |
@t0yv0 I think I responded to the initial question, I'm happy to help @AaronFriel here |
e22f9c3
to
cc97c7f
Compare
cc97c7f
to
fa22ee8
Compare
Diff for pulumi-random with merge commit a3209b4 |
Diff for pulumi-azuread with merge commit a3209b4 |
Diff for pulumi-kubernetes with merge commit a3209b4 |
Diff for pulumi-gcp with merge commit a3209b4 |
Diff for pulumi-azure with merge commit a3209b4 |
Diff for pulumi-aws with merge commit a3209b4 |
@t0yv0 I've rewritten the optional spiller to track state as it recurses into an invoke, then an intrinsic That said, I did run it and verified by hand that positive changes were visible in doc comments to remove hoisted variables: pulumi.Run(func(ctx *pulumi.Context) error {
_, err := aws.GetRegions(ctx, &GetRegionsArgs{
AllRegions: pulumi.BoolRef(true),
}, nil) _, err = lb.LookupListener(ctx, &lb.LookupListenerArgs{
LoadBalancerArn: pulumi.StringRef(selected.Arn),
Port: pulumi.IntRef(443),
}, nil) This looks to be a positive change everywhere I can see, but again, having difficulty even locally rebuilding the AWS provider SDK reproducibly, so I'd be hesitant to merge this without being able to do that. |
Diff for pulumi-azure-native with merge commit a3209b4 |
"github.com/pulumi/pulumi/sdk/v3/go/pulumi", | ||
"../../../../../../sdk")}, | ||
"github.com/pulumi/pulumi/sdk/v3", | ||
"../../../../../../../sdk")}, |
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.
Why has this changed?
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 think the Go test were running via fluke before, resolving a different "github.com/pulumi/pulumi/sdk/v3" than the local copy. Until I changed this, tests were running using the published version of our SDK, I believe? I don't know Go module resolution well enough to say, but I do know that until I changed this, tests weren't running using my local changes.
Digging into the tests, they temporarily create a go.mod
in a subdirectory like below, then run go mod tidy
, then add a replacement for the Pulumi SDK. But I think that last step was a no-op.
testdata
├── aws-optionals-pp
│ ├── go
│ │ ├── aws-optionals.go
│ │ └── go.mod # generated at test runtime
From the directory containing go.mod up to sdk
is 7 levels:
testdata/aws-optionals-pp/go on AaronFriel/issue8821 [$?⇕] via v1.17.6
❯ ls ../../../../../../../sdk
README.md dotnet go go.mod go.sum nodejs proto python
fa22ee8
to
6cb2adb
Compare
Todo:
|
Diff for pulumi-random with merge commit fb98f44 |
@t0yv0 removing your draft and I believe with this nit commit, all tests should be green again. |
Diff for pulumi-random with merge commit 95fdae9 |
Diff for pulumi-azuread with merge commit 95fdae9 |
As described in #8821, docs generated for helper functions can be incorrect because optional arguments to parameter objects are not correctly handled. Previously, code would be generated like so: ```go policyDocument, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{ Statements: []iam.GetPolicyDocumentStatement{ iam.GetPolicyDocumentStatement{ Sid: "1", //... ``` However "Sid" is of type `*string`. This four helper conversion functions, to handle the primitive types we lower from, and modifies codegen to recursively apply these functions inside of an invoke call. In the new code generation, the above is instead rendered as: ```go policyDocument, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{ Statements: []iam.GetPolicyDocumentStatement{ iam.GetPolicyDocumentStatement{ Sid: pulumi.StringRef("1"), //... ```
0966242
to
ef6e697
Compare
Diff for pulumi-kubernetes with merge commit 95fdae9 |
Diff for pulumi-random with merge commit bd241b3 |
Diff for pulumi-gcp with merge commit 95fdae9 |
Diff for pulumi-azuread with merge commit bd241b3 |
Diff for pulumi-kubernetes with merge commit bd241b3 |
Diff for pulumi-gcp with merge commit bd241b3 |
Diff for pulumi-azure with merge commit 95fdae9 |
Diff for pulumi-azure with merge commit bd241b3 |
Diff for pulumi-aws with merge commit 95fdae9 |
Diff for pulumi-aws with merge commit bd241b3 |
Diff for pulumi-azure-native with merge commit 95fdae9 |
Diff for pulumi-azure-native with merge commit bd241b3 |
Diff for pulumi-random with merge commit 13fd9de |
Diff for pulumi-azuread with merge commit 13fd9de |
Diff for pulumi-kubernetes with merge commit 13fd9de |
Diff for pulumi-gcp with merge commit 13fd9de |
Diff for pulumi-azure with merge commit 13fd9de |
Diff for pulumi-aws with merge commit 13fd9de |
Diff for pulumi-azure-native with merge commit 13fd9de |
As described in #8821, docs generated for helper functions can be incorrect because optional arguments to parameter objects are not correctly handled.
Previously, code would be generated like so:
However "Sid" is of type
*string
.This four helper conversion functions, to handle the primitive types we lower from, and modifies codegen to recursively apply these functions inside of an invoke call.
In the new code generation, the above is instead rendered as: