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.
pull/34738/head
Martin Atkins 3 years ago
parent c4d7ee93fb
commit 1943ed2395

@ -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

Loading…
Cancel
Save