From d95e8ce75cc193181fd8cf9272269fbfff911f66 Mon Sep 17 00:00:00 2001 From: Grégoire Duchêne Date: Sun, 4 Jul 2021 17:20:50 +0100 Subject: Simplify project structure --- config.go | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 config.go (limited to 'config.go') 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 +// 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 +} -- cgit v1.2.3-70-g09d2