tijl.dev-core/internal/config/config.go
tijl c6dc9cd110
Some checks failed
build / build (push) Failing after 0s
updates
2024-08-21 01:08:47 +02:00

52 lines
960 B
Go

package config
import (
"os"
log "git.tijl.dev/tijl/tijl.dev/modules/logger"
"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)
}
err = yaml.Unmarshal(indexFile, &Config)
if err != nil {
log.Fatal().Err(err)
}
log.Debug().Msg("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"`
}