Enhance Pulumi StackReference Interface with Typed Outputs #527
Labels
area/api
User visible API
area/core
The SDK's core code
impact/usability
Something that impacts users' ability to use the product easily and intuitively
kind/enhancement
New feature or request without workaround
size/M
Estimated effort to complete (up to 5 days).
Milestone
Description:
The current
StackReference
in Pulumi uses a stringly typed interface that necessitates callinggetOutput(key: String)
to retrieve anOutput[Option[JsValue]]
andrequireOutput(key: String)
to fetch anOutput[JsValue]
. Both methods demand manual type conversion fromJsValue
, which is error-prone.Issue:
Develop a type-safe API that allows direct deserialization into predefined types, maintaining backward compatibility with the existing API.
Proposed Solution:
Let's assume this case class as representation of outputs of a referred stack:
Simple variant:
Implement a semiauto derivation pattern for the
StackReferenceOutputs
typeclass to manage serialization while allowing for customizations. Add a method toStackReference
that provides typed outputs directly:More involved variant:
Introduce a new API for
StackReference
that supports typed outputs through a generic type parameter. Define aPlatform
case class for expected outputs likekubeconfig
andnodes
.Adapt the
StackReferenceFactory
to use type classes for deserialization.The text was updated successfully, but these errors were encountered: