diff options
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/terraform/transform_count_boundary.go')
-rw-r--r-- | vendor/github.com/hashicorp/terraform/terraform/transform_count_boundary.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/terraform/terraform/transform_count_boundary.go b/vendor/github.com/hashicorp/terraform/terraform/transform_count_boundary.go new file mode 100644 index 0000000..83415f3 --- /dev/null +++ b/vendor/github.com/hashicorp/terraform/terraform/transform_count_boundary.go | |||
@@ -0,0 +1,28 @@ | |||
1 | package terraform | ||
2 | |||
3 | import ( | ||
4 | "github.com/hashicorp/terraform/dag" | ||
5 | ) | ||
6 | |||
7 | // CountBoundaryTransformer adds a node that depends on everything else | ||
8 | // so that it runs last in order to clean up the state for nodes that | ||
9 | // are on the "count boundary": "foo.0" when only one exists becomes "foo" | ||
10 | type CountBoundaryTransformer struct{} | ||
11 | |||
12 | func (t *CountBoundaryTransformer) Transform(g *Graph) error { | ||
13 | node := &NodeCountBoundary{} | ||
14 | g.Add(node) | ||
15 | |||
16 | // Depends on everything | ||
17 | for _, v := range g.Vertices() { | ||
18 | // Don't connect to ourselves | ||
19 | if v == node { | ||
20 | continue | ||
21 | } | ||
22 | |||
23 | // Connect! | ||
24 | g.Connect(dag.BasicEdge(node, v)) | ||
25 | } | ||
26 | |||
27 | return nil | ||
28 | } | ||