From 37569f5cc383fc7b568825107cd73e939a156d78 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Wed, 23 Sep 2020 11:09:42 -0400 Subject: [PATCH] insert PlanRefresh into the context --- backend/local/backend_local.go | 5 +++++ backend/local/backend_plan_test.go | 1 + backend/local/backend_refresh.go | 3 +++ 3 files changed, 9 insertions(+) diff --git a/backend/local/backend_local.go b/backend/local/backend_local.go index fdbec1b74..b4d6002c0 100644 --- a/backend/local/backend_local.go +++ b/backend/local/backend_local.go @@ -78,6 +78,11 @@ func (b *Local) context(op *backend.Operation) (*terraform.Context, *configload. opts.Targets = op.Targets opts.UIInput = op.UIIn + opts.SkipRefresh = op.Type == backend.OperationTypePlan && !op.PlanRefresh + if opts.SkipRefresh { + log.Printf("[DEBUG] backend/local: skipping refresh of managed resources") + } + // Load the latest state. If we enter contextFromPlanFile below then the // state snapshot in the plan file must match this, or else it'll return // error diagnostics. diff --git a/backend/local/backend_plan_test.go b/backend/local/backend_plan_test.go index 09fd11a95..2c337870c 100644 --- a/backend/local/backend_plan_test.go +++ b/backend/local/backend_plan_test.go @@ -678,6 +678,7 @@ func TestLocal_planOutPathNoChange(t *testing.T) { Type: "local", Config: cfgRaw, } + op.PlanRefresh = true run, err := b.Operation(context.Background(), op) if err != nil { diff --git a/backend/local/backend_refresh.go b/backend/local/backend_refresh.go index 3a4343b86..af6058dc7 100644 --- a/backend/local/backend_refresh.go +++ b/backend/local/backend_refresh.go @@ -42,6 +42,9 @@ func (b *Local) opRefresh( } } + // Refresh now happens via a plan, so we need to ensure this is enabled + op.PlanRefresh = true + // Get our context tfCtx, _, opState, contextDiags := b.context(op) diags = diags.Append(contextDiags)