mirror of
https://github.com/siderolabs/talos.git
synced 2025-09-12 09:21:18 +02:00
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>
68 lines
1.7 KiB
Go
68 lines
1.7 KiB
Go
// Code generated by "enumer -type=BondMode -linecomment -text"; DO NOT EDIT.
|
|
|
|
//
|
|
package nethelpers
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
const _BondModeName = "balance-rractive-backupbalance-xorbroadcast802.3adbalance-tlbbalance-alb"
|
|
|
|
var _BondModeIndex = [...]uint8{0, 10, 23, 34, 43, 50, 61, 72}
|
|
|
|
func (i BondMode) String() string {
|
|
if i >= BondMode(len(_BondModeIndex)-1) {
|
|
return fmt.Sprintf("BondMode(%d)", i)
|
|
}
|
|
return _BondModeName[_BondModeIndex[i]:_BondModeIndex[i+1]]
|
|
}
|
|
|
|
var _BondModeValues = []BondMode{0, 1, 2, 3, 4, 5, 6}
|
|
|
|
var _BondModeNameToValueMap = map[string]BondMode{
|
|
_BondModeName[0:10]: 0,
|
|
_BondModeName[10:23]: 1,
|
|
_BondModeName[23:34]: 2,
|
|
_BondModeName[34:43]: 3,
|
|
_BondModeName[43:50]: 4,
|
|
_BondModeName[50:61]: 5,
|
|
_BondModeName[61:72]: 6,
|
|
}
|
|
|
|
// BondModeString retrieves an enum value from the enum constants string name.
|
|
// Throws an error if the param is not part of the enum.
|
|
func BondModeString(s string) (BondMode, error) {
|
|
if val, ok := _BondModeNameToValueMap[s]; ok {
|
|
return val, nil
|
|
}
|
|
return 0, fmt.Errorf("%s does not belong to BondMode values", s)
|
|
}
|
|
|
|
// BondModeValues returns all values of the enum
|
|
func BondModeValues() []BondMode {
|
|
return _BondModeValues
|
|
}
|
|
|
|
// IsABondMode returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
func (i BondMode) IsABondMode() bool {
|
|
for _, v := range _BondModeValues {
|
|
if i == v {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// MarshalText implements the encoding.TextMarshaler interface for BondMode
|
|
func (i BondMode) MarshalText() ([]byte, error) {
|
|
return []byte(i.String()), nil
|
|
}
|
|
|
|
// UnmarshalText implements the encoding.TextUnmarshaler interface for BondMode
|
|
func (i *BondMode) UnmarshalText(text []byte) error {
|
|
var err error
|
|
*i, err = BondModeString(string(text))
|
|
return err
|
|
}
|