46 lines
883 B
Go
46 lines
883 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.Info().Msg("loaded config")
|
|
}
|
|
|
|
type ConfigType struct {
|
|
Host string `yaml:"host"`
|
|
Port int `yaml:"port"`
|
|
UrlBase string `yaml:"url_base"`
|
|
JsonLogging bool `yaml:"log_json"`
|
|
DB string `yaml:"database"`
|
|
Oidc `yaml:"oidc"`
|
|
}
|
|
|
|
type Oidc struct {
|
|
ClientID string `yaml:"client_id"`
|
|
ClientSecret string `yaml:"client_secret"`
|
|
Provider string `yaml:"issuer"`
|
|
CallbackUrl string `yaml:"callback_url"`
|
|
}
|