aboutsummaryrefslogtreecommitdiff
path: root/pkg/config/config.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkg/config/config.go64
1 files changed, 14 insertions, 50 deletions
diff --git a/pkg/config/config.go b/pkg/config/config.go
index 885b80e..de8e4ad 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -34,56 +34,29 @@ var DefaultGlobalOptions = GlobalOptions{
}
// Per feed options
+// NB: Always specify a yaml name, as it is later used in processing
type Options struct {
- MinFreq *int `yaml:"min-frequency"`
- InclImages *bool `yaml:"include-images"`
- Disable *bool `yaml:"disable"`
- IgnHash *bool `yaml:"ignore-hash"`
- AlwaysNew *bool `yaml:"always-new"`
- NoTLS *bool `yaml:"tls-no-verify"`
-}
-
-func (opt *Options) mergeFrom(other Options) {
- if opt.MinFreq == nil {
- opt.MinFreq = other.MinFreq
- }
- if opt.InclImages == nil {
- opt.InclImages = other.InclImages
- }
- if opt.IgnHash == nil {
- opt.IgnHash = other.IgnHash
- }
- if opt.AlwaysNew == nil {
- opt.AlwaysNew = other.AlwaysNew
- }
- if opt.Disable == nil {
- opt.Disable = other.Disable
- }
- if opt.NoTLS == nil {
- opt.NoTLS = other.NoTLS
- }
+ MinFreq int `yaml:"min-frequency"`
+ InclImages bool `yaml:"include-images"`
+ Disable bool `yaml:"disable"`
+ IgnHash bool `yaml:"ignore-hash"`
+ AlwaysNew bool `yaml:"always-new"`
+ NoTLS bool `yaml:"tls-no-verify"`
}
// Default feed options
-var DefaultFeedOptions Options
-
-func init() {
- one := 1
- fal := false
- DefaultFeedOptions = Options{
- MinFreq: &one,
- InclImages: &fal,
- IgnHash: &fal,
- AlwaysNew: &fal,
- Disable: &fal,
- NoTLS: &fal,
- }
+var DefaultFeedOptions = Options{
+ MinFreq: 1,
+ InclImages: false,
+ IgnHash: false,
+ AlwaysNew: false,
+ Disable: false,
+ NoTLS: false,
}
// Config holds the global configuration options and the configured feeds
type Config struct {
GlobalOptions `yaml:",inline"`
- GlobalConfig Map `yaml:",inline"`
FeedOptions Options `yaml:"options"`
Feeds Feeds `yaml:"-"`
}
@@ -93,7 +66,6 @@ func WithDefault() *Config {
return &Config{
GlobalOptions: DefaultGlobalOptions,
FeedOptions: DefaultFeedOptions,
- GlobalConfig: Map{},
Feeds: Feeds{},
}
}
@@ -140,17 +112,9 @@ 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 {
>-8/+106 2010-07-05Only show right nav arrow, if the following month is not in the futureRené 'Necoro' Neumann2-14/+20 2010-07-05Add month navigationRené 'Necoro' Neumann6-5/+35 2010-07-05Add iconRené 'Necoro' Neumann2-1/+2 2010-07-05change cursorRené 'Necoro' Neumann1-0/+5 2010-07-05Some restructuringRené 'Necoro' Neumann3-28/+45 2010-07-05Closed/Open imagesRené 'Necoro' Neumann4-0/+146 2010-05-25Move page templates into their own folderRené 'Necoro' Neumann5-5/+7 2010-05-25Added the ability to edit an expenseRené 'Necoro' Neumann3-9/+34 2010-05-12FixRené 'Necoro' Neumann1-2/+2 2010-05-12Show more detailsRené 'Necoro' Neumann4-19/+42 2010-05-12Create new form each timeRené 'Necoro' Neumann1-24/+26 2010-05-10Fix redirect in AddRené 'Necoro' Neumann1-1/+1 2010-05-10Added the 'add expense' stuffRené 'Necoro' Neumann4-3/+69