mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
This is a new-shaped representation of check results which follows the two-tiered structure of static objects and dynamic instances of objects, thereby allowing consumers to see which checkable objects exist in the configuration even if a dynamic evaluation error prevented actually expanding them all to determine their declared instances. Eventually we'll include this in the state too, but this initially adds it only to the plan in order to replace the now-deprecated experimental conditions result that was present but undocumented in Terraform v1.2.
28 lines
602 B
Go
28 lines
602 B
Go
package jsonchecks
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/hashicorp/terraform/internal/checks"
|
|
)
|
|
|
|
type checkStatus []byte
|
|
|
|
func checkStatusForJSON(s checks.Status) checkStatus {
|
|
if ret, ok := checkStatuses[s]; ok {
|
|
return ret
|
|
}
|
|
panic(fmt.Sprintf("unsupported check status %#v", s))
|
|
}
|
|
|
|
func (s checkStatus) MarshalJSON() ([]byte, error) {
|
|
return []byte(s), nil
|
|
}
|
|
|
|
var checkStatuses = map[checks.Status]checkStatus{
|
|
checks.StatusPass: checkStatus(`"pass"`),
|
|
checks.StatusFail: checkStatus(`"fail"`),
|
|
checks.StatusError: checkStatus(`"error"`),
|
|
checks.StatusUnknown: checkStatus(`"unknown"`),
|
|
}
|