talos/pkg/machinery/nethelpers/failovermac_enumer.go
Andrey Smirnov d02d944ec7
chore: provide umarshal from YAML methods for network resource specs
This will be required to preserve platform network configuration in a
cache across boots. Network configuration will be marshaled to YAML and
unmarshaled back.

Changes are pretty simple and most of the code is auto-generated:
replace `stringer` codegen with `enumer` which produces also methods
which convert from string back to enum values.

Added tests to verify YAML marshaling/unmarshaling.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
2022-01-10 17:00:53 +03:00

52 lines
1.3 KiB
Go

// Code generated by "enumer -type=FailOverMAC -linecomment"; DO NOT EDIT.
//
package nethelpers
import (
"fmt"
)
const _FailOverMACName = "noneactivefollow"
var _FailOverMACIndex = [...]uint8{0, 4, 10, 16}
func (i FailOverMAC) String() string {
if i >= FailOverMAC(len(_FailOverMACIndex)-1) {
return fmt.Sprintf("FailOverMAC(%d)", i)
}
return _FailOverMACName[_FailOverMACIndex[i]:_FailOverMACIndex[i+1]]
}
var _FailOverMACValues = []FailOverMAC{0, 1, 2}
var _FailOverMACNameToValueMap = map[string]FailOverMAC{
_FailOverMACName[0:4]: 0,
_FailOverMACName[4:10]: 1,
_FailOverMACName[10:16]: 2,
}
// FailOverMACString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func FailOverMACString(s string) (FailOverMAC, error) {
if val, ok := _FailOverMACNameToValueMap[s]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to FailOverMAC values", s)
}
// FailOverMACValues returns all values of the enum
func FailOverMACValues() []FailOverMAC {
return _FailOverMACValues
}
// IsAFailOverMAC returns "true" if the value is listed in the enum definition. "false" otherwise
func (i FailOverMAC) IsAFailOverMAC() bool {
for _, v := range _FailOverMACValues {
if i == v {
return true
}
}
return false
}