diff options
| author | Grégoire Duchêne <gduchene@awhk.org> | 2021-07-04 17:20:50 +0100 |
|---|---|---|
| committer | Grégoire Duchêne <gduchene@awhk.org> | 2021-07-04 17:20:50 +0100 |
| commit | d95e8ce75cc193181fd8cf9272269fbfff911f66 (patch) | |
| tree | f25e86b4768050d39b932bfb9e42970cfc5936e4 /config.go | |
| parent | 03f9f907ed21a9c56b229668b28571969d988a8c (diff) | |
Simplify project structure
Diffstat (limited to 'config.go')
| -rw-r--r-- | config.go | 44 |
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 +} |
