From 5d9cac85bcf4bcec563f7e9b1500c35fa416a097 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Mon, 9 Oct 2023 17:35:58 -0700 Subject: [PATCH] stackruntime: Emit "pending" events for component instance plan/apply Previously we did have an event for planning but it wasn't in quite the right place, and so could potentially appear "late" and mess up the event sequence. Now we'll always emit the pending event immediately before the planning or applying event, which is perhaps a little redundant but having these separated means that we might be able to create some space between them later if we find that we need to do some additional work after we know about a component instance but before we're reading to say that we're planning or applying it. --- .../stackruntime/internal/stackeval/component_instance.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/stacks/stackruntime/internal/stackeval/component_instance.go b/internal/stacks/stackruntime/internal/stackeval/component_instance.go index 92641abdf9..8f558c392d 100644 --- a/internal/stacks/stackruntime/internal/stackeval/component_instance.go +++ b/internal/stacks/stackruntime/internal/stackeval/component_instance.go @@ -444,6 +444,7 @@ func (c *ComponentInstance) CheckModuleTreePlan(ctx context.Context) (*plans.Pla addr := c.Addr() h := hooksFromContext(ctx) + hookSingle(ctx, hooksFromContext(ctx).PendingComponentInstancePlan, c.Addr()) seq, ctx := hookBegin(ctx, h.BeginComponentInstancePlan, h.ContextAttach, addr) decl := c.call.Declaration(ctx) @@ -612,6 +613,7 @@ func (c *ComponentInstance) ApplyModuleTreePlan(ctx context.Context, plan *plans decl := c.call.Declaration(ctx) h := hooksFromContext(ctx) + hookSingle(ctx, hooksFromContext(ctx).PendingComponentInstanceApply, c.Addr()) seq, ctx := hookBegin(ctx, h.BeginComponentInstanceApply, h.ContextAttach, addr) moduleTree := c.call.Config(ctx).ModuleTree(ctx) @@ -733,6 +735,7 @@ func (c *ComponentInstance) ApplyModuleTreePlan(ctx context.Context, plan *plans hookMore(ctx, seq, h.ReportComponentInstanceApplied, &hooks.ComponentInstanceChange{ Addr: addr, + // TODO: include counts for each type of change }) } @@ -850,8 +853,6 @@ func (c *ComponentInstance) PlanChanges(ctx context.Context) ([]stackplan.Planne var changes []stackplan.PlannedChange var diags tfdiags.Diagnostics - hookSingle(ctx, hooksFromContext(ctx).PendingComponentInstancePlan, c.Addr()) - _, moreDiags := c.CheckInputVariableValues(ctx, PlanPhase) diags = diags.Append(moreDiags)