pulumi/pkg/codegen
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
..
docs Add data attribute tag for swifttype to resource property element (#9226) 2022-03-21 10:36:04 -07:00
dotnet Expose the check function (#9176) 2022-03-16 11:42:30 -07:00
go [codegen/go] Update Go SDK function output to check for errors (#9274) 2022-03-24 20:11:53 -07:00
hcl2 ci: radical idea - what if slow tests & no stdout makes GH consider runner dead? 2022-03-06 14:52:13 -08:00
importer ci: radical idea - what if slow tests & no stdout makes GH consider runner dead? 2022-03-06 14:52:13 -08:00
nodejs Expose the check function (#9176) 2022-03-16 11:42:30 -07:00
pcl PCL: Use resource aliases when resolving a type (#9238) 2022-03-18 11:48:39 -07:00
python Expose the check function (#9176) 2022-03-16 11:42:30 -07:00
schema ci: radical idea - what if slow tests & no stdout makes GH consider runner dead? 2022-03-06 14:52:13 -08:00
testing [codegen/go] Update Go SDK function output to check for errors (#9274) 2022-03-24 20:11:53 -07:00
docs.go Support "lifting" single-valued method returns to their return type (#8111) 2021-10-01 11:33:02 -07:00
docs_test.go ci: radical idea - what if slow tests & no stdout makes GH consider runner dead? 2022-03-06 14:52:13 -08:00
utilities.go [codegen/dotnet] Allow generated SDKs to have a global namespace other then `Pulumi` (#8735) 2022-01-21 12:58:11 -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
utilities_types.go [codegen/go] Call site defaults for Pulumi Object types (#8411) 2021-11-23 15:10:15 -08:00