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
|
||||
}
|
||||
|
||||
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
|
||||
if exists &&
|
||||
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)
|
||||
}
|
||||
|
||||
if attrSchema.Computed && diff.NewComputed {
|
||||
result[attr] = config.UnknownVariableValue
|
||||
if diff.NewRemoved {
|
||||
// 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
|
||||
}
|
||||
|
||||
if diff.NewRemoved {
|
||||
// don't set anything in the new value
|
||||
if attrSchema.Computed && diff.NewComputed {
|
||||
result[attr] = config.UnknownVariableValue
|
||||
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:
|
||||
if result[countKey] == "" {
|
||||
// Fill in the count value if it wasn't present in the diff for some reason,
|
||||
// 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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue