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>
68 lines
2.0 KiB
Go
68 lines
2.0 KiB
Go
// Code generated by "enumer -type=OperationalState -linecomment -text"; DO NOT EDIT.
|
|
|
|
//
|
|
package nethelpers
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
const _OperationalStateName = "unknownnotPresentdownlowerLayerDowntestingdormantup"
|
|
|
|
var _OperationalStateIndex = [...]uint8{0, 7, 17, 21, 35, 42, 49, 51}
|
|
|
|
func (i OperationalState) String() string {
|
|
if i >= OperationalState(len(_OperationalStateIndex)-1) {
|
|
return fmt.Sprintf("OperationalState(%d)", i)
|
|
}
|
|
return _OperationalStateName[_OperationalStateIndex[i]:_OperationalStateIndex[i+1]]
|
|
}
|
|
|
|
var _OperationalStateValues = []OperationalState{0, 1, 2, 3, 4, 5, 6}
|
|
|
|
var _OperationalStateNameToValueMap = map[string]OperationalState{
|
|
_OperationalStateName[0:7]: 0,
|
|
_OperationalStateName[7:17]: 1,
|
|
_OperationalStateName[17:21]: 2,
|
|
_OperationalStateName[21:35]: 3,
|
|
_OperationalStateName[35:42]: 4,
|
|
_OperationalStateName[42:49]: 5,
|
|
_OperationalStateName[49:51]: 6,
|
|
}
|
|
|
|
// OperationalStateString retrieves an enum value from the enum constants string name.
|
|
// Throws an error if the param is not part of the enum.
|
|
func OperationalStateString(s string) (OperationalState, error) {
|
|
if val, ok := _OperationalStateNameToValueMap[s]; ok {
|
|
return val, nil
|
|
}
|
|
return 0, fmt.Errorf("%s does not belong to OperationalState values", s)
|
|
}
|
|
|
|
// OperationalStateValues returns all values of the enum
|
|
func OperationalStateValues() []OperationalState {
|
|
return _OperationalStateValues
|
|
}
|
|
|
|
// IsAOperationalState returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
func (i OperationalState) IsAOperationalState() bool {
|
|
for _, v := range _OperationalStateValues {
|
|
if i == v {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// MarshalText implements the encoding.TextMarshaler interface for OperationalState
|
|
func (i OperationalState) MarshalText() ([]byte, error) {
|
|
return []byte(i.String()), nil
|
|
}
|
|
|
|
// UnmarshalText implements the encoding.TextUnmarshaler interface for OperationalState
|
|
func (i *OperationalState) UnmarshalText(text []byte) error {
|
|
var err error
|
|
*i, err = OperationalStateString(string(text))
|
|
return err
|
|
}
|