blob: 0a50901d7fea4c3f0e10c4c9c975a9666201ef89 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// SPDX-FileCopyrightText: © 2020 Grégoire Duchêne <gduchene@awhk.org>
// SPDX-License-Identifier: ISC
package main
import (
"io/ioutil"
"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(filename string) (*Config, error) {
b, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
cfg := &Config{}
err = yaml.Unmarshal(b, cfg)
if err != nil {
return nil, err
}
return cfg, nil
}
|