pulumi/sdk/go
bors[bot] 20ee7fc734
Merge #12494
12494: [sdk/go] Track rehydrated components as dependencies r=justinvp a=justinvp

When expanding dependencies, local component resources act as aggregations of their descendants; rather than adding the component resource itself, each child resource is added as a dependency. Remote component resources, on the other hand, are added directly to the set, as they naturally act as aggregations of their children with respect to dependencies: the construction of a remote component always waits on the construction of its children.

46ccb5a22c/sdk/go/pulumi/rpc.go (L65-L91)

However, rehydrated components (i.e. instances of a component resource that have been recreated from a URN, typically via deserialization of a resource reference) aren't marked as a remote component and won't have any children from the SDK's perspective. And because of that, when their outputs are used, there won't be any dependencies kept for those outputs.

This change fixes rehydrated components to be marked as remote components, in the same way as "dependency resources" are marked as remote components, so that they are kept as a dependency.

This addresses cases where a component resource method is implemented in Go and the method returns results derived from the component's outputs. Inside the implementation of the provider's `Call`, the implementation will get a rehydrated instance of the component. Without this fix, the dependency on that component will not be kept in the returned output.

Here's a concrete example:

5d3372b4ae/tests/integration/construct_component_methods/testcomponent-go/main.go (L64-L68)

The above is a method implemented in a component provider. The `c *Component` receiver will be a rehydrated instance of the component. The method uses `pulumi.Sprintf` to create a result that combines some of the component's outputs. But the combined output that is returned won't have the dependency on the component kept, since the rehydrated component is a component and doesn't have any children. With the fix, the dependency will be kept and serialized as expected.

Part of #12471

Co-authored-by: Justin Van Patten <jvp@justinvp.com>
2023-03-24 21:48:52 +00:00
..
auto Closes PulumiCtx in Go AutoAPI during Up. 2023-03-22 18:13:01 -04:00
common go/common: Make DefaultSink thread-safe 2023-03-24 08:34:35 -07:00
pulumi [sdk/go] Track rehydrated components as dependencies 2023-03-24 13:49:10 -07:00
pulumi-language-go all: Fix revive issues 2023-03-21 08:55:11 -07:00
Makefile ci: Enable testing of language version sets 2022-09-21 09:48:38 -07:00
README.md `pulumi update` => `pulumi up` (#2702) 2019-05-06 14:00:18 -07:00

README.md

Pulumi Golang SDK

This directory contains support for writing Pulumi programs in the Go language. There are two aspects to this:

  • pulumi/ contains the client language bindings Pulumi program's code directly against;
  • pulumi-language-go/ contains the language host plugin that the Pulumi engine uses to orchestrate updates.

To author a Pulumi program in Go, simply say so in your Pulumi.yaml

name: <my-project>
runtime: go

and ensure you have pulumi-language-go on your path (it is distributed in the Pulumi download automatically).

By default, the language plugin will use your project's name, <my-project>, as the executable that it loads. This too must be on your path for the language provider to load it when you run pulumi preview or pulumi up.