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 {
local platform fileJason A. Donenfeld2-3/+3 2014-04-19platform: Allow custom platform file before installJason A. Donenfeld2-3/+5 2014-04-18reencrypt: cleaner temp file declarationJason A. Donenfeld1-4/+4 2014-04-18Remove unneeded semicolon.Jason A. Donenfeld1-14/+14 2014-04-18Check sneaky paths.Jason A. Donenfeld1-0/+15 2014-04-18Pruning: turns out rmdir does it for us with -p.Jason A. Donenfeld1-9/+3 2014-04-18Abstract remove empty directories into function.Jason A. Donenfeld1-14/+11 2014-04-18Remember to prune empty folders.Jason A. Donenfeld1-0/+8 2014-04-18init: allow deinitializationJason A. Donenfeld2-2/+18 2014-04-18bash-completion: filter dot files from resultsJason A. Donenfeld1-3/+8 2014-04-18reencrypt: remove option, do automaticallyJason A. Donenfeld5-39/+25 2014-04-18reencryption: add to completion filesJason A. Donenfeld3-1/+5 2014-04-18Specify variable gpg.Jason A. Donenfeld1-1/+1 2014-04-18style: don't escape new line on &&Jason A. Donenfeld1-2/+2 2014-04-18reencryption: remove temporary file on failureJason A. Donenfeld1-1/+1 2014-04-18reencryption: only reencrypt files when requiredJason A. Donenfeld2-16/+37 2014-04-17cp: typo as cvJason A. Donenfeld1-1/+1 2014-04-17bash: gpg_id is localJason A. Donenfeld1-0/+1 2014-04-17move/copy: always reencrypt passwords at destinationJason A. Donenfeld5-25/+56 2014-04-17makefile: allow platform files with gnu sedJason A. Donenfeld1-7/+8 2014-04-17mv: Add pass mv/rename supportJason A. Donenfeld5-3/+78 2014-04-17revelation2pass: add plain XML importJavali1-11/+15 2014-04-17platform: add cygwin supportJason A. Donenfeld2-1/+17