From 82d2dd98cad02947e214a7c208493693bec8c8f3 Mon Sep 17 00:00:00 2001 From: Oleg Mykolaichenko Date: Fri, 13 Sep 2019 15:06:55 +0300 Subject: [PATCH] Added YAML support to event selector configuration --- pkg/event_selector/event_selector.go | 4 ++-- pkg/event_selector/selectors_config.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/event_selector/event_selector.go b/pkg/event_selector/event_selector.go index 06ae431..1293266 100644 --- a/pkg/event_selector/event_selector.go +++ b/pkg/event_selector/event_selector.go @@ -1,7 +1,7 @@ package event_selector import ( - "encoding/json" + "gopkg.in/yaml.v2" "sync" "github.com/anchorfree/data-go/pkg/consul" @@ -40,7 +40,7 @@ func (es *EventSelector) RunConfigWatcher() error { func (es *EventSelector) updateConfig(rawConfig []byte) error { selectors := &Selectors{} - err := json.Unmarshal(rawConfig, selectors) + err := yaml.Unmarshal(rawConfig, selectors) if err != nil { return err } diff --git a/pkg/event_selector/selectors_config.go b/pkg/event_selector/selectors_config.go index 184e38c..c567910 100644 --- a/pkg/event_selector/selectors_config.go +++ b/pkg/event_selector/selectors_config.go @@ -1,10 +1,10 @@ package event_selector type Selectors struct { - Selectors []Selector `json:"selectors"` + Selectors []Selector `yaml:"selectors"` } type Selector struct { - TargetTopic string `json:"target_topic"` - Matching map[string]string `json:"matching"` + TargetTopic string `yaml:"target_topic"` + Matching map[string]string `yaml:"matching"` }