Open EronWright opened 2 months ago
While I agree this is a good example scenario showing that the current Map
output makes for a difficult function to write, I don't think it's safe to change the return value to an MapOutput
.
The issue with an MapOutput
is the whole value may resolve to unknown
and there's no way on the engine/provider protocol to indicate that the entire state of a resource is unknown. We always expect to know what the top-level shape of a resource is, i.e. what top level keys are set. In the case where the props resolve to unknown the only value the SDK could send back to the engine is an empty map, and the behaviour of that is definitely not the same as being able to say it's an unknown map.
In this case, I think the best thing to do is to rewrite the apply to use all
on the 'metadata' and 'spec' keys but to return just the 'spec' map to set the 'spec' property with.
There's probably output combinators we could write to make this easier, especially with all the nesting, and the Go SDK is definitely the most tricky language to work with outputs in due to it's non-generic nature.
Consider changing the transform API to accept an Output for the
Props
(as a whole). The current approach acceptspulumi.Map
(amap[string]Input
), which is difficult to work with, e.g. when transforming inputs asynchronously. One turns to usinginternals.UnsafeAwaitOutput
as a workaround (see the innertransform
function in the examples), but it would be preferable to simply do:Here's a couple of examples, showing complex transformations of a Kubernetes object (
metadata
,spec
as input). Observe how the metadata property is used to adjust the spec property (deeply).