mirror of
https://github.com/siderolabs/talos.git
synced 2025-09-11 00:41:13 +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>
66 lines
1.8 KiB
Go
66 lines
1.8 KiB
Go
// Code generated by "enumer -type=RouteProtocol -linecomment -text"; DO NOT EDIT.
|
|
|
|
//
|
|
package nethelpers
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
const _RouteProtocolName = "unspecredirectkernelbootstatic"
|
|
|
|
var _RouteProtocolIndex = [...]uint8{0, 6, 14, 20, 24, 30}
|
|
|
|
func (i RouteProtocol) String() string {
|
|
if i >= RouteProtocol(len(_RouteProtocolIndex)-1) {
|
|
return fmt.Sprintf("RouteProtocol(%d)", i)
|
|
}
|
|
return _RouteProtocolName[_RouteProtocolIndex[i]:_RouteProtocolIndex[i+1]]
|
|
}
|
|
|
|
var _RouteProtocolValues = []RouteProtocol{0, 1, 2, 3, 4}
|
|
|
|
var _RouteProtocolNameToValueMap = map[string]RouteProtocol{
|
|
_RouteProtocolName[0:6]: 0,
|
|
_RouteProtocolName[6:14]: 1,
|
|
_RouteProtocolName[14:20]: 2,
|
|
_RouteProtocolName[20:24]: 3,
|
|
_RouteProtocolName[24:30]: 4,
|
|
}
|
|
|
|
// RouteProtocolString retrieves an enum value from the enum constants string name.
|
|
// Throws an error if the param is not part of the enum.
|
|
func RouteProtocolString(s string) (RouteProtocol, error) {
|
|
if val, ok := _RouteProtocolNameToValueMap[s]; ok {
|
|
return val, nil
|
|
}
|
|
return 0, fmt.Errorf("%s does not belong to RouteProtocol values", s)
|
|
}
|
|
|
|
// RouteProtocolValues returns all values of the enum
|
|
func RouteProtocolValues() []RouteProtocol {
|
|
return _RouteProtocolValues
|
|
}
|
|
|
|
// IsARouteProtocol returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
func (i RouteProtocol) IsARouteProtocol() bool {
|
|
for _, v := range _RouteProtocolValues {
|
|
if i == v {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// MarshalText implements the encoding.TextMarshaler interface for RouteProtocol
|
|
func (i RouteProtocol) MarshalText() ([]byte, error) {
|
|
return []byte(i.String()), nil
|
|
}
|
|
|
|
// UnmarshalText implements the encoding.TextUnmarshaler interface for RouteProtocol
|
|
func (i *RouteProtocol) UnmarshalText(text []byte) error {
|
|
var err error
|
|
*i, err = RouteProtocolString(string(text))
|
|
return err
|
|
}
|