pulumi / pulumi-go-provider

A framework for building Go Providers for Pulumi
Apache License 2.0
32 stars 10 forks source link

[infer] Richer value representation for custom resources #212

Open iwahbe opened 5 months ago

iwahbe commented 5 months ago

Hello!

Issue details

Many infer functions operate on strongly typed values, but there is currently no way for these values to encode that a location is secret. We should enhance the surface area of types to allow for this richer information.

Related: https://github.com/pulumi/pulumi-go-provider/pull/155

Affected area/feature

iwahbe commented 5 months ago

If we wanted to be really fancy (and a bit magical), we could implement pointer based lookup functions for input structs:

func IsSecret[T any](p.Context, *T) bool
func IsComputed[T any](p.Context, *T) bool

Working similarly to infer.Annotor, these functions would be used to index into a precomputed metadata table on the input type by value location. This would require that inputs are passed by reference to preserve location, and would return false for any moved value.

iwahbe commented 1 day ago

This is a breaking change, but I'm removing 1.0.0-blocker since I don't think we have the time to address this issue before we release 1.0.0. We can continue to iterate and release an infer/v2, to be made default in 2.0.0.