From 97ca07d05c3987aadf8a68c28d1614c0ea282c96 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Thu, 11 Dec 2025 16:12:34 -0800 Subject: [PATCH] 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 --- internal/engine/internal/execgraph/builder.go | 6 +++--- internal/engine/internal/execgraph/result.go | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/internal/engine/internal/execgraph/builder.go b/internal/engine/internal/execgraph/builder.go index 977b4c1578..63ec987baf 100644 --- a/internal/engine/internal/execgraph/builder.go +++ b/internal/engine/internal/execgraph/builder.go @@ -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() diff --git a/internal/engine/internal/execgraph/result.go b/internal/engine/internal/execgraph/result.go index 57351acab2..8a3cc26be5 100644 --- a/internal/engine/internal/execgraph/result.go +++ b/internal/engine/internal/execgraph/result.go @@ -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.