don't recalculate existing block counts in diff
If a block is uneffected by diffs, keep the block count value regardless of what it is. Blocks containing zero values will often be represented by only the count value.
This commit is contained in:
parent
4c23e990e2
commit
892674a3f9
|
@ -460,7 +460,6 @@ func (d *InstanceDiff) Apply(attrs map[string]string, schema *configschema.Block
|
||||||
|
|
||||||
func (d *InstanceDiff) applyBlockDiff(path []string, attrs map[string]string, schema *configschema.Block) (map[string]string, error) {
|
func (d *InstanceDiff) applyBlockDiff(path []string, attrs map[string]string, schema *configschema.Block) (map[string]string, error) {
|
||||||
result := map[string]string{}
|
result := map[string]string{}
|
||||||
|
|
||||||
name := ""
|
name := ""
|
||||||
if len(path) > 0 {
|
if len(path) > 0 {
|
||||||
name = path[len(path)-1]
|
name = path[len(path)-1]
|
||||||
|
@ -597,7 +596,8 @@ func (d *InstanceDiff) applyBlockDiff(path []string, attrs map[string]string, sc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if countDiff, ok := d.Attributes[strings.Join(append(path, n, "#"), ".")]; ok {
|
countAddr := strings.Join(append(path, n, "#"), ".")
|
||||||
|
if countDiff, ok := d.Attributes[countAddr]; ok {
|
||||||
if countDiff.NewComputed {
|
if countDiff.NewComputed {
|
||||||
result[localBlockPrefix+"#"] = hcl2shim.UnknownVariableValue
|
result[localBlockPrefix+"#"] = hcl2shim.UnknownVariableValue
|
||||||
} else {
|
} else {
|
||||||
|
@ -633,6 +633,8 @@ func (d *InstanceDiff) applyBlockDiff(path []string, attrs map[string]string, sc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if origCount, ok := attrs[countAddr]; ok && keepBlock {
|
||||||
|
result[localBlockPrefix+"#"] = origCount
|
||||||
} else {
|
} else {
|
||||||
result[localBlockPrefix+"#"] = countFlatmapContainerValues(localBlockPrefix+"#", result)
|
result[localBlockPrefix+"#"] = countFlatmapContainerValues(localBlockPrefix+"#", result)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue