mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
refactor: separate entities from views/json into a new package (#3025)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
This commit is contained in:
committed by
GitHub
parent
5bd9f9d5cb
commit
3ff2dedd4b
@@ -11,25 +11,16 @@ import (
|
||||
|
||||
ctyjson "github.com/zclconf/go-cty/cty/json"
|
||||
|
||||
"github.com/opentofu/opentofu/internal/command/jsonentities"
|
||||
"github.com/opentofu/opentofu/internal/plans"
|
||||
"github.com/opentofu/opentofu/internal/states"
|
||||
"github.com/opentofu/opentofu/internal/tfdiags"
|
||||
)
|
||||
|
||||
type Output struct {
|
||||
Sensitive bool `json:"sensitive"`
|
||||
Deprecated string `json:"deprecated,omitempty"`
|
||||
Type json.RawMessage `json:"type,omitempty"`
|
||||
Value json.RawMessage `json:"value,omitempty"`
|
||||
Action ChangeAction `json:"action,omitempty"`
|
||||
}
|
||||
|
||||
type Outputs map[string]Output
|
||||
|
||||
func OutputsFromMap(outputValues map[string]*states.OutputValue) (Outputs, tfdiags.Diagnostics) {
|
||||
func OutputsFromMap(outputValues map[string]*states.OutputValue) (jsonentities.Outputs, tfdiags.Diagnostics) {
|
||||
var diags tfdiags.Diagnostics
|
||||
|
||||
outputs := make(map[string]Output, len(outputValues))
|
||||
outputs := make(map[string]jsonentities.Output, len(outputValues))
|
||||
|
||||
for name, ov := range outputValues {
|
||||
unmarked, _ := ov.Value.UnmarkDeep()
|
||||
@@ -53,7 +44,7 @@ func OutputsFromMap(outputValues map[string]*states.OutputValue) (Outputs, tfdia
|
||||
redactedValue = json.RawMessage(value)
|
||||
}
|
||||
|
||||
outputs[name] = Output{
|
||||
outputs[name] = jsonentities.Output{
|
||||
Sensitive: ov.Sensitive,
|
||||
Deprecated: ov.Deprecated,
|
||||
Type: json.RawMessage(valueType),
|
||||
@@ -64,19 +55,15 @@ func OutputsFromMap(outputValues map[string]*states.OutputValue) (Outputs, tfdia
|
||||
return outputs, nil
|
||||
}
|
||||
|
||||
func OutputsFromChanges(changes []*plans.OutputChangeSrc) Outputs {
|
||||
outputs := make(map[string]Output, len(changes))
|
||||
func OutputsFromChanges(changes []*plans.OutputChangeSrc) jsonentities.Outputs {
|
||||
outputs := make(map[string]jsonentities.Output, len(changes))
|
||||
|
||||
for _, change := range changes {
|
||||
outputs[change.Addr.OutputValue.Name] = Output{
|
||||
outputs[change.Addr.OutputValue.Name] = jsonentities.Output{
|
||||
Sensitive: change.Sensitive,
|
||||
Action: changeAction(change.Action),
|
||||
Action: jsonentities.ParseChangeAction(change.Action),
|
||||
}
|
||||
}
|
||||
|
||||
return outputs
|
||||
}
|
||||
|
||||
func (o Outputs) String() string {
|
||||
return fmt.Sprintf("Outputs: %d", len(o))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user