github.com/graywolf-at-work-2/terraform-vendor@v1.4.5/internal/command/jsonformat/differ/tuple.go (about)

     1  package differ
     2  
     3  import (
     4  	"github.com/zclconf/go-cty/cty"
     5  
     6  	"github.com/hashicorp/terraform/internal/command/jsonformat/collections"
     7  	"github.com/hashicorp/terraform/internal/command/jsonformat/computed"
     8  	"github.com/hashicorp/terraform/internal/command/jsonformat/computed/renderers"
     9  )
    10  
    11  func (change Change) computeAttributeDiffAsTuple(elementTypes []cty.Type) computed.Diff {
    12  	var elements []computed.Diff
    13  	current := change.getDefaultActionForIteration()
    14  	sliceValue := change.asSlice()
    15  	for ix, elementType := range elementTypes {
    16  		childValue := sliceValue.getChild(ix, ix)
    17  		if !childValue.RelevantAttributes.MatchesPartial() {
    18  			// Mark non-relevant attributes as unchanged.
    19  			childValue = childValue.AsNoOp()
    20  		}
    21  		element := childValue.ComputeDiffForType(elementType)
    22  		elements = append(elements, element)
    23  		current = collections.CompareActions(current, element.Action)
    24  	}
    25  	return computed.NewDiff(renderers.List(elements), current, change.ReplacePaths.Matches())
    26  }