Use typed enums for cleaner parsing.
This commit is contained in:
parent
8d2b15a7c8
commit
553966ac87
5 changed files with 33 additions and 40 deletions
|
@ -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
|
||||
}{}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue