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
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{

View File

@ -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