2024-02-08 03:48:59 -06:00
|
|
|
// Copyright (c) The OpenTofu Authors
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
// Copyright (c) 2023 HashiCorp, Inc.
|
2023-05-02 10:33:06 -05:00
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2023-01-09 04:05:25 -06:00
|
|
|
package differ
|
|
|
|
|
2023-01-09 07:45:35 -06:00
|
|
|
import (
|
2023-01-11 02:35:36 -06:00
|
|
|
"github.com/zclconf/go-cty/cty"
|
2023-01-09 07:45:35 -06:00
|
|
|
|
2023-09-20 06:35:35 -05:00
|
|
|
"github.com/opentofu/opentofu/internal/command/jsonformat/computed"
|
|
|
|
"github.com/opentofu/opentofu/internal/command/jsonformat/computed/renderers"
|
|
|
|
"github.com/opentofu/opentofu/internal/command/jsonformat/structured"
|
2023-01-09 07:45:35 -06:00
|
|
|
)
|
|
|
|
|
2023-04-21 02:51:55 -05:00
|
|
|
func ComputeDiffForOutput(change structured.Change) computed.Diff {
|
|
|
|
if sensitive, ok := checkForSensitiveType(change, cty.DynamicPseudoType); ok {
|
2023-01-09 09:49:35 -06:00
|
|
|
return sensitive
|
|
|
|
}
|
|
|
|
|
2023-04-21 02:51:55 -05:00
|
|
|
if unknown, ok := checkForUnknownType(change, cty.DynamicPseudoType); ok {
|
2023-01-10 10:24:48 -06:00
|
|
|
return unknown
|
2023-01-09 09:49:35 -06:00
|
|
|
}
|
|
|
|
|
2023-01-11 02:35:36 -06:00
|
|
|
jsonOpts := renderers.RendererJsonOpts()
|
2023-04-24 03:28:21 -05:00
|
|
|
return jsonOpts.Transform(change)
|
2023-01-09 04:05:25 -06:00
|
|
|
}
|