tijl.dev-core/internal/config/config.go
tijl d77d2cc94c
All checks were successful
build / build (push) Successful in 51s
web changes + blog implementation
2024-08-22 18:04:08 +02:00

47 lines
938 B
Go

package config
import (
"os"
log "git.tijl.dev/tijl/tijl.dev-core/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"`
BlogLocation string `yaml:"blog_location"`
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"`
}