pulumi/pkg/codegen
Luke Hoban 6afefe050f
[codegen/go] Fix accessors on struct ptr outputs (#4456)
* [codegen/go] Fix accessors on struct ptr outputs

The accesor methods on nestred struct Ptr outputs were previously not accepting pointer typed inputs as they should, and would thus always panic if used.

The "simple" fix would be to just accept the pointer type and blindly dereference it.  But this doesn't seem like the right experience - it would make these accessors very unsafe to use in practice.

Instead, this PR implements the accessors on pointer-typed outputs as nil-coaslescing, always lifting the output type into a pointer type and flowing a nil value into the result type.  This ensures the accessor will not nil-deref, and that user code can handle the `nil` value itself (or use `.Apply` directly to implement more specialized behaviour).

Before:

```go
// Name of your S3 bucket.
func (o BuildStorageLocationPtrOutput) Bucket() pulumi.StringOutput {
	return o.ApplyT(func(v BuildStorageLocation) string { return v.Bucket }).(pulumi.StringOutput)
}
```

After:

```go
// Name of your S3 bucket.
func (o BuildStorageLocationPtrOutput) Bucket() pulumi.StringPtrOutput {
	return o.ApplyT(func(v *BuildStorageLocation) *string {
		if v == nil {
			return nil
		}
		return &v.Bucket
	}).(pulumi.StringPtrOutput)
}
```

However, due to the decision to have this more usable behaviour, this is a breaking change, as some/many accessors now return a pointer type when they previously did not.

Fixes pulumi/pulumi-azure#530.

* Mark nested property types as requiring ptr types

* Add CHANGELOG

* More fixes
2020-04-21 13:33:38 -07:00
..
docs [codegen/docs] Improve titles tags and meta descriptions (#4432) 2020-04-21 12:28:44 +01:00
dotnet Clean up the language-specific schema APIs. (#4454) 2020-04-20 16:36:05 -07:00
go [codegen/go] Fix accessors on struct ptr outputs (#4456) 2020-04-21 13:33:38 -07:00
hcl2 Codegen: collect imports from function calls. (#4445) 2020-04-21 10:24:42 -07:00
internal/test Codegen: collect imports from function calls. (#4445) 2020-04-21 10:24:42 -07:00
nodejs Codegen: collect imports from function calls. (#4445) 2020-04-21 10:24:42 -07:00
python Codegen: collect imports from function calls. (#4445) 2020-04-21 10:24:42 -07:00
schema Clean up the language-specific schema APIs. (#4454) 2020-04-20 16:36:05 -07:00
docs.go Generate links for primitive types. (#4386) 2020-04-15 12:56:28 -07:00
docs_test.go Remove non-relevant examples and empty examples section from docs comments (#4184) 2020-03-26 10:30:04 -07:00
utilities.go Breaking changes due to Feature 2.0 work 2020-04-14 09:30:25 +01:00