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>
64 lines
1.8 KiB
Go
64 lines
1.8 KiB
Go
// Code generated by "enumer -type=PrimaryReselect -linecomment -text"; DO NOT EDIT.
|
|
|
|
//
|
|
package nethelpers
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
const _PrimaryReselectName = "alwaysbetterfailure"
|
|
|
|
var _PrimaryReselectIndex = [...]uint8{0, 6, 12, 19}
|
|
|
|
func (i PrimaryReselect) String() string {
|
|
if i >= PrimaryReselect(len(_PrimaryReselectIndex)-1) {
|
|
return fmt.Sprintf("PrimaryReselect(%d)", i)
|
|
}
|
|
return _PrimaryReselectName[_PrimaryReselectIndex[i]:_PrimaryReselectIndex[i+1]]
|
|
}
|
|
|
|
var _PrimaryReselectValues = []PrimaryReselect{0, 1, 2}
|
|
|
|
var _PrimaryReselectNameToValueMap = map[string]PrimaryReselect{
|
|
_PrimaryReselectName[0:6]: 0,
|
|
_PrimaryReselectName[6:12]: 1,
|
|
_PrimaryReselectName[12:19]: 2,
|
|
}
|
|
|
|
// PrimaryReselectString retrieves an enum value from the enum constants string name.
|
|
// Throws an error if the param is not part of the enum.
|
|
func PrimaryReselectString(s string) (PrimaryReselect, error) {
|
|
if val, ok := _PrimaryReselectNameToValueMap[s]; ok {
|
|
return val, nil
|
|
}
|
|
return 0, fmt.Errorf("%s does not belong to PrimaryReselect values", s)
|
|
}
|
|
|
|
// PrimaryReselectValues returns all values of the enum
|
|
func PrimaryReselectValues() []PrimaryReselect {
|
|
return _PrimaryReselectValues
|
|
}
|
|
|
|
// IsAPrimaryReselect returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
func (i PrimaryReselect) IsAPrimaryReselect() bool {
|
|
for _, v := range _PrimaryReselectValues {
|
|
if i == v {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// MarshalText implements the encoding.TextMarshaler interface for PrimaryReselect
|
|
func (i PrimaryReselect) MarshalText() ([]byte, error) {
|
|
return []byte(i.String()), nil
|
|
}
|
|
|
|
// UnmarshalText implements the encoding.TextUnmarshaler interface for PrimaryReselect
|
|
func (i *PrimaryReselect) UnmarshalText(text []byte) error {
|
|
var err error
|
|
*i, err = PrimaryReselectString(string(text))
|
|
return err
|
|
}
|