mirror of https://github.com/pulumi/pulumi.git
![]() Fixes: #6934 With this snippet of code: ``` func main() { pulumi.Run(func(ctx *pulumi.Context) error { // Create an AWS resource (S3 Bucket) vpc, err := ec2.NewVpc(ctx, "main", &ec2.VpcArgs{ CidrBlock: pulumi.String("10.0.0.0/16"), }) if err != nil { return err } rt, err := ec2.NewRouteTable(ctx, "example", &ec2.RouteTableArgs{ VpcId: vpc.ID(), }) // Export the name of the bucket ctx.Export("rt", rt) return nil }) } ``` the CLI would panic on the diff as follows: ``` panic: fatal: An assertion has failed goroutine 249 [running]: github.com/pulumi/pulumi/sdk/v3/go/common/util/contract.failfast(...) /private/tmp/pulumi-20210422-70582-1bpvlru/sdk/go/common/util/contract/failfast.go:23 github.com/pulumi/pulumi/sdk/v3/go/common/util/contract.Assert(...) /private/tmp/pulumi-20210422-70582-1bpvlru/sdk/go/common/util/contract/assert.go:26 github.com/pulumi/pulumi/pkg/v3/engine.printPropertyValue(0xc0005d41b0, 0x57cce00, 0xc001da9050, 0x0, 0x1, 0x5932853, 0x4, 0x0) /private/tmp/pulumi-20210422-70582-1bpvlru/pkg/engine/diff.go:511 +0x1485 ``` This was due to the entire object being added to the output and the property being a ResourceReference On the changing of the code to use a switch statement, we can now include the ResourceReference and ensure that we catch any missing case statements with a panic as default This means the same piece of code now outputs to the CLI as follows: ``` Outputs: rt: { URN: "urn:pulumi:dev::testing-new-engine-diff::aws:ec2/routeTable:RouteTable::example" ID : "rtb-09b37608ec34f3b49" PackageVersion: "" } Resources: 3 unchanged Duration: 2s ``` |
||
---|---|---|
.. | ||
lifeycletest | ||
deployment.go | ||
destroy.go | ||
diff.go | ||
doc.go | ||
engine.go | ||
errors.go | ||
events.go | ||
eventsink.go | ||
import.go | ||
journal.go | ||
plugin_host.go | ||
plugins.go | ||
plugins_test.go | ||
project.go | ||
query.go | ||
refresh.go | ||
snapshot.go | ||
update.go | ||
update_test.go |