core: legacyDiffComparisonString don't panic if only deposed objects

This shim for the benefit of our old tests was not handling the situation
where an InstanceState only contains deposed instances and no current
instance. This is a strange, rare situation but one that does come up in
practice in some odd cases.
This commit is contained in:
Martin Atkins 2018-09-20 15:15:44 -07:00
parent 334c6f1c2c
commit efe956524d

View File

@ -902,6 +902,7 @@ func legacyDiffComparisonString(changes *plans.Changes) string {
attrNames := map[string]bool{}
var oldAttrs map[string]string
var newAttrs map[string]string
if rc.Current != nil {
if before := rc.Current.Before; before != nil {
ty, err := before.ImpliedType()
if err == nil {
@ -926,6 +927,7 @@ func legacyDiffComparisonString(changes *plans.Changes) string {
}
}
}
}
if oldAttrs == nil {
oldAttrs = make(map[string]string)
}