aboutsummaryrefslogtreecommitdiff
path: root/internal/config/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/config/config.go')
-rw-r--r--internal/config/config.go35
1 files changed, 15 insertions, 20 deletions
diff --git a/internal/config/config.go b/internal/config/config.go
index 2df7d98..361246e 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -2,51 +2,46 @@ package config
import (
"fmt"
- "gopkg.in/yaml.v3"
"io/ioutil"
)
type Map map[string]interface{}
type Feeds map[string]*Feed
-type config struct {
- GlobalConfig Map `yaml:",inline"`
- Feeds []configGroupFeed
-}
-
type Config struct {
- GlobalConfig Map `yaml:",inline"`
+ GlobalConfig Map
Feeds Feeds
}
type Feed struct {
- Name string
- Target string
- Url string
- MinFreq int
- Config Map
+ Name string
+ Target string `yaml:"-"`
+ Url string
+ MinFreq int `yaml:"min-frequency"`
+ InclImages *bool `yaml:"include-images"`
}
-func Load(path string) (*Config, error) {
+func Load(path string) (Config, error) {
+ var finishedCfg Config
+
buf, err := ioutil.ReadFile(path)
if err != nil {
- return nil, fmt.Errorf("while reading '%s': %w", path, err)
+ return finishedCfg, fmt.Errorf("while reading '%s': %w", path, err)
}
var parsedCfg config
- if err := yaml.Unmarshal(buf, &parsedCfg); err != nil {
- return nil, fmt.Errorf("while unmarshalling: %w", err)
+ if parsedCfg, err = parse(buf); err != nil {
+ return finishedCfg, err
}
- fmt.Printf("--- parsedCfg:\n%+v\n\n", parsedCfg)
- var finishedCfg = Config{
+ finishedCfg = Config{
GlobalConfig: parsedCfg.GlobalConfig,
Feeds: make(Feeds),
}
if err := buildFeeds(parsedCfg.Feeds, "", finishedCfg.Feeds); err != nil {
- return nil, fmt.Errorf("while parsing: %w", err)
+ return finishedCfg, fmt.Errorf("while parsing: %w", err)
}
- return &finishedCfg, nil
+ return finishedCfg, nil
}