DiffSuppressFunc should noop diffs in sets
Sets rely on diffs being complete for all elements, even when they are unchanged. When encountering a DiffSuppressFunc inside a set the diffs were being dropped entirely, possible causing set elements to be lost.
This commit is contained in:
parent
2e2374cfcb
commit
81a4e705b1
|
@ -799,10 +799,19 @@ func (m schemaMap) diff(
|
||||||
for attrK, attrV := range unsupressedDiff.Attributes {
|
for attrK, attrV := range unsupressedDiff.Attributes {
|
||||||
switch rd := d.(type) {
|
switch rd := d.(type) {
|
||||||
case *ResourceData:
|
case *ResourceData:
|
||||||
if schema.DiffSuppressFunc != nil &&
|
if schema.DiffSuppressFunc != nil && attrV != nil &&
|
||||||
attrV != nil &&
|
|
||||||
schema.DiffSuppressFunc(attrK, attrV.Old, attrV.New, rd) {
|
schema.DiffSuppressFunc(attrK, attrV.Old, attrV.New, rd) {
|
||||||
continue
|
// If this attr diff is suppressed, we may still need it in the
|
||||||
|
// overall diff if it's contained within a set. Rather than
|
||||||
|
// dropping the diff, make it a NOOP.
|
||||||
|
if !all {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
attrV = &terraform.ResourceAttrDiff{
|
||||||
|
Old: attrV.Old,
|
||||||
|
New: attrV.Old,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
diff.Attributes[attrK] = attrV
|
diff.Attributes[attrK] = attrV
|
||||||
|
|
Loading…
Reference in New Issue