2024-08-20 11:49:05 +02:00
|
|
|
package config
|
2024-08-20 13:35:49 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
|
|
)
|
|
|
|
|
|
|
|
var Config *ConfigType
|
|
|
|
|
|
|
|
func Load() {
|
|
|
|
configPath := os.Getenv("TIJLDEV_CONFIG_LOCATION")
|
|
|
|
if configPath == "" {
|
|
|
|
configPath = "./config.yaml"
|
|
|
|
}
|
|
|
|
|
|
|
|
indexFile, err := os.ReadFile(configPath)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = yaml.Unmarshal(indexFile, &Config)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Debug("loaded config")
|
|
|
|
}
|
|
|
|
|
|
|
|
type ConfigType struct {
|
|
|
|
UrlBase string `yaml:"url_base"`
|
|
|
|
DB `yaml:"database"`
|
|
|
|
Oidc `yaml:"oidc"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type DB struct {
|
|
|
|
User string `yaml:"user"`
|
|
|
|
Passsword string `yaml:"password"`
|
|
|
|
Database string `yaml:"database"`
|
|
|
|
Host string `yaml:"host"`
|
|
|
|
Port int `yaml:"port"`
|
|
|
|
|
|
|
|
UrlExtention string `yaml:"connection_url_extention"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Oidc struct {
|
|
|
|
ClientID string `yaml:"client_id"`
|
|
|
|
ClientSecret string `yaml:"client_secret"`
|
|
|
|
Issuer string `yaml:"issuer"`
|
|
|
|
}
|