aboutsummaryrefslogtreecommitdiff
path: root/pkg/config/yaml.go
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2020-05-01 17:48:57 +0200
committerRené 'Necoro' Neumann <necoro@necoro.eu>2020-05-01 17:48:57 +0200
commit8afa4a29d793e84007666083158e198cf2b8557d (patch)
tree3ed60577657f2723e1cae80c3965b1414124f433 /pkg/config/yaml.go
parent23c2296ae94bedd616bffdf6f87f689bdc90b108 (diff)
downloadfeed2imap-go-8afa4a29d793e84007666083158e198cf2b8557d.tar.gz
feed2imap-go-8afa4a29d793e84007666083158e198cf2b8557d.tar.bz2
feed2imap-go-8afa4a29d793e84007666083158e198cf2b8557d.zip
Print warning, when unknown global option. Also support specifying the new 'options:' keys on global level, but print warning.
Diffstat (limited to '')
-rw-r--r--pkg/config/yaml.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/pkg/config/yaml.go b/pkg/config/yaml.go
index f6b9edd..e8dc401 100644
--- a/pkg/config/yaml.go
+++ b/pkg/config/yaml.go
@@ -76,6 +76,27 @@ func unmarshal(in io.Reader, cfg *Config) (config, error) {
return parsedCfg, nil
}
+func (cfg *Config) fixGlobalOptions(unparsed Map) {
+ origMap := Map{}
+
+ // copy map
+ for k, v := range unparsed {
+ origMap[k] = v
+ }
+
+ newOpts, _ := buildOptions(&cfg.FeedOptions, unparsed)
+
+ for k := range origMap {
+ if _, ok := unparsed[k]; !ok {
+ log.Warnf("Global option '%s' should be inside the 'options' map. It currently overwrites the same key there.", k)
+ } else {
+ log.Warnf("Unknown global option '%s'. Ignored!", k)
+ }
+ }
+
+ cfg.FeedOptions = newOpts
+}
+
func (cfg *Config) parse(in io.Reader) error {
var (
err error
@@ -93,6 +114,8 @@ func (cfg *Config) parse(in io.Reader) error {
return fmt.Errorf("while unmarshalling: %w", err)
}
+ cfg.fixGlobalOptions(parsedCfg.GlobalConfig)
+
if err := buildFeeds(parsedCfg.Feeds, []string{}, cfg.Feeds, &cfg.FeedOptions); err != nil {
return fmt.Errorf("while parsing: %w", err)
}
d/template/text.tpl?h=v1.0.0&id=b41368462c89dbfc5230350c46629266f03ad9d5&follow=1'>Use go-embed for templates instead of inline strings.René 'Necoro' Neumann6-74/+79 2021-02-16Issue #46: Fix semantics of `n` resultRené 'Necoro' Neumann2-9/+15 2021-02-16Issue #46: Move and rename writer; add commentsRené 'Necoro' Neumann3-12/+21 2021-02-15Issue #46: Improvements; add testsRené 'Necoro' Neumann2-1/+48 2021-02-15Bump github.com/google/uuid from 1.1.4 to 1.2.0dependabot[bot]2-3/+3 2021-02-15Issue #46: Make the resulting email body not to include single \r or \n. This...René 'Necoro' Neumann2-2/+66 2021-01-20Bump github.com/PuerkitoBio/goquery from 1.6.0 to 1.6.1dependabot[bot]2-3/+3 2021-01-09Bump github.com/google/uuid from 1.1.2 to 1.1.4dependabot[bot]2-3/+3 2021-01-09Bump github.com/emersion/go-message from 0.14.0 to 0.14.1 (#42)dependabot[bot]2-3/+3 2020-11-28Bump github.com/emersion/go-message from 0.13.0 to 0.14.0 (#38)dependabot[bot]2-3/+9 2020-11-28Bump github.com/google/go-cmp from 0.5.2 to 0.5.4 (#37)dependabot[bot]2-3/+3 2020-11-23Fix release.ymlv0.5.2René 'Necoro' Neumann1-3/+10 2020-11-23Prepare v0.5.2René 'Necoro' Neumann3-3/+8 2020-11-20Bump github.com/gabriel-vasile/mimetype from 1.1.1 to 1.1.2dependabot[bot]2-3/+3 2020-11-04Clean dependabot.ymlRené 'Necoro' Neumann1-4/+0