diff --git a/terraform/transform_removed_modules.go b/terraform/transform_removed_modules.go index 08816f10f..2e05edbaa 100644 --- a/terraform/transform_removed_modules.go +++ b/terraform/transform_removed_modules.go @@ -2,12 +2,12 @@ package terraform import ( "log" - "strings" "github.com/hashicorp/terraform/config/module" - "github.com/hashicorp/terraform/dag" ) +// RemoveModuleTransformer implements GraphTransformer to add nodes indicating +// when a module was removed from the configuration. type RemovedModuleTransformer struct { Module *module.Tree // root module State *State @@ -19,17 +19,6 @@ func (t *RemovedModuleTransformer) Transform(g *Graph) error { return nil } - // get a map of all nodes by path, so we can connect anything that might be - // in the module - refMap := map[string][]dag.Vertex{} - for _, v := range g.Vertices() { - if pn, ok := v.(GraphNodeSubPath); ok { - path := normalizeModulePath(pn.Path())[1:] - p := modulePrefixStr(path) - refMap[p] = append(refMap[p], v) - } - } - for _, m := range t.State.Modules { c := t.Module.Child(m.Path[1:]) if c != nil { @@ -37,19 +26,7 @@ func (t *RemovedModuleTransformer) Transform(g *Graph) error { } log.Printf("[DEBUG] module %s no longer in config\n", modulePrefixStr(m.Path)) - - node := &NodeModuleRemoved{PathValue: m.Path} - g.Add(node) - - // connect this to anything that contains the module's path - refPath := modulePrefixStr(m.Path) - for p, nodes := range refMap { - if strings.HasPrefix(p, refPath) { - for _, parent := range nodes { - g.Connect(dag.BasicEdge(node, parent)) - } - } - } + g.Add(&NodeModuleRemoved{PathValue: m.Path}) } return nil }