mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 01:41:48 -06:00
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:
parent
334c6f1c2c
commit
efe956524d
@ -902,26 +902,28 @@ func legacyDiffComparisonString(changes *plans.Changes) string {
|
||||
attrNames := map[string]bool{}
|
||||
var oldAttrs map[string]string
|
||||
var newAttrs map[string]string
|
||||
if before := rc.Current.Before; before != nil {
|
||||
ty, err := before.ImpliedType()
|
||||
if err == nil {
|
||||
val, err := before.Decode(ty)
|
||||
if rc.Current != nil {
|
||||
if before := rc.Current.Before; before != nil {
|
||||
ty, err := before.ImpliedType()
|
||||
if err == nil {
|
||||
oldAttrs = hcl2shim.FlatmapValueFromHCL2(val)
|
||||
for k := range oldAttrs {
|
||||
attrNames[k] = true
|
||||
val, err := before.Decode(ty)
|
||||
if err == nil {
|
||||
oldAttrs = hcl2shim.FlatmapValueFromHCL2(val)
|
||||
for k := range oldAttrs {
|
||||
attrNames[k] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if after := rc.Current.After; after != nil {
|
||||
ty, err := after.ImpliedType()
|
||||
if err == nil {
|
||||
val, err := after.Decode(ty)
|
||||
if after := rc.Current.After; after != nil {
|
||||
ty, err := after.ImpliedType()
|
||||
if err == nil {
|
||||
newAttrs = hcl2shim.FlatmapValueFromHCL2(val)
|
||||
for k := range newAttrs {
|
||||
attrNames[k] = true
|
||||
val, err := after.Decode(ty)
|
||||
if err == nil {
|
||||
newAttrs = hcl2shim.FlatmapValueFromHCL2(val)
|
||||
for k := range newAttrs {
|
||||
attrNames[k] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user