mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Merge pull request #32708 from mrinalirao/mr/taskStage-race
Bug Fix where CLI exits if run is not confirmable.
This commit is contained in:
commit
3d1a58d5b5
@ -97,8 +97,14 @@ func (b *Cloud) runTaskStage(ctx *IntegrationContext, output IntegrationOutputWr
|
||||
case tfe.TaskStagePending:
|
||||
// Waiting for it to start
|
||||
return true, nil
|
||||
case tfe.TaskStageRunning:
|
||||
if _, e := processSummarizers(ctx, output, stage, summarizers, errs); e != nil {
|
||||
errs = e
|
||||
}
|
||||
// not a terminal status so we continue to poll
|
||||
return true, nil
|
||||
// Note: Terminal statuses need to print out one last time just in case
|
||||
case tfe.TaskStageRunning, tfe.TaskStagePassed:
|
||||
case tfe.TaskStagePassed:
|
||||
ok, e := processSummarizers(ctx, output, stage, summarizers, errs)
|
||||
if e != nil {
|
||||
errs = e
|
||||
@ -176,6 +182,8 @@ func (b *Cloud) processStageOverrides(context *IntegrationContext, output Integr
|
||||
if err != errRunOverridden {
|
||||
if _, err = b.client.TaskStages.Override(context.StopContext, taskStageID, tfe.TaskStageOverrideOptions{}); err != nil {
|
||||
return false, generalError(fmt.Sprintf("Failed to override policy check.\n%s", runUrl), err)
|
||||
} else {
|
||||
return true, nil
|
||||
}
|
||||
} else {
|
||||
output.Output(fmt.Sprintf("The run needs to be manually overridden or discarded.\n%s\n", runUrl))
|
||||
|
@ -220,6 +220,7 @@ func TestTaskStageOverride(t *testing.T) {
|
||||
isError bool
|
||||
errMsg string
|
||||
input *mockInput
|
||||
cont bool
|
||||
}{
|
||||
"override-pass": {
|
||||
taskStageID: "ts-pass",
|
||||
@ -228,6 +229,7 @@ func TestTaskStageOverride(t *testing.T) {
|
||||
"→→ [bold]Override": "override",
|
||||
}),
|
||||
errMsg: "",
|
||||
cont: true,
|
||||
},
|
||||
"override-fail": {
|
||||
taskStageID: "ts-err",
|
||||
@ -236,6 +238,7 @@ func TestTaskStageOverride(t *testing.T) {
|
||||
"→→ [bold]Override": "override",
|
||||
}),
|
||||
errMsg: "",
|
||||
cont: false,
|
||||
},
|
||||
"skip-override": {
|
||||
taskStageID: "ts-err",
|
||||
@ -244,11 +247,12 @@ func TestTaskStageOverride(t *testing.T) {
|
||||
input: testInput(t, map[string]string{
|
||||
"→→ [bold]Override": "no",
|
||||
}),
|
||||
cont: false,
|
||||
},
|
||||
}
|
||||
for _, c := range cases {
|
||||
integrationContext.Op.UIIn = c.input
|
||||
_, err := b.processStageOverrides(integrationContext, writer, c.taskStageID)
|
||||
cont, err := b.processStageOverrides(integrationContext, writer, c.taskStageID)
|
||||
if c.isError {
|
||||
if err == nil {
|
||||
t.Fatalf("Expected to fail with some error")
|
||||
@ -264,5 +268,8 @@ func TestTaskStageOverride(t *testing.T) {
|
||||
t.Fatalf("Expected to pass, got err: %s", err)
|
||||
}
|
||||
}
|
||||
if c.cont != cont {
|
||||
t.Fatalf("expected polling continue: %t, got: %t", c.cont, cont)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user