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.
This commit is contained in:
Martin Atkins 2018-08-28 16:38:37 -07:00
parent 20adb9d9b7
commit 182e783885
2 changed files with 14 additions and 11 deletions

View File

@ -22,9 +22,10 @@ type EvalReadDataDiff struct {
ProviderAddr addrs.AbsProviderConfig ProviderAddr addrs.AbsProviderConfig
ProviderSchema **ProviderSchema ProviderSchema **ProviderSchema
Output **plans.ResourceInstanceChange Output **plans.ResourceInstanceChange
OutputValue *cty.Value OutputValue *cty.Value
OutputState **states.ResourceInstanceObject OutputConfigValue *cty.Value
OutputState **states.ResourceInstanceObject
// Set Previous when re-evaluating diff during apply, to ensure that // Set Previous when re-evaluating diff during apply, to ensure that
// the "Destroy" flag is preserved. // the "Destroy" flag is preserved.
@ -114,10 +115,12 @@ func (n *EvalReadDataDiff) Eval(ctx EvalContext) (interface{}, error) {
if n.Output != nil { if n.Output != nil {
*n.Output = change *n.Output = change
} }
if n.OutputValue != nil { if n.OutputValue != nil {
*n.OutputValue = change.After *n.OutputValue = change.After
} }
if n.OutputConfigValue != nil {
*n.OutputConfigValue = configVal
}
if n.OutputState != nil { if n.OutputState != nil {
state := &states.ResourceInstanceObject{ state := &states.ResourceInstanceObject{

View File

@ -145,13 +145,13 @@ func (n *NodeRefreshableDataResourceInstance) EvalTree() EvalNode {
}, },
&EvalReadDataDiff{ &EvalReadDataDiff{
Addr: addr.Resource, Addr: addr.Resource,
Config: n.Config, Config: n.Config,
ProviderAddr: n.ResolvedProvider, ProviderAddr: n.ResolvedProvider,
ProviderSchema: &providerSchema, ProviderSchema: &providerSchema,
Output: &change, Output: &change,
OutputValue: &configVal, OutputConfigValue: &configVal,
OutputState: &state, OutputState: &state,
}, },
// The rest of this pass can proceed only if there are no // The rest of this pass can proceed only if there are no