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
This commit is contained in:
Liam Cervante
2023-01-11 09:35:36 +01:00
committed by GitHub
parent 8330b7295b
commit 38afb41787
25 changed files with 761 additions and 332 deletions

View File

@@ -3,12 +3,11 @@ package differ
import (
"reflect"
"github.com/hashicorp/terraform/internal/command/jsonformat/computed"
"github.com/hashicorp/terraform/internal/command/jsonformat/computed/renderers"
"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"
"github.com/hashicorp/terraform/internal/command/jsonprovider"
"github.com/hashicorp/terraform/internal/plans"
)
@@ -19,7 +18,7 @@ func (change Change) computeAttributeDiffAsSet(elementType cty.Type) computed.Di
change.processSet(false, func(value Change) {
element := value.computeDiffForType(elementType)
elements = append(elements, element)
current = compareActions(current, element.Action)
current = collections.CompareActions(current, element.Action)
})
return computed.NewDiff(renderers.Set(elements), current, change.replacePath())
}
@@ -33,7 +32,7 @@ func (change Change) computeAttributeDiffAsNestedSet(attributes map[string]*json
NestingMode: "single",
})
elements = append(elements, element)
current = compareActions(current, element.Action)
current = collections.CompareActions(current, element.Action)
})
return computed.NewDiff(renderers.Set(elements), current, change.replacePath())
}
@@ -44,7 +43,7 @@ func (change Change) computeBlockDiffsAsSet(block *jsonprovider.Block) ([]comput
change.processSet(true, func(value Change) {
element := value.ComputeDiffForBlock(block)
elements = append(elements, element)
current = compareActions(current, element.Action)
current = collections.CompareActions(current, element.Action)
})
return elements, current
}