Skip to content

Commit 21fd606

Browse files
committed
OCPBUGS-22772: return Terraform statefile on error
Fixes a nil pointer dereference which occurs when there is an error during Terraform apply. A file needs to be written for the cluster asset, but there was a bug where no statefile was being returned upon an error in Terraform apply.
1 parent 321084a commit 21fd606

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/terraform/terraform.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,12 @@ func applyTerraform(tmpDir string, platform string, stage Stage, terraformDir st
280280
}
281281

282282
if applyErr != nil {
283-
return nil, nil, fmt.Errorf("error applying Terraform configs: %w", applyErr)
283+
return nil, stateFile, fmt.Errorf("error applying Terraform configs: %w", applyErr)
284284
}
285285

286286
outputs, err := Outputs(tmpDir, terraformDir)
287287
if err != nil {
288-
return nil, nil, errors.Wrapf(err, "could not get outputs from stage %q", stage.Name())
288+
return nil, stateFile, errors.Wrapf(err, "could not get outputs from stage %q", stage.Name())
289289
}
290290

291291
outputsFile = &asset.File{

0 commit comments

Comments
 (0)