summaryrefslogtreecommitdiff
path: root/pkg/config/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/config/config.go')
-rw-r--r--pkg/config/config.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/pkg/config/config.go b/pkg/config/config.go
new file mode 100644
index 0000000..0c967fd
--- /dev/null
+++ b/pkg/config/config.go
@@ -0,0 +1,36 @@
+package config
+
+import (
+ "os"
+
+ "gopkg.in/yaml.v3"
+)
+
+type Config struct {
+ Listen string `yaml:"listen"`
+ Node string `yaml:"node"`
+ Store string `yaml:"store"`
+ LoggerType int `yaml:"logger_type"`
+ Echos map[string]Echo `yaml:"echos"`
+ Fetch []Node `yaml:"fetch"`
+}
+
+type Node struct {
+ Addr string `yaml:"addr"`
+ Echos []string `yaml:"echos"`
+}
+
+type Echo struct {
+ Description string `yaml:"description"`
+}
+
+func New(filePath string) (*Config, error) {
+ cfg := new(Config)
+ fp, err := os.Open(filePath)
+ if err != nil {
+ return nil, err
+ }
+ defer fp.Close()
+
+ return cfg, yaml.NewDecoder(fp).Decode(cfg)
+}