mirror of
https://github.com/siderolabs/talos.git
synced 2025-09-11 17:01:20 +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>
63 lines
1.5 KiB
Go
63 lines
1.5 KiB
Go
// Code generated by "enumer -type=LACPRate -linecomment -text"; DO NOT EDIT.
|
|
|
|
//
|
|
package nethelpers
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
const _LACPRateName = "slowfast"
|
|
|
|
var _LACPRateIndex = [...]uint8{0, 4, 8}
|
|
|
|
func (i LACPRate) String() string {
|
|
if i >= LACPRate(len(_LACPRateIndex)-1) {
|
|
return fmt.Sprintf("LACPRate(%d)", i)
|
|
}
|
|
return _LACPRateName[_LACPRateIndex[i]:_LACPRateIndex[i+1]]
|
|
}
|
|
|
|
var _LACPRateValues = []LACPRate{0, 1}
|
|
|
|
var _LACPRateNameToValueMap = map[string]LACPRate{
|
|
_LACPRateName[0:4]: 0,
|
|
_LACPRateName[4:8]: 1,
|
|
}
|
|
|
|
// LACPRateString retrieves an enum value from the enum constants string name.
|
|
// Throws an error if the param is not part of the enum.
|
|
func LACPRateString(s string) (LACPRate, error) {
|
|
if val, ok := _LACPRateNameToValueMap[s]; ok {
|
|
return val, nil
|
|
}
|
|
return 0, fmt.Errorf("%s does not belong to LACPRate values", s)
|
|
}
|
|
|
|
// LACPRateValues returns all values of the enum
|
|
func LACPRateValues() []LACPRate {
|
|
return _LACPRateValues
|
|
}
|
|
|
|
// IsALACPRate returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
func (i LACPRate) IsALACPRate() bool {
|
|
for _, v := range _LACPRateValues {
|
|
if i == v {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// MarshalText implements the encoding.TextMarshaler interface for LACPRate
|
|
func (i LACPRate) MarshalText() ([]byte, error) {
|
|
return []byte(i.String()), nil
|
|
}
|
|
|
|
// UnmarshalText implements the encoding.TextUnmarshaler interface for LACPRate
|
|
func (i *LACPRate) UnmarshalText(text []byte) error {
|
|
var err error
|
|
*i, err = LACPRateString(string(text))
|
|
return err
|
|
}
|