From 511afcd43a591e2e03080137ee64c14bb575d27d Mon Sep 17 00:00:00 2001 From: Chris Arcand Date: Fri, 29 Oct 2021 21:23:28 -0500 Subject: [PATCH] command: Adjust skipping of resource counts for any remote implementation When using the Terraform Cloud integration - like the 'remote' backend - resource count output should be suppressed if those counts are being rendered remotely. This generalizes this to the shared BackendWithRemoteTerraformVersion interface. --- internal/command/apply.go | 7 +++---- internal/command/meta_backend.go | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/command/apply.go b/internal/command/apply.go index 7405bddf0..2ae8a6378 100644 --- a/internal/command/apply.go +++ b/internal/command/apply.go @@ -5,7 +5,6 @@ import ( "strings" "github.com/hashicorp/terraform/internal/backend" - remoteBackend "github.com/hashicorp/terraform/internal/backend/remote" "github.com/hashicorp/terraform/internal/command/arguments" "github.com/hashicorp/terraform/internal/command/views" "github.com/hashicorp/terraform/internal/plans/planfile" @@ -130,9 +129,9 @@ func (c *ApplyCommand) Run(rawArgs []string) int { return op.Result.ExitStatus() } - // Render the resource count and outputs, unless we're using the remote - // backend locally, in which case these are rendered remotely - if rb, isRemoteBackend := be.(*remoteBackend.Remote); !isRemoteBackend || rb.IsLocalOperations() { + // Render the resource count and outputs, unless those counts are being + // rendered already in a remote Terraform process. + if rb, isRemoteBackend := be.(BackendWithRemoteTerraformVersion); !isRemoteBackend || rb.IsLocalOperations() { view.ResourceCount(args.State.StateOutPath) if !c.Destroy && op.State != nil { view.Outputs(op.State.RootModule().OutputValues) diff --git a/internal/command/meta_backend.go b/internal/command/meta_backend.go index 4167964a9..75eab4351 100644 --- a/internal/command/meta_backend.go +++ b/internal/command/meta_backend.go @@ -60,6 +60,7 @@ type BackendOpts struct { type BackendWithRemoteTerraformVersion interface { IgnoreVersionConflict() VerifyWorkspaceTerraformVersion(workspace string) tfdiags.Diagnostics + IsLocalOperations() bool } // Backend initializes and returns the backend for this CLI session.