From 559f65bf3ddee783f9ba3462d64c3d16cd1f81f8 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Thu, 24 May 2018 14:36:32 -0700 Subject: [PATCH] core: Fix ignore_changes = all The initial rework of this function to support traversals didn't correctly handle the "all" case, due to a logic error where the ignoreAll branch could be visited only if ignoreChanges were non-empty, but yet the two are mutually exclusive in practice. Now we process ignoreAll separately from ignoreChanges, and invert the two loops so that we will visit all attributes regardless of what is in the ignoreChanges slice. --- terraform/eval_diff.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/terraform/eval_diff.go b/terraform/eval_diff.go index bb6b33268..f5884b873 100644 --- a/terraform/eval_diff.go +++ b/terraform/eval_diff.go @@ -254,10 +254,14 @@ func (n *EvalDiff) processIgnoreChanges(diff *InstanceDiff) error { // get the complete set of keys we want to ignore ignorableAttrKeys := make(map[string]bool) - for _, ignoredTraversal := range ignoreChanges { - ignoredKey := legacyFlatmapKeyForTraversal(ignoredTraversal) - for k := range attrs { - if ignoreAll || strings.HasPrefix(k, ignoredKey) { + for k := range attrs { + if ignoreAll { + ignorableAttrKeys[k] = true + continue + } + for _, ignoredTraversal := range ignoreChanges { + ignoredKey := legacyFlatmapKeyForTraversal(ignoredTraversal) + if k == ignoredKey || strings.HasPrefix(k, ignoredKey+".") { ignorableAttrKeys[k] = true } }