talos/pkg/machinery/nethelpers/adselect_enumer.go
Andrey Smirnov d02d944ec7
chore: provide umarshal from YAML methods for network resource specs
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>
2022-01-10 17:00:53 +03:00

64 lines
1.6 KiB
Go

// Code generated by "enumer -type=ADSelect -linecomment -text"; DO NOT EDIT.
//
package nethelpers
import (
"fmt"
)
const _ADSelectName = "stablebandwidthcount"
var _ADSelectIndex = [...]uint8{0, 6, 15, 20}
func (i ADSelect) String() string {
if i >= ADSelect(len(_ADSelectIndex)-1) {
return fmt.Sprintf("ADSelect(%d)", i)
}
return _ADSelectName[_ADSelectIndex[i]:_ADSelectIndex[i+1]]
}
var _ADSelectValues = []ADSelect{0, 1, 2}
var _ADSelectNameToValueMap = map[string]ADSelect{
_ADSelectName[0:6]: 0,
_ADSelectName[6:15]: 1,
_ADSelectName[15:20]: 2,
}
// ADSelectString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func ADSelectString(s string) (ADSelect, error) {
if val, ok := _ADSelectNameToValueMap[s]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to ADSelect values", s)
}
// ADSelectValues returns all values of the enum
func ADSelectValues() []ADSelect {
return _ADSelectValues
}
// IsAADSelect returns "true" if the value is listed in the enum definition. "false" otherwise
func (i ADSelect) IsAADSelect() bool {
for _, v := range _ADSelectValues {
if i == v {
return true
}
}
return false
}
// MarshalText implements the encoding.TextMarshaler interface for ADSelect
func (i ADSelect) MarshalText() ([]byte, error) {
return []byte(i.String()), nil
}
// UnmarshalText implements the encoding.TextUnmarshaler interface for ADSelect
func (i *ADSelect) UnmarshalText(text []byte) error {
var err error
*i, err = ADSelectString(string(text))
return err
}