Added run task support for post plan run stage, removed pre apply

This commit stems from the change to make post plan the default run task stage, at the
time of this commit's writing! Since pre apply is under internal revision, we have removed
the block that polls the pre apply stage until the team decides to re-add support for pre apply
run tasks.
This commit is contained in:
Sebastian Rivera 2022-02-01 16:41:29 -05:00
parent 542e3f901d
commit 126d6df088

View File

@ -346,6 +346,22 @@ in order to capture the filesystem context the remote workspace expects:
// status of the run will be "errored", but there is still policy
// information which should be shown.
// Await post-plan run tasks
integration := &IntegrationContext{
B: b,
StopContext: stopCtx,
CancelContext: cancelCtx,
Op: op,
Run: r,
}
if stageID := getTaskStageIDByName(r.TaskStages, tfe.PostPlan); stageID != nil {
err = b.runTasks(integration, integration.BeginOutput("Run Tasks (post-plan)"), *stageID)
if err != nil {
return r, err
}
}
// Show any cost estimation output.
if r.CostEstimate != nil {
err = b.costEstimate(stopCtx, cancelCtx, op, r)
@ -362,28 +378,14 @@ in order to capture the filesystem context the remote workspace expects:
}
}
// Await pre-apply run tasks
if len(r.TaskStages) > 0 {
integration := &IntegrationContext{
B: b,
StopContext: stopCtx,
CancelContext: cancelCtx,
Op: op,
Run: r,
}
if stageID := getTaskStageIDByName(r.TaskStages, tfe.PreApply); stageID != nil {
err = b.runTasks(integration, integration.BeginOutput("Run Tasks (pre-apply)"), *stageID)
if err != nil {
return r, err
}
}
}
return r, nil
}
func getTaskStageIDByName(stages []*tfe.TaskStage, stageName tfe.Stage) *string {
if len(stages) == 0 {
return nil
}
for _, stage := range stages {
if stage.Stage == stageName {
return &stage.ID