talos/pkg/machinery/nethelpers/arpalltargets_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

63 lines
1.7 KiB
Go

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