-
Notifications
You must be signed in to change notification settings - Fork 21
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
[program-gen] Emit invoke options and invoke output options in generated programs #1586
Conversation
pkg/codegen/testing/test/testdata/aws-fargate-pp/java/aws-fargate.java
Outdated
Show resolved
Hide resolved
pkg/codegen/java/gen_program.go
Outdated
// i.e. (new InvokeOutputOptions.Builder()).dependsOn(resource).build() | ||
functionImports.Add("com.pulumi.deployment.InvokeOutputOptions") | ||
} else if len(call.Args) == 3 { | ||
functionImports.Add("com.pulumi.deployment.InvokeOptions") |
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.
Maybe tweak this to just check the length once?
if len(call.Args) == 3 {
// Comments as above etc.
if containsDependsOnInvokeOption(call.Args[2]) {
} else {
}
}
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.
Done ✅
pkg/codegen/java/gen_program.go
Outdated
func inspectFunctionCall(nodes []pcl.Node, inspect func(*model.FunctionCallExpression)) { | ||
for _, node := range nodes { | ||
diags := node.VisitExpressions(model.IdentityVisitor, func(x model.Expression) (model.Expression, hcl.Diagnostics) { | ||
// Ignore the node if it is not a call to invoke. |
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 reckon just add a doc comment to the function explaining what it's doing, then you don't need this line (which I think applies to more than just invokes anyway -- any built-in would also trigger it, right?
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.
Added better docs ✅
// in this case we rename the parameter to _data | ||
// it becomes data.applyValue(_data -> _data.result()) | ||
paramName := expr.Signature.Parameters[0].Name | ||
modifiedParamName := "_" + paramName |
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 suspect this isn't safe in general (there might be another variable named _data
in scope, for instance) but it's probably a good starting point for now. Probably should add another conformance test around shadowing etc. in future.
Built on top of #1585 in order to generate
InvokeOptions
for invoke calls.l2-resource-config
/ plugin download URL code generation #1566l2-invoke-options
apply(...)
data.applyValue(data -> data.result())
becomesdata.applyValue(_data -> _data.result())
apply(...)
calls for invokes when used in output variablesThis PR prepares program-gen and sdk to handle
l2-invoke-options-depends-on
which currently generate correct programs but fails the actual conformance test where the invoke has no dependencies cc @julienp