feat(init): First commit
This commit is contained in:
commit
f92368748a
22 changed files with 1298 additions and 0 deletions
45
pkg/config/config.go
Normal file
45
pkg/config/config.go
Normal file
|
@ -0,0 +1,45 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
providerConfigs "git.maurice.fr/thomas/mailout/pkg/providers/configs"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Postgres struct {
|
||||
Hostname string `yaml:"hostname"`
|
||||
Port int `yaml:"port"`
|
||||
User string `yaml:"user"`
|
||||
Password string `yaml:"password"`
|
||||
Database string `yaml:"database"`
|
||||
SSLMode string `yaml:"sslmode"`
|
||||
} `yaml:"postgres"`
|
||||
Providers struct {
|
||||
OVH *providerConfigs.OVHConfig `yaml:"ovh"`
|
||||
} `yaml:"providers"`
|
||||
}
|
||||
|
||||
func LoadConfig(path string) (*Config, error) {
|
||||
b, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var cfg Config
|
||||
err = yaml.Unmarshal(b, &cfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if cfg.Postgres.SSLMode == "" {
|
||||
cfg.Postgres.SSLMode = "disable"
|
||||
}
|
||||
|
||||
if cfg.Postgres.Port == 0 {
|
||||
cfg.Postgres.Port = 5432
|
||||
}
|
||||
|
||||
return &cfg, err
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue