Skip to content

Commit

Permalink
fix display plan when drift detected in the backend disable mode
Browse files Browse the repository at this point in the history
  • Loading branch information
chanwit committed Jan 15, 2022
1 parent 6b850cd commit 79ef8f5
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions controllers/terraform_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,14 +632,20 @@ func (r *TerraformReconciler) detectDrift(ctx context.Context, terraform infrav1
}

if drifted {
rawOutput, err := tf.ShowPlanFileRaw(ctx, driftFilename)
if err != nil {
return infrav1.TerraformNotReady(
terraform,
revision,
infrav1.DriftDetectionFailedReason,
err.Error(),
), err
var rawOutput string
if r.backendCompletelyDisable(terraform) {
rawOutput = "not available"
} else {
var err error
rawOutput, err = tf.ShowPlanFileRaw(ctx, driftFilename)
if err != nil {
return infrav1.TerraformNotReady(
terraform,
revision,
infrav1.DriftDetectionFailedReason,
err.Error(),
), err
}
}

// If drift detected & we use the auto mode, then we continue
Expand Down

0 comments on commit 79ef8f5

Please # to comment.