3 // NodeAbstractCountResource should be embedded instead of NodeAbstractResource
4 // if the resource has a `count` value that needs to be expanded.
6 // The embedder should implement `DynamicExpand` to process the count.
7 type NodeAbstractCountResource struct {
10 // Validate, if true, will perform the validation for the count.
11 // This should only be turned on for the "validate" operation.
16 func (n *NodeAbstractCountResource) EvalTree() EvalNode {
17 // We only check if the count is computed if we're not validating.
18 // If we're validating we allow computed counts since they just turn
19 // into more computed values.
20 var evalCountCheckComputed EvalNode
22 evalCountCheckComputed = &EvalCountCheckComputed{Resource: n.Config}
27 // The EvalTree for a plannable resource primarily involves
28 // interpolating the count since it can contain variables
29 // we only just received access to.
31 // With the interpolated count, we can then DynamicExpand
32 // into the proper number of instances.
33 &EvalInterpolate{Config: n.Config.RawCount},
35 // Check if the count is computed
36 evalCountCheckComputed,
38 // If validation is enabled, perform the validation
40 If: func(ctx EvalContext) (bool, error) {
41 return n.Validate, nil
44 Then: &EvalValidateCount{Resource: n.Config},
47 &EvalCountFixZeroOneBoundary{Resource: n.Config},