Check for nil config in node_resource_refresh

While not normally possible, manual manipulation of the state and config
can cause us to end up with a nil config in
evalTreeManagedResourceNoState.

Regardless of how it got here, we can't ever assume the Config field is
not nil, and EvalInterpolate happily accepts a nil RawConfig
This commit is contained in:
James Bardin 2018-03-06 17:45:28 -05:00
parent ea50f455ed
commit 7fd6f97899
1 changed files with 7 additions and 1 deletions

View File

@ -213,10 +213,16 @@ func (n *NodeRefreshableManagedResourceInstance) evalTreeManagedResourceNoState(
// Determine the dependencies for the state. // Determine the dependencies for the state.
stateDeps := n.StateReferences() stateDeps := n.StateReferences()
// n.Config can be nil if the config and state don't match
var raw *config.RawConfig
if n.Config != nil {
raw = n.Config.RawConfig.Copy()
}
return &EvalSequence{ return &EvalSequence{
Nodes: []EvalNode{ Nodes: []EvalNode{
&EvalInterpolate{ &EvalInterpolate{
Config: n.Config.RawConfig.Copy(), Config: raw,
Resource: resource, Resource: resource,
Output: &resourceConfig, Output: &resourceConfig,
}, },