Use typed enums for cleaner parsing.

This commit is contained in:
Anna Rose Wiggins 2025-09-05 13:42:22 -04:00
parent 8d2b15a7c8
commit 553966ac87
5 changed files with 33 additions and 40 deletions

View file

@ -15,12 +15,12 @@ type Config struct {
// These top-level structs use custom unmarshaling to unpack each available sub-type
type DeviceConfig struct {
Type string
Type DeviceType
Config interface{}
}
type RuleConfig struct {
Type string
Type RuleType
Name string
Modes []string
Config interface{}
@ -119,7 +119,7 @@ type RuleTargetConfigModeSelect struct {
func (dc *DeviceConfig) UnmarshalYAML(unmarshal func(data interface{}) error) error {
metaConfig := &struct {
Type string
Type DeviceType
}{}
err := unmarshal(metaConfig)
if err != nil {
@ -145,7 +145,7 @@ func (dc *DeviceConfig) UnmarshalYAML(unmarshal func(data interface{}) error) er
func (dc *RuleConfig) UnmarshalYAML(unmarshal func(data interface{}) error) error {
metaConfig := &struct {
Type string
Type RuleType
Name string
Modes []string
}{}