aboutsummaryrefslogtreecommitdiff
path: root/internal/config/yaml.go
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2020-04-18 00:44:04 +0200
committerRené 'Necoro' Neumann <necoro@necoro.eu>2020-04-18 00:44:04 +0200
commit1dffefe667760113d23f89e65b066a78b9d7e0b0 (patch)
tree41f7d4485f7fd98838215f99ef66dc57092bcfb1 /internal/config/yaml.go
parent5b1a3c9c54652f4ed70677729ccaeabb498f0954 (diff)
downloadfeed2imap-go-1dffefe667760113d23f89e65b066a78b9d7e0b0.tar.gz
feed2imap-go-1dffefe667760113d23f89e65b066a78b9d7e0b0.tar.bz2
feed2imap-go-1dffefe667760113d23f89e65b066a78b9d7e0b0.zip
Tests
Diffstat (limited to 'internal/config/yaml.go')
-rw-r--r--internal/config/yaml.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/internal/config/yaml.go b/internal/config/yaml.go
index 335dede..aa58685 100644
--- a/internal/config/yaml.go
+++ b/internal/config/yaml.go
@@ -1,6 +1,14 @@
package config
-import "fmt"
+import (
+ "fmt"
+ "gopkg.in/yaml.v3"
+)
+
+type config struct {
+ GlobalConfig Map `yaml:",inline"`
+ Feeds []configGroupFeed
+}
type Group struct {
Group string
@@ -32,6 +40,16 @@ func (grpFeed *configGroupFeed) target() string {
return grpFeed.Group.Group
}
+func parse(buf []byte) (config, error) {
+ var parsedCfg config
+ if err := yaml.Unmarshal(buf, &parsedCfg); err != nil {
+ return parsedCfg, fmt.Errorf("while unmarshalling: %w", err)
+ }
+ fmt.Printf("--- parsedCfg:\n%+v\n\n", parsedCfg)
+
+ return parsedCfg, nil
+}
+
func appTarget(target, app string) string {
if target == "" {
return app