execgraph: ResourceInstanceResultRef type alias

ResultRef[*states.ResourceInstanceObjectFull] is our current canonical
representation of the "final result" of applying changes to a resource
instance, and so it is going to appear a bunch in the plan and apply
engines.

The generic type is clunky to read and write though, so for this one in
particular we'll offer a more concise type alias that we can use for parts
of the API that are representing results from applying.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
This commit is contained in:
Martin Atkins
2025-12-11 16:12:34 -08:00
parent ce5944085f
commit 97ca07d05c
2 changed files with 12 additions and 3 deletions

View File

@@ -312,7 +312,7 @@ func (b *Builder) ManagedResourceObjectFinalPlan(
func (b *Builder) ApplyManagedResourceObjectChanges(
finalPlan ResultRef[*ManagedResourceObjectFinalPlan],
providerClient ResultRef[providers.Configured],
) ResultRef[*states.ResourceInstanceObjectFull] {
) ResourceInstanceResultRef {
b.mu.Lock()
defer b.mu.Unlock()
@@ -326,7 +326,7 @@ func (b *Builder) DataRead(
desiredInst ResultRef[*eval.DesiredResourceInstance],
providerClient ResultRef[providers.Configured],
waitFor AnyResultRef,
) ResultRef[*states.ResourceInstanceObjectFull] {
) ResourceInstanceResultRef {
b.mu.Lock()
defer b.mu.Unlock()
@@ -345,7 +345,7 @@ func (b *Builder) DataRead(
// Only one call is allowed per distinct [addrs.AbsResourceInstance] value. If
// two callers try to register for the same address then the second call will
// panic.
func (b *Builder) SetResourceInstanceFinalStateResult(addr addrs.AbsResourceInstance, result ResultRef[*states.ResourceInstanceObjectFull]) {
func (b *Builder) SetResourceInstanceFinalStateResult(addr addrs.AbsResourceInstance, result ResourceInstanceResultRef) {
b.mu.Lock()
defer b.mu.Unlock()

View File

@@ -20,6 +20,15 @@ type ResultRef[T any] interface {
AnyResultRef
}
// ResourceInstanceResultRef is an alias for the [ResultRef] type used when
// reporting the final result of applying changes to a resource instance
// object.
//
// We give this its own name just because this particular result type tends
// to be named in function signatures elsewhere in the system and the
// simple name is (subjectively) easier to read than the generic name.
type ResourceInstanceResultRef = ResultRef[*states.ResourceInstanceObjectFull]
// AnyResultRef is a type-erased [ResultRef], for data
// structures that only need to represent the relationships between results
// and not the types of those results.