feat: config
This commit is contained in:
36
config.go
Normal file
36
config.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
|
||||
"git.schreifuchs.ch/lou-taylor/accounting/mailer"
|
||||
"git.schreifuchs.ch/lou-taylor/accounting/model"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
GiteaURL string `json:"gitea_url"`
|
||||
GiteaToken string `json:"gitea_token"`
|
||||
Repos []Repo `json:"repos"`
|
||||
MinDuration Duration `json:"min_duration"`
|
||||
Hourly float64 `json:"hourly"`
|
||||
FromEntity model.Entity `json:"from_entity"`
|
||||
ToEntity model.Entity `json:"to_entity"`
|
||||
PdfGeneratorURL string `json:"pdf_generator_url"`
|
||||
Mailer mailer.Config `json:"mailer"`
|
||||
Mail mailer.Mail `json:"mail"`
|
||||
MailBcc []string `json:"mail_bcc"`
|
||||
}
|
||||
|
||||
func LoadConfig(path string) (Config, error) {
|
||||
var cfg Config
|
||||
file, err := os.Open(path)
|
||||
if err != nil {
|
||||
return cfg, err
|
||||
}
|
||||
defer file.Close()
|
||||
decoder := json.NewDecoder(file)
|
||||
err = decoder.Decode(&cfg)
|
||||
return cfg, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user