don't set NewRemoved values as empty strings
NewRemoved diff values were somtimes left in maps and lists.
This commit is contained in:
parent
86e30add98
commit
6868ddd085
|
@ -699,14 +699,6 @@ func (d *InstanceDiff) applySingleAttrDiff(path []string, attrs map[string]strin
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if diff.Old == diff.New && diff.New == "" {
|
|
||||||
// this can only be a valid empty string
|
|
||||||
if attrSchema.Type == cty.String {
|
|
||||||
result[attr] = ""
|
|
||||||
}
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// check for missmatched diff values
|
// check for missmatched diff values
|
||||||
if exists &&
|
if exists &&
|
||||||
old != diff.Old &&
|
old != diff.Old &&
|
||||||
|
@ -715,13 +707,21 @@ func (d *InstanceDiff) applySingleAttrDiff(path []string, attrs map[string]strin
|
||||||
return result, fmt.Errorf("diff apply conflict for %s: diff expects %q, but prior value has %q", attr, diff.Old, old)
|
return result, fmt.Errorf("diff apply conflict for %s: diff expects %q, but prior value has %q", attr, diff.Old, old)
|
||||||
}
|
}
|
||||||
|
|
||||||
if attrSchema.Computed && diff.NewComputed {
|
if diff.NewRemoved {
|
||||||
result[attr] = config.UnknownVariableValue
|
// don't set anything in the new value
|
||||||
|
return map[string]string{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if diff.Old == diff.New && diff.New == "" {
|
||||||
|
// this can only be a valid empty string
|
||||||
|
if attrSchema.Type == cty.String {
|
||||||
|
result[attr] = ""
|
||||||
|
}
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if diff.NewRemoved {
|
if attrSchema.Computed && diff.NewComputed {
|
||||||
// don't set anything in the new value
|
result[attr] = config.UnknownVariableValue
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -863,8 +863,10 @@ func (d *InstanceDiff) applyCollectionDiff(path []string, attrs map[string]strin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill in the count value if it was missing for some reason:
|
// Fill in the count value if it wasn't present in the diff for some reason,
|
||||||
if result[countKey] == "" {
|
// or if there is no count at all.
|
||||||
|
_, countDiff := d.Attributes[countKey]
|
||||||
|
if result[countKey] == "" || (!countDiff && len(keys) != len(result)) {
|
||||||
result[countKey] = countFlatmapContainerValues(countKey, result)
|
result[countKey] = countFlatmapContainerValues(countKey, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue