pulumi/pkg/codegen/go
Guinevere Saenger de0dcbfec6
[codegen/go] Update Go SDK function output to check for errors (#9274)
* [codegen/go] Update Go SDK function output to check for errors

Fixes https://github.com/pulumi/pulumi-aws/issues/1872.

This should result in the following sample output in the Go SDK:

```
func GetPolicyDocumentOutput(ctx *pulumi.Context, args GetPolicyDocumentOutputArgs, opts ...pulumi.InvokeOption) GetPolicyDocumentResultOutput {
	return pulumi.ToOutputWithContext(context.Background(), args).
		ApplyT(func(v interface{}) (GetPolicyDocumentResult, error) {
			args := v.(GetPolicyDocumentArgs)
			r, err := GetPolicyDocument(ctx, &args, opts...)
			if err != nil {
				return nil, err
			}
			if r == nil {
				return nil, fmt.Errorf("expected either result or error to be nil, not both")
			}
			return *r, err
		}).(GetPolicyDocumentResultOutput)
}
```

* Fix generated code panic on *nil (#9284)

* [codegen/go] Update Go SDK function output to check for errors

Fixes https://github.com/pulumi/pulumi-aws/issues/1872.

This should result in the following sample output in the Go SDK:

```
func GetPolicyDocumentOutput(ctx *pulumi.Context, args GetPolicyDocumentOutputArgs, opts ...pulumi.InvokeOption) GetPolicyDocumentResultOutput {
	return pulumi.ToOutputWithContext(context.Background(), args).
		ApplyT(func(v interface{}) (GetPolicyDocumentResult, error) {
			args := v.(GetPolicyDocumentArgs)
			r, err := GetPolicyDocument(ctx, &args, opts...)
			if r != nil {
				s = *r
			}
			return s, err
		}).(GetPolicyDocumentResultOutput)
}
```

* Alternate fix to safeguard dereferencing nil

* Accept codegen changes in the test suite

Co-authored-by: Guinevere Saenger <guinevere@pulumi.com>

* Update CHANGELOG_PENDING.md

Co-authored-by: Anton Tayanovskyy <anton@pulumi.com>
2022-03-24 20:11:53 -07:00
..
doc.go Fix default package name (#8187) 2021-10-11 15:28:11 -07:00
doc_test.go ci: radical idea - what if slow tests & no stdout makes GH consider runner dead? 2022-03-06 14:52:13 -08:00
gen.go [codegen/go] Update Go SDK function output to check for errors (#9274) 2022-03-24 20:11:53 -07:00
gen_crd2pulumi.go [codegen/go] Call site defaults for Pulumi Object types (#8411) 2021-11-23 15:10:15 -08:00
gen_program.go [codegen/go] Add GenerateProgramWithOpts function (#8997) 2022-02-16 11:11:33 -07:00
gen_program_expression_test.go ci: radical idea - what if slow tests & no stdout makes GH consider runner dead? 2022-03-06 14:52:13 -08:00
gen_program_expressions.go Expand pcl intrinsic functions (#9208) 2022-03-15 17:05:36 -07:00
gen_program_json.go Reify `Input` and `Optional` types in the schema type system. (#7059) 2021-06-24 09:17:55 -07:00
gen_program_optionals.go [codegen/go] Improve optional params in invoke 2022-02-01 11:44:40 -08:00
gen_program_read_dir.go [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
gen_program_splat.go [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
gen_program_ternaries.go [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
gen_program_test.go Expose the check function (#9176) 2022-03-16 11:42:30 -07:00
gen_program_utils.go Implemented filebase64sha256 & fileArchive support for codegen (#7997) 2022-01-21 16:03:25 +02:00
gen_spill.go Reify `Input` and `Optional` types in the schema type system. (#7059) 2021-06-24 09:17:55 -07:00
gen_test.go ci: radical idea - what if slow tests & no stdout makes GH consider runner dead? 2022-03-06 14:52:13 -08:00
importer.go [codegen/go] Add support for specifying internal dependencies (#9183) 2022-03-18 17:02:33 -07:00
test.go Expose the check function (#9176) 2022-03-16 11:42:30 -07:00
utilities.go Update error handling (#8406) 2021-11-12 18:37:17 -08:00
utilities_test.go ci: radical idea - what if slow tests & no stdout makes GH consider runner dead? 2022-03-06 14:52:13 -08:00