diff --git a/examples/example-config.yaml b/examples/example-config.yaml index ee92acc..bdee65b 100644 --- a/examples/example-config.yaml +++ b/examples/example-config.yaml @@ -2,9 +2,11 @@ name: example watcher: - time: + type: time + config: poll_seconds: 1 executioner: - log: - tag: example + type: log + config: + tag: example diff --git a/internal/goverseer/config/config.go b/internal/goverseer/config/config.go index 4bf735b..db1ef26 100644 --- a/internal/goverseer/config/config.go +++ b/internal/goverseer/config/config.go @@ -16,24 +16,6 @@ type WatcherConfig struct { Config interface{} } -// UnmarshalYAML implements the yaml.Unmarshaler interface for WatcherConfig -// Because we want to have the type parsed from the yaml node rather than having -// to specify a watcher.type node in the config we need custom unmarshalling -func (d *WatcherConfig) UnmarshalYAML(value *yaml.Node) error { - var raw map[string]interface{} - if err := value.Decode(&raw); err != nil { - return err - } - - for k, v := range raw { - d.Type = k - d.Config = v - break - } - - return nil -} - // ExecutionerConfig is a custom type that handles dynamic unmarshalling type ExecutionerConfig struct { // Type is the type of executioner @@ -44,24 +26,6 @@ type ExecutionerConfig struct { Config interface{} } -// UnmarshalYAML implements the yaml.Unmarshaler interface for WatcherConfig -// Because we want to have the type parsed from the yaml node rather than having -// to specify a watcher.type node in the config we need custom unmarshalling -func (d *ExecutionerConfig) UnmarshalYAML(value *yaml.Node) error { - var raw map[string]interface{} - if err := value.Decode(&raw); err != nil { - return err - } - - for k, v := range raw { - d.Type = k - d.Config = v - break - } - - return nil -} - // Config is the configuration for a watcher and executioner type Config struct { // Name is the name of the configuration, this will show up in logs diff --git a/internal/goverseer/config/config_test.go b/internal/goverseer/config/config_test.go index c59c7f6..026edc3 100644 --- a/internal/goverseer/config/config_test.go +++ b/internal/goverseer/config/config_test.go @@ -14,10 +14,12 @@ const ( testConfigWatcherToLog = ` name: WatcherToLog watcher: - time: + type: time + config: poll_seconds: 1 executioner: - log: + type: log + config: tag: test ` )