From 1943ed2395eb789edd714bc1f8a569ade06d72f0 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Fri, 6 Oct 2023 16:48:47 -0700 Subject: [PATCH] stackruntime: Emit some more progress hooks during the apply phase This is not quite comprehensive yet, but echoes the main component start/end events we emit during the planning phase, and some of the resource-instance-related events. The rpcapi layer is not yet consuming all of these events and so most of this will just be no-op right now; we'll add the rpcapi translation layer for these in subsequent commits. --- .../internal/stackeval/component_instance.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/internal/stacks/stackruntime/internal/stackeval/component_instance.go b/internal/stacks/stackruntime/internal/stackeval/component_instance.go index 2f52d943d3..92641abdf9 100644 --- a/internal/stacks/stackruntime/internal/stackeval/component_instance.go +++ b/internal/stacks/stackruntime/internal/stackeval/component_instance.go @@ -611,7 +611,8 @@ func (c *ComponentInstance) ApplyModuleTreePlan(ctx context.Context, plan *plans addr := c.Addr() decl := c.call.Declaration(ctx) - // TODO: Emit a "begin component instance apply" hook event + h := hooksFromContext(ctx) + seq, ctx := hookBegin(ctx, h.BeginComponentInstanceApply, h.ContextAttach, addr) moduleTree := c.call.Config(ctx).ModuleTree(ctx) if moduleTree == nil { @@ -642,14 +643,12 @@ func (c *ComponentInstance) ApplyModuleTreePlan(ctx context.Context, plan *plans tfCtx, err := terraform.NewContext(&terraform.ContextOpts{ Hooks: []terraform.Hook{ - // TODO: Pass the hook sequence started by the "begin component - // instance apply" hook event, once there is one. - /*&componentInstanceTerraformHook{ + &componentInstanceTerraformHook{ ctx: ctx, seq: seq, hooks: hooksFromContext(ctx), addr: c.Addr(), - },*/ + }, }, PreloadedProviderSchemas: providerSchemas, }) @@ -730,13 +729,17 @@ func (c *ComponentInstance) ApplyModuleTreePlan(ctx context.Context, plan *plans if newState != nil { // TODO: Emit resource-instance-level "applied" events for all - // resource instances mentioned in the state. + // resource instances that were affected by applying this plan. + + hookMore(ctx, seq, h.ReportComponentInstanceApplied, &hooks.ComponentInstanceChange{ + Addr: addr, + }) } if diags.HasErrors() { - // TODO: Emit a "component instance apply errored" hook event + hookMore(ctx, seq, h.ErrorComponentInstanceApply, addr) } else { - // TODO: Emit a "component instance apply complete" hook event + hookMore(ctx, seq, h.EndComponentInstanceApply, addr) } return newState, diags