2024-02-08 04:48:59 -05:00
|
|
|
// Copyright (c) The OpenTofu Authors
|
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
// Copyright (c) 2023 HashiCorp, Inc.
|
2023-05-02 11:33:06 -04:00
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
|
2023-01-10 11:24:48 -05:00
|
|
|
package renderers
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
|
2023-09-20 07:35:35 -04:00
|
|
|
"github.com/opentofu/opentofu/internal/command/jsonformat/computed"
|
2023-01-10 11:24:48 -05:00
|
|
|
|
2023-09-20 07:35:35 -04:00
|
|
|
"github.com/opentofu/opentofu/internal/plans"
|
2023-01-10 11:24:48 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var _ computed.DiffRenderer = (*unknownRenderer)(nil)
|
|
|
|
|
|
|
|
|
|
func Unknown(before computed.Diff) computed.DiffRenderer {
|
|
|
|
|
return &unknownRenderer{
|
|
|
|
|
before: before,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type unknownRenderer struct {
|
|
|
|
|
NoWarningsRenderer
|
|
|
|
|
|
|
|
|
|
before computed.Diff
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (renderer unknownRenderer) RenderHuman(diff computed.Diff, indent int, opts computed.RenderHumanOpts) string {
|
|
|
|
|
if diff.Action == plans.Create {
|
2023-04-24 05:02:32 -04:00
|
|
|
return fmt.Sprintf("(known after apply)%s", forcesReplacement(diff.Replace, opts))
|
2023-01-10 11:24:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Never render null suffix for children of unknown changes.
|
|
|
|
|
opts.OverrideNullSuffix = true
|
2023-04-24 05:02:32 -04:00
|
|
|
return fmt.Sprintf("%s -> (known after apply)%s", renderer.before.RenderHuman(indent, opts), forcesReplacement(diff.Replace, opts))
|
2023-01-10 11:24:48 -05:00
|
|
|
}
|