]>
Commit | Line | Data |
---|---|---|
bae9f6d2 JC |
1 | package terraform |
2 | ||
3 | import ( | |
107c1cdb | 4 | "github.com/hashicorp/terraform/configs" |
bae9f6d2 JC |
5 | "github.com/hashicorp/terraform/dag" |
6 | ) | |
7 | ||
8 | // CountBoundaryTransformer adds a node that depends on everything else | |
9 | // so that it runs last in order to clean up the state for nodes that | |
10 | // are on the "count boundary": "foo.0" when only one exists becomes "foo" | |
107c1cdb ND |
11 | type CountBoundaryTransformer struct { |
12 | Config *configs.Config | |
13 | } | |
bae9f6d2 JC |
14 | |
15 | func (t *CountBoundaryTransformer) Transform(g *Graph) error { | |
107c1cdb ND |
16 | node := &NodeCountBoundary{ |
17 | Config: t.Config, | |
18 | } | |
bae9f6d2 JC |
19 | g.Add(node) |
20 | ||
21 | // Depends on everything | |
22 | for _, v := range g.Vertices() { | |
23 | // Don't connect to ourselves | |
24 | if v == node { | |
25 | continue | |
26 | } | |
27 | ||
28 | // Connect! | |
29 | g.Connect(dag.BasicEdge(node, v)) | |
30 | } | |
31 | ||
32 | return nil | |
33 | } |