core: evalTreeManagedScaleOutResource -> evalTreeManagedResourceNoState

We want to be a bit more explicit here as to when this eval sequence is
carried out. The why is now in the top-level comments.
This commit is contained in:
Chris Marchesi 2017-06-23 17:35:30 -07:00
parent 0e3aedcea3
commit b486780cf0

View File

@ -94,7 +94,7 @@ func (n *NodeRefreshableManagedResourceInstance) EvalTree() EvalNode {
switch mode := n.Addr.Mode; mode { switch mode := n.Addr.Mode; mode {
case config.ManagedResourceMode: case config.ManagedResourceMode:
if n.ResourceState == nil { if n.ResourceState == nil {
return n.evalTreeManagedScaleOutResource() return n.evalTreeManagedResourceNoState()
} }
return n.evalTreeManagedResource() return n.evalTreeManagedResource()
@ -173,7 +173,18 @@ func (n *NodeRefreshableManagedResourceInstance) evalTreeManagedResource() EvalN
} }
} }
func (n *NodeRefreshableManagedResourceInstance) evalTreeManagedScaleOutResource() EvalNode { // evalTreeManagedResourceNoState produces an EvalSequence for refresh resource
// nodes that don't have state attached. An example of where this functionality
// is useful is when a resource that already exists in state is being scaled
// out, ie: has its resource count increased. In this case, the scaled out node
// needs to be available to other nodes (namely data sources) that may depend
// on it for proper interpolation, or confusing "index out of range" errors can
// occur.
//
// The steps in this sequence are very similar to the steps carried out in
// plan, but nothing is done with the diff after it is created - it is dropped,
// and its changes are not counted in the UI.
func (n *NodeRefreshableManagedResourceInstance) evalTreeManagedResourceNoState() EvalNode {
// Declare a bunch of variables that are used for state during // Declare a bunch of variables that are used for state during
// evaluation. Most of this are written to by-address below. // evaluation. Most of this are written to by-address below.
var provider ResourceProvider var provider ResourceProvider