blob: f55194aeb0393e80f6b46df4eec7f2e16b07cd60 [file] [log] [blame]
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"`),
}