2023-01-09 10:39:13 -06:00
|
|
|
package differ
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/zclconf/go-cty/cty"
|
2023-01-09 13:22:59 -06:00
|
|
|
|
2023-01-10 10:24:48 -06:00
|
|
|
"github.com/hashicorp/terraform/internal/command/jsonformat/computed"
|
|
|
|
|
|
|
|
"github.com/hashicorp/terraform/internal/command/jsonformat/computed/renderers"
|
2023-01-09 10:39:13 -06:00
|
|
|
)
|
|
|
|
|
2023-01-10 10:24:48 -06:00
|
|
|
func (change Change) computeAttributeDiffAsTuple(elementTypes []cty.Type) computed.Diff {
|
|
|
|
var elements []computed.Diff
|
|
|
|
current := change.getDefaultActionForIteration()
|
|
|
|
sliceValue := change.asSlice()
|
2023-01-09 10:39:13 -06:00
|
|
|
for ix, elementType := range elementTypes {
|
|
|
|
childValue := sliceValue.getChild(ix, ix, false)
|
2023-01-10 10:24:48 -06:00
|
|
|
element := childValue.computeDiffForType(elementType)
|
2023-01-09 10:39:13 -06:00
|
|
|
elements = append(elements, element)
|
2023-01-10 10:24:48 -06:00
|
|
|
current = compareActions(current, element.Action)
|
2023-01-09 10:39:13 -06:00
|
|
|
}
|
2023-01-10 10:24:48 -06:00
|
|
|
return computed.NewDiff(renderers.List(elements), current, change.replacePath())
|
2023-01-09 10:39:13 -06:00
|
|
|
}
|