aboutsummaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'config.go')
-rw-r--r--config.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/config.go b/config.go
new file mode 100644
index 0000000..64a4a51
--- /dev/null
+++ b/config.go
@@ -0,0 +1,44 @@
+// SPDX-FileCopyrightText: © 2020 Grégoire Duchêne <gduchene@awhk.org>
+// SPDX-License-Identifier: ISC
+
+package main
+
+import (
+ "io"
+
+ "gopkg.in/yaml.v3"
+)
+
+type Config struct {
+ Message Message `yaml:"message"`
+ SMTP SMTP `yaml:"smtp"`
+ Twilio Twilio `yaml:"twilio"`
+}
+
+type Message struct {
+ From string `yaml:"from"`
+ To string `yaml:"to"`
+ Subject string `yaml:"subject"`
+ Template string `yaml:"template"`
+}
+
+type SMTP struct {
+ Address string `yaml:"hostname"`
+ Username string `yaml:"username"`
+ Password string `yaml:"password"`
+}
+
+type Twilio struct {
+ Address string `yaml:"address"`
+ AuthToken string `yaml:"authToken"`
+ Endpoint string `yaml:"endpoint"`
+}
+
+func loadConfig(r io.Reader) (*Config, error) {
+ dec := yaml.NewDecoder(r)
+ cfg := &Config{}
+ if err := dec.Decode(cfg); err != nil {
+ return nil, err
+ }
+ return cfg, nil
+}