mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
command/jsonstate: Include check results in JSON state report
This commit is contained in:
parent
0e4e9f7706
commit
a8c255c779
@ -9,6 +9,7 @@ import (
|
||||
ctyjson "github.com/zclconf/go-cty/cty/json"
|
||||
|
||||
"github.com/hashicorp/terraform/internal/addrs"
|
||||
"github.com/hashicorp/terraform/internal/command/jsonchecks"
|
||||
"github.com/hashicorp/terraform/internal/lang/marks"
|
||||
"github.com/hashicorp/terraform/internal/states"
|
||||
"github.com/hashicorp/terraform/internal/states/statefile"
|
||||
@ -23,9 +24,10 @@ const FormatVersion = "1.0"
|
||||
// state is the top-level representation of the json format of a terraform
|
||||
// state.
|
||||
type state struct {
|
||||
FormatVersion string `json:"format_version,omitempty"`
|
||||
TerraformVersion string `json:"terraform_version,omitempty"`
|
||||
Values *stateValues `json:"values,omitempty"`
|
||||
FormatVersion string `json:"format_version,omitempty"`
|
||||
TerraformVersion string `json:"terraform_version,omitempty"`
|
||||
Values *stateValues `json:"values,omitempty"`
|
||||
Checks json.RawMessage `json:"checks,omitempty"`
|
||||
}
|
||||
|
||||
// stateValues is the common representation of resolved values for both the prior
|
||||
@ -150,6 +152,11 @@ func Marshal(sf *statefile.File, schemas *terraform.Schemas) ([]byte, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// output.Checks
|
||||
if sf.State.CheckResults != nil && sf.State.CheckResults.ConfigResults.Len() > 0 {
|
||||
output.Checks = jsonchecks.MarshalCheckStates(sf.State.CheckResults)
|
||||
}
|
||||
|
||||
ret, err := json.Marshal(output)
|
||||
return ret, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user