"strings"
"github.com/hashicorp/terraform/config"
+ "github.com/hashicorp/terraform/version"
)
// EvalCompareDiff is an EvalNode implementation that compares two diffs
"\n"+
"Also include as much context as you can about your config, state, "+
"and the steps you performed to trigger this error.\n",
- n.Info.Id, Version, n.Info.Id, reason, one, two)
+ n.Info.Id, version.Version, n.Info.Id, reason, one, two)
}
return nil, nil
containers := groupContainers(diff)
keep := map[string]bool{}
for _, v := range containers {
- if v.keepDiff() {
+ if v.keepDiff(ignorableAttrKeys) {
// At least one key has changes, so list all the sibling keys
- // to keep in the diff.
+ // to keep in the diff
for k := range v {
keep[k] = true
+ // this key may have been added by the user to ignore, but
+ // if it's a subkey in a container, we need to un-ignore it
+ // to keep the complete containter.
+ delete(ignorableAttrKeys, k)
}
}
}
// a group of key-*ResourceAttrDiff pairs from the same flatmapped container
type flatAttrDiff map[string]*ResourceAttrDiff
-// we need to keep all keys if any of them have a diff
-func (f flatAttrDiff) keepDiff() bool {
- for _, v := range f {
- if !v.Empty() && !v.NewComputed {
+// we need to keep all keys if any of them have a diff that's not ignored
+func (f flatAttrDiff) keepDiff(ignoreChanges map[string]bool) bool {
+ for k, v := range f {
+ ignore := false
+ for attr := range ignoreChanges {
+ if strings.HasPrefix(k, attr) {
+ ignore = true
+ }
+ }
+
+ if !v.Empty() && !v.NewComputed && !ignore {
return true
}
}