mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-21 10:47:34 -05:00
* remove attributes that do not match the relevant attributes filter * fix formatting * fix renderer function, don't drop irrelevant attributes just mark them as no-ops * fix imports
27 lines
978 B
Go
27 lines
978 B
Go
package differ
|
|
|
|
import (
|
|
"github.com/zclconf/go-cty/cty"
|
|
|
|
"github.com/hashicorp/terraform/internal/command/jsonformat/collections"
|
|
"github.com/hashicorp/terraform/internal/command/jsonformat/computed"
|
|
"github.com/hashicorp/terraform/internal/command/jsonformat/computed/renderers"
|
|
)
|
|
|
|
func (change Change) computeAttributeDiffAsTuple(elementTypes []cty.Type) computed.Diff {
|
|
var elements []computed.Diff
|
|
current := change.getDefaultActionForIteration()
|
|
sliceValue := change.asSlice()
|
|
for ix, elementType := range elementTypes {
|
|
childValue := sliceValue.getChild(ix, ix)
|
|
if !childValue.RelevantAttributes.MatchesPartial() {
|
|
// Mark non-relevant attributes as unchanged.
|
|
childValue = childValue.AsNoOp()
|
|
}
|
|
element := childValue.computeDiffForType(elementType)
|
|
elements = append(elements, element)
|
|
current = collections.CompareActions(current, element.Action)
|
|
}
|
|
return computed.NewDiff(renderers.List(elements), current, change.ReplacePaths.Matches())
|
|
}
|