core: EvalApply should pass configuration value to provider

This allows the provider to distinguish whether a particular value is set
in configuration or whether it's coming from prior state. It has no
particular purpose other than that.
This commit is contained in:
Martin Atkins 2018-09-10 14:42:23 -07:00
parent b83a563cf0
commit 27745af0ea
1 changed files with 12 additions and 3 deletions

View File

@ -53,15 +53,24 @@ func (n *EvalApply) Eval(ctx EvalContext) (interface{}, error) {
*n.CreateNew = (change.Action == plans.Create || change.Action == plans.Replace)
}
configVal := cty.NullVal(cty.DynamicPseudoType) // TODO: Populate this when n.Config is non-nil; will need config and provider schema in here
configVal := cty.NullVal(cty.DynamicPseudoType)
if n.Config != nil {
var configDiags tfdiags.Diagnostics
keyData := EvalDataForInstanceKey(n.Addr.Key)
configVal, _, configDiags = ctx.EvaluateBlock(n.Config.Config, schema, nil, keyData)
diags = diags.Append(configDiags)
if configDiags.HasErrors() {
return nil, diags.Err()
}
}
log.Printf("[DEBUG] %s: applying the planned %s change", n.Addr.Absolute(ctx.Path()), change.Action)
resp := provider.ApplyResourceChange(providers.ApplyResourceChangeRequest{
TypeName: n.Addr.Resource.Type,
PriorState: change.Before,
Config: configVal, // TODO
Config: configVal,
PlannedState: change.After,
PlannedPrivate: change.Private, // TODO
PlannedPrivate: change.Private,
})
applyDiags := resp.Diagnostics
if n.Config != nil {