From 3bd2293152f902de9c67830571d3bcb3c7294d94 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Thu, 17 May 2018 16:19:25 -0700 Subject: [PATCH] compare module by normalized path The onld logic for locating comparing module paths no longer worked, and we can simplify the comparison by using the addrs.ModuleInstance string. --- terraform/node_module_removed.go | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/terraform/node_module_removed.go b/terraform/node_module_removed.go index 94a2d64201..f681aa32ed 100644 --- a/terraform/node_module_removed.go +++ b/terraform/node_module_removed.go @@ -85,25 +85,13 @@ func (n *EvalDeleteModule) Eval(ctx EvalContext) (interface{}, error) { state.prune() // find the module and delete it -Modules: for i, m := range state.Modules { // Since state is still using our old-style []string path representation, // comparison is a little awkward. This can be simplified once state // is updated to use addrs.ModuleInstance too. - if len(m.Path) != len(n.Addr) { - continue Modules + if normalizeModulePath(m.Path).String() != n.Addr.String() { + continue } - for i, step := range n.Addr { - if step.InstanceKey != addrs.NoKey { - // Old-style state path can't have keys anyway, so this can - // never match. - continue Modules - } - if step.Name != m.Path[i] { - continue Modules - } - } - if !m.Empty() { // a targeted apply may leave module resources even without a config, // so just log this and return. @@ -113,6 +101,5 @@ Modules: state.Modules = append(state.Modules[:i], state.Modules[i+1:]...) break } - return nil, nil }