From 79ef8f5442da1e4496a5c7b7cbb0905d952ce34d Mon Sep 17 00:00:00 2001 From: Chanwit Kaewkasi Date: Sat, 15 Jan 2022 18:31:41 +0700 Subject: [PATCH] fix display plan when drift detected in the backend disable mode --- controllers/terraform_controller.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/controllers/terraform_controller.go b/controllers/terraform_controller.go index 763cf4b9..9c7cee46 100644 --- a/controllers/terraform_controller.go +++ b/controllers/terraform_controller.go @@ -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