From 8c134b0ece0da2d774e2bad4df35803d3c30f500 Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Sat, 25 Apr 2020 17:37:42 +0200 Subject: Push global feed configuration to feeds --- pkg/config/config.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'pkg/config/config.go') diff --git a/pkg/config/config.go b/pkg/config/config.go index 83c952f..1b95f61 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -39,6 +39,15 @@ type Options struct { InclImages *bool `yaml:"include-images"` } +func (opt *Options) mergeFrom(other Options) { + if opt.MinFreq == nil { + opt.MinFreq = other.MinFreq + } + if opt.InclImages == nil { + opt.InclImages = other.InclImages + } +} + // Default feed options var DefaultFeedOptions Options @@ -111,9 +120,17 @@ func Load(path string) (*Config, error) { return nil, fmt.Errorf("while parsing: %w", err) } + cfg.pushFeedOptions() + return cfg, nil } +func (cfg *Config) pushFeedOptions() { + for _, feed := range cfg.Feeds { + feed.Options.mergeFrom(cfg.FeedOptions) + } +} + func hostname() (hostname string) { hostname, err := os.Hostname() if err != nil { -- cgit v1.2.3-70-g09d2