Skip to content
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

Merged
merged 12 commits into from
Jan 14, 2025
Merged
Prev Previous commit
Next Next commit
use embedded builder for InvokeOutputOptions
Zaid-Ajaj committed Jan 14, 2025
commit caa220982bd4efc1699fc8deb49d0f02a260a8fc
6 changes: 3 additions & 3 deletions pkg/codegen/java/gen_program.go
Original file line number Diff line number Diff line change
@@ -857,9 +857,9 @@ func (g *generator) genPreamble(w io.Writer, nodes []pcl.Node) {
functionImports.Add("com.pulumi.asset.AssetArchive")
case pcl.Invoke:
if len(call.Args) == 3 && containsDependsOnInvokeOption(call.Args[2]) {
// import the builder class because we want to new it up at call site
// i.e. (new InvokeOutputOptionsBuilder()).dependsOn(resource).build()
functionImports.Add("com.pulumi.deployment.InvokeOutputOptionsBuilder")
// for invoke output options, instantiate the builder from its parent class
// 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")
Copy link
Contributor

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 {

  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done ✅

}
2 changes: 1 addition & 1 deletion pkg/codegen/java/gen_program_expressions.go
Original file line number Diff line number Diff line change
@@ -339,7 +339,7 @@ func (g *generator) GenFunctionCallExpression(w io.Writer, expr *model.FunctionC
if containsDependsOnInvokeOption(options) {
// TODO: replace with `InvokeOutputOptions.builder()` once it's implemented
// for that we need InvokeOutputOptions to not extend InvokeOptions
builderName = "(new InvokeOutputOptionsBuilder())"
builderName = "(new InvokeOutputOptions.Builder())"
}
g.Fgenf(w, ", %s", builderName)
g.genNewline(w)