Files
opentf/internal/command/jsonformat/differ/tuple.go
Liam Cervante 38afb41787 Structured plan renderer: Introduce support for multiline and JSON strings (#32488)
* pause implementation

* change -> diff, value -> change

* add support for json and multiline strings to the primitive renderer

* goimports

* remove unused function

* go fmt

* address comments
2023-01-11 09:35:36 +01:00

23 lines
832 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, false)
element := childValue.computeDiffForType(elementType)
elements = append(elements, element)
current = collections.CompareActions(current, element.Action)
}
return computed.NewDiff(renderers.List(elements), current, change.replacePath())
}