From 182e7838858a39f25029cdbcb77fb433c8ded3a7 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Tue, 28 Aug 2018 16:38:37 -0700 Subject: [PATCH] core: EvalReadDataDiff to output direct config value alongside planned We're now writing the "planned new value" to OutputValue, but the data resource nodes during refresh need to see the verbatim config value in order to decide whether read must be deferred to the apply phase, so we'll optionally export that here too. --- terraform/eval_read_data.go | 11 +++++++---- terraform/node_data_refresh.go | 14 +++++++------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/terraform/eval_read_data.go b/terraform/eval_read_data.go index f9924b29e..2eb9960d3 100644 --- a/terraform/eval_read_data.go +++ b/terraform/eval_read_data.go @@ -22,9 +22,10 @@ type EvalReadDataDiff struct { ProviderAddr addrs.AbsProviderConfig ProviderSchema **ProviderSchema - Output **plans.ResourceInstanceChange - OutputValue *cty.Value - OutputState **states.ResourceInstanceObject + Output **plans.ResourceInstanceChange + OutputValue *cty.Value + OutputConfigValue *cty.Value + OutputState **states.ResourceInstanceObject // Set Previous when re-evaluating diff during apply, to ensure that // the "Destroy" flag is preserved. @@ -114,10 +115,12 @@ func (n *EvalReadDataDiff) Eval(ctx EvalContext) (interface{}, error) { if n.Output != nil { *n.Output = change } - if n.OutputValue != nil { *n.OutputValue = change.After } + if n.OutputConfigValue != nil { + *n.OutputConfigValue = configVal + } if n.OutputState != nil { state := &states.ResourceInstanceObject{ diff --git a/terraform/node_data_refresh.go b/terraform/node_data_refresh.go index 65da5dffb..1993faf2d 100644 --- a/terraform/node_data_refresh.go +++ b/terraform/node_data_refresh.go @@ -145,13 +145,13 @@ func (n *NodeRefreshableDataResourceInstance) EvalTree() EvalNode { }, &EvalReadDataDiff{ - Addr: addr.Resource, - Config: n.Config, - ProviderAddr: n.ResolvedProvider, - ProviderSchema: &providerSchema, - Output: &change, - OutputValue: &configVal, - OutputState: &state, + Addr: addr.Resource, + Config: n.Config, + ProviderAddr: n.ResolvedProvider, + ProviderSchema: &providerSchema, + Output: &change, + OutputConfigValue: &configVal, + OutputState: &state, }, // The rest of this pass can proceed only if there are no