]>
Commit | Line | Data |
---|---|---|
15c0b25d AP |
1 | package terraform |
2 | ||
3 | import ( | |
4 | "log" | |
5 | ||
107c1cdb ND |
6 | "github.com/hashicorp/terraform/configs" |
7 | "github.com/hashicorp/terraform/states" | |
15c0b25d AP |
8 | ) |
9 | ||
107c1cdb | 10 | // RemovedModuleTransformer implements GraphTransformer to add nodes indicating |
15c0b25d AP |
11 | // when a module was removed from the configuration. |
12 | type RemovedModuleTransformer struct { | |
107c1cdb ND |
13 | Config *configs.Config // root node in the config tree |
14 | State *states.State | |
15c0b25d AP |
15 | } |
16 | ||
17 | func (t *RemovedModuleTransformer) Transform(g *Graph) error { | |
18 | // nothing to remove if there's no state! | |
19 | if t.State == nil { | |
20 | return nil | |
21 | } | |
22 | ||
23 | for _, m := range t.State.Modules { | |
107c1cdb ND |
24 | cc := t.Config.DescendentForInstance(m.Addr) |
25 | if cc != nil { | |
15c0b25d AP |
26 | continue |
27 | } | |
28 | ||
107c1cdb ND |
29 | log.Printf("[DEBUG] %s is no longer in configuration\n", m.Addr) |
30 | g.Add(&NodeModuleRemoved{Addr: m.Addr}) | |
15c0b25d AP |
31 | } |
32 | return nil | |
33 | } |