mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-02-19 07:01:10 -05:00
33 lines
749 B
Go
33 lines
749 B
Go
// Copyright (c) The OpenTofu Authors
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
// Copyright (c) 2023 HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package jsonchecks
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/opentofu/opentofu/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"`),
|
|
}
|