vault/sdk/helper/ocsp/failopenmode_enumer.go
Christopher Swenson 961bf20bdb
Use enumer to generate String() methods for most enums (#25705)
We have many hand-written String() methods (and similar) for enums.
These require more maintenance and are more error-prone than using
automatically generated methods. In addition, the auto-generated
versions can be more efficient.

Here, we switch to using https://github.com/loggerhead/enumer, itself
a fork of https://github.com/diegostamigni/enumer, no longer maintained,
and a fork of the mostly standard tool
https://pkg.go.dev/golang.org/x/tools/cmd/stringer.
We use this fork of enumer for Go 1.20+ compatibility and because
we require the `-transform` flag to be able to generate
constants that match our current code base.

Some enums were not targeted for this change:
2024-04-17 11:14:14 -07:00

51 lines
1.3 KiB
Go

// Code generated by "enumer -type=FailOpenMode -trimprefix=FailOpen"; DO NOT EDIT.
package ocsp
import (
"fmt"
)
const _FailOpenModeName = "ocspFailOpenNotSetTrueFalse"
var _FailOpenModeIndex = [...]uint8{0, 18, 22, 27}
func (i FailOpenMode) String() string {
if i >= FailOpenMode(len(_FailOpenModeIndex)-1) {
return fmt.Sprintf("FailOpenMode(%d)", i)
}
return _FailOpenModeName[_FailOpenModeIndex[i]:_FailOpenModeIndex[i+1]]
}
var _FailOpenModeValues = []FailOpenMode{0, 1, 2}
var _FailOpenModeNameToValueMap = map[string]FailOpenMode{
_FailOpenModeName[0:18]: 0,
_FailOpenModeName[18:22]: 1,
_FailOpenModeName[22:27]: 2,
}
// FailOpenModeString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func FailOpenModeString(s string) (FailOpenMode, error) {
if val, ok := _FailOpenModeNameToValueMap[s]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to FailOpenMode values", s)
}
// FailOpenModeValues returns all values of the enum
func FailOpenModeValues() []FailOpenMode {
return _FailOpenModeValues
}
// IsAFailOpenMode returns "true" if the value is listed in the enum definition. "false" otherwise
func (i FailOpenMode) IsAFailOpenMode() bool {
for _, v := range _FailOpenModeValues {
if i == v {
return true
}
}
return false
}