pulumi/pkg/engine
Will Jones 1da0555b6a
Enable `pulumi:pulumi:getResource` to hydrate `Read` resources (#18070)
*Components* provide a means for Pulumi users to logically group and
abstract sets of resources. While authors of Pulumi programs can define
"local" components using e.g. the `ComponentResource` class of the
NodeJS or Python SDK, these can only be consumed by programs written in
the same language. Components implemented by provider `Construct`
implementations, however (often called "remote" components), can be
consumed by any appropriate client SDK, just like any other Pulumi
resource.

Despite their implementation involving gRPC protocol communications,
remote components offer many of the same features as local components.
For instance, just as it is possible for a local component's outputs to
contain references to its child resources, so may a remote component
return references to resources instantiated in its `Construct`
implementation. On the wire, these are serialized using resource URNs
and IDs. These values are then "hydrated" into fully fledged resource
values by the calling client SDK.

Hydration is powered by the `pulumi:pulumi:getResource` function. This
is an invoke offered by the so-called *built-in* provider, alongside
other core Pulumi concerns such as stack references. Under the hood,
`getResource` is implemented by looking up URNs in a table of resources
being managed by the executing program, and returning the appropriate
state to the caller.

Presently, this lookup only takes into account resources managed by
Pulumi (that is, *resource registrations*). It does not take into
account *reads* such as those caused by e.g. a `.get` call in a NodeJS
SDK. Consequently, if a `Construct` implementation performs a `.get` and
returns a reference to the read resource as an output, later hydrations
of that reference will fail. This is the cause of #17515.

This change fixes this by augmenting the built-in provider with a map of
read resources, which is updated as a deployment progresses just as the
list of registered resources being used already is. When a lookup in the
registrations map fails, the read map is tried, with an error being
raised only if that also fails. A pair of lifecycle tests are added to
verify that the behaviour works as intended.

Fixes #17515
2024-12-22 20:13:43 +00:00
..
lifecycletest Enable `pulumi:pulumi:getResource` to hydrate `Read` resources (#18070) 2024-12-22 20:13:43 +00:00
combinedManager.go Test SnapshotManager and Journal in engine tests (#15871) 2024-04-11 22:54:08 +00:00
debugging.go implement the engine bits for debugging support (#17072) 2024-08-30 10:31:28 +00:00
deployment.go Autonaming configuration in experimental mode (#17916) 2024-12-10 14:03:27 +00:00
deployment_test.go Clean up deployment options (#16357) 2024-06-11 13:37:57 +00:00
destroy.go Update the refresh/destroy warnings for parameterized packages (#18029) 2024-12-20 02:03:17 +00:00
detailedDiff.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
detailedDiff_test.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
doc.go Document Go packages (#6009) 2021-01-11 11:07:59 -07:00
engine.go [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
errors.go Centralise human-friendly error handling in the CLI (#17046) 2024-08-23 08:48:42 +00:00
events.go Use events to report downloads as system messages (#17019) 2024-09-03 12:12:04 +00:00
events_test.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
eventsink.go turn on the golangci-lint exhaustive linter (#15028) 2024-01-17 16:50:41 +00:00
import.go Clean up deployment options (#16357) 2024-06-11 13:37:57 +00:00
journal.go Introduce snapshot metadata (#17430) 2024-09-30 16:45:40 +00:00
plugin_host.go Bump gRPC dependencies and migrate `grpc.Dial` (#17701) 2024-11-06 18:36:10 +00:00
plugins.go Update the refresh/destroy warnings for parameterized packages (#18029) 2024-12-20 02:03:17 +00:00
plugins_test.go Update the refresh/destroy warnings for parameterized packages (#18029) 2024-12-20 02:03:17 +00:00
progress.go Use events to report downloads as system messages (#17019) 2024-09-03 12:12:04 +00:00
progress_test.go Use events to report downloads as system messages (#17019) 2024-09-03 12:12:04 +00:00
project.go Enable some more linting rules (#17456) 2024-10-03 17:37:13 +00:00
query.go Use events to report downloads as system messages (#17019) 2024-09-03 12:12:04 +00:00
refresh.go Update the refresh/destroy warnings for parameterized packages (#18029) 2024-12-20 02:03:17 +00:00
snapshot.go [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
update.go Update the refresh/destroy warnings for parameterized packages (#18029) 2024-12-20 02:03:17 +00:00
update_test.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00