github.com/pbthorste/terraform@v0.8.6-0.20170127005045-deb56bd93da2/terraform/node_resource_abstract_count.go (about)

     1  package terraform
     2  
     3  // NodeAbstractCountResource should be embedded instead of NodeAbstractResource
     4  // if the resource has a `count` value that needs to be expanded.
     5  //
     6  // The embedder should implement `DynamicExpand` to process the count.
     7  type NodeAbstractCountResource struct {
     8  	*NodeAbstractResource
     9  
    10  	// Validate, if true, will perform the validation for the count.
    11  	// This should only be turned on for the "validate" operation.
    12  	Validate bool
    13  }
    14  
    15  // GraphNodeEvalable
    16  func (n *NodeAbstractCountResource) EvalTree() EvalNode {
    17  	return &EvalSequence{
    18  		Nodes: []EvalNode{
    19  			// The EvalTree for a plannable resource primarily involves
    20  			// interpolating the count since it can contain variables
    21  			// we only just received access to.
    22  			//
    23  			// With the interpolated count, we can then DynamicExpand
    24  			// into the proper number of instances.
    25  			&EvalInterpolate{Config: n.Config.RawCount},
    26  
    27  			&EvalCountCheckComputed{Resource: n.Config},
    28  
    29  			// If validation is enabled, perform the validation
    30  			&EvalIf{
    31  				If: func(ctx EvalContext) (bool, error) {
    32  					return n.Validate, nil
    33  				},
    34  
    35  				Then: &EvalValidateCount{Resource: n.Config},
    36  			},
    37  
    38  			&EvalCountFixZeroOneBoundary{Resource: n.Config},
    39  		},
    40  	}
    41  }