pulumi/pkg/codegen/go
Zaid Ajaj ebf838e02e
[go] Allow output-versioned invokes to resolve and maintain secrets (#17132)
Partially addressing #12710

### Description

This PR extends Go SDK-gen, specifically for output-versioned invokes
such that they no longer rely on the plain invokes for their function
body.

We do this by implementing and using a sdk function `InvokePackageRaw`
which is similar to `InvokePackage` except that it doesn't fail on
secrets and actually returns a boolean indicating whether the invoke
response contained any secrets. This way, the generated output-versioned
invokes can immediately wrap the response as a secret if necessary and
more importantly, not failing immediately if the response contained
secrets.

The sdk-gen test `output-funcs` actually do a runtime test for the newly
generated function body and it passes. ~~However, I don't think it
covers the _if secret then wrap as secret_ path~~ but maybe that's
acceptable because it's a simple one liner
```go
// <invoke function body ommited here>
if secret {
  return pulumi.ToSecret(output).(FuncResultOutput), nil
}
```
Follow-up PRs with less priority:
 - [x] A proper test for invokes with secrets in their response
 - [ ] A conformance test
- [ ] Doing the same for _generic_ output-versioned invokes to let them
maintain secretness

### EDIT
Updated the test in output-funcs such that it now returns a response for
an invoke containing secrets
2024-09-09 12:57:43 +00:00
..
gen_program_test Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
doc.go Enable perfsprint linter (#14813) 2023-12-12 12:19:42 +00:00
doc_test.go sdk/go: Remove 'nolint' directives from package docs 2023-01-06 09:06:47 -08:00
embeddedUtilities.go Support returning plain values from methods (#13592) 2023-11-18 06:02:06 +00:00
gen.go [go] Allow output-versioned invokes to resolve and maintain secrets (#17132) 2024-09-09 12:57:43 +00:00
gen_program.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
gen_program_expression_test.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
gen_program_expressions.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
gen_program_inline_invoke.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
gen_program_json.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
gen_program_optionals.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
gen_program_read_dir.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
gen_program_splat.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
gen_program_ternaries.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
gen_program_test.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
gen_program_utils.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
gen_spill.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
gen_test.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
importer.go [go/program-gen] Implement importPathPattern in Go language options to override emitted paths in generated Go programs (#16267) 2024-05-30 19:51:12 +00:00
test.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
utilities.go Enable perfsprint linter (#14813) 2023-12-12 12:19:42 +00:00
utilities_test.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00