vault/sdk/logical/clienttokensource_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

52 lines
1.6 KiB
Go

// Code generated by "enumer -type=ClientTokenSource -trimprefix=ClientTokenFrom -transform=snake"; DO NOT EDIT.
package logical
import (
"fmt"
)
const _ClientTokenSourceName = "no_client_tokenvault_headerauthz_headerinternal_auth"
var _ClientTokenSourceIndex = [...]uint8{0, 15, 27, 39, 52}
func (i ClientTokenSource) String() string {
if i >= ClientTokenSource(len(_ClientTokenSourceIndex)-1) {
return fmt.Sprintf("ClientTokenSource(%d)", i)
}
return _ClientTokenSourceName[_ClientTokenSourceIndex[i]:_ClientTokenSourceIndex[i+1]]
}
var _ClientTokenSourceValues = []ClientTokenSource{0, 1, 2, 3}
var _ClientTokenSourceNameToValueMap = map[string]ClientTokenSource{
_ClientTokenSourceName[0:15]: 0,
_ClientTokenSourceName[15:27]: 1,
_ClientTokenSourceName[27:39]: 2,
_ClientTokenSourceName[39:52]: 3,
}
// ClientTokenSourceString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func ClientTokenSourceString(s string) (ClientTokenSource, error) {
if val, ok := _ClientTokenSourceNameToValueMap[s]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to ClientTokenSource values", s)
}
// ClientTokenSourceValues returns all values of the enum
func ClientTokenSourceValues() []ClientTokenSource {
return _ClientTokenSourceValues
}
// IsAClientTokenSource returns "true" if the value is listed in the enum definition. "false" otherwise
func (i ClientTokenSource) IsAClientTokenSource() bool {
for _, v := range _ClientTokenSourceValues {
if i == v {
return true
}
}
return false
}