vault/sdk/helper/testcluster/generaterootkind_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.5 KiB
Go

// Code generated by "enumer -type=GenerateRootKind -trimprefix=GenerateRoot"; DO NOT EDIT.
package testcluster
import (
"fmt"
)
const _GenerateRootKindName = "RegularDRGenerateRecovery"
var _GenerateRootKindIndex = [...]uint8{0, 7, 9, 25}
func (i GenerateRootKind) String() string {
if i < 0 || i >= GenerateRootKind(len(_GenerateRootKindIndex)-1) {
return fmt.Sprintf("GenerateRootKind(%d)", i)
}
return _GenerateRootKindName[_GenerateRootKindIndex[i]:_GenerateRootKindIndex[i+1]]
}
var _GenerateRootKindValues = []GenerateRootKind{0, 1, 2}
var _GenerateRootKindNameToValueMap = map[string]GenerateRootKind{
_GenerateRootKindName[0:7]: 0,
_GenerateRootKindName[7:9]: 1,
_GenerateRootKindName[9:25]: 2,
}
// GenerateRootKindString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func GenerateRootKindString(s string) (GenerateRootKind, error) {
if val, ok := _GenerateRootKindNameToValueMap[s]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to GenerateRootKind values", s)
}
// GenerateRootKindValues returns all values of the enum
func GenerateRootKindValues() []GenerateRootKind {
return _GenerateRootKindValues
}
// IsAGenerateRootKind returns "true" if the value is listed in the enum definition. "false" otherwise
func (i GenerateRootKind) IsAGenerateRootKind() bool {
for _, v := range _GenerateRootKindValues {
if i == v {
return true
}
}
return false
}