Files
opentf/internal/command/jsonformat/differ/computed.go
Liam Cervante 1eebcf875f Add support for object attributes in the structured renderer (#32391)
* prep for processing the structured run output

* undo unwanted change to a json key

* Add skeleton functions and API for refactored renderer

* goimports

* Fix documentation of the RenderOpts struct

* Add rendering functionality for primitives to the structured renderer

* add test case for override

* Add support for parsing and rendering sensitive values in the renderer

* Add support for unknown/computed values in the structured renderer

* delete missing unit tests

* Add support for object attributes in the structured renderer

* goimports
2023-01-09 12:15:38 +01:00

40 lines
1.0 KiB
Go

package differ
import (
"github.com/hashicorp/terraform/internal/command/jsonformat/change"
)
func (v Value) checkForComputed(changeType interface{}) (change.Change, bool) {
unknown := v.isUnknown()
if !unknown {
return change.Change{}, false
}
// No matter what we do here, we want to treat the after value as explicit.
// This is because it is going to be null in the value, and we don't want
// the functions in this package to assume this means it has been deleted.
v.AfterExplicit = true
if v.Before == nil {
return v.AsChange(change.Computed(change.Change{})), true
}
// If we get here, then we have a before value. We're going to model a
// delete operation and our renderer later can render the overall change
// accurately.
beforeValue := Value{
Before: v.Before,
BeforeSensitive: v.BeforeSensitive,
}
return v.AsChange(change.Computed(beforeValue.ComputeChange(changeType))), true
}
func (v Value) isUnknown() bool {
if unknown, ok := v.Unknown.(bool); ok {
return unknown
}
return false
}