fix: add yaml tags to OAuth config struct for proper parsing

This commit is contained in:
garionion (aider) 2025-02-27 15:22:19 +01:00
parent 540c69d7d6
commit 0299e2891c

17
main.go
View file

@ -26,11 +26,11 @@ var staticFiles embed.FS
var sqliteMigrations embed.FS
type OAuthConfig struct {
ClientID string `config:"client_id"`
ClientSecret string `config:"client_secret"`
AuthURL string `config:"auth_url"`
TokenURL string `config:"token_url"`
UserInfoURL string `config:"userinfo_url"`
ClientID string `config:"client_id" yaml:"client_id"`
ClientSecret string `config:"client_secret" yaml:"client_secret"`
AuthURL string `config:"auth_url" yaml:"auth_url"`
TokenURL string `config:"token_url" yaml:"token_url"`
UserInfoURL string `config:"userinfo_url" yaml:"userinfo_url"`
}
type DBConfig struct {
@ -48,7 +48,7 @@ type Config struct {
Server struct {
Port int `config:"port"`
} `config:"server"`
OAuth OAuthConfig `config:"oauth"`
OAuth OAuthConfig `config:"oauth" yaml:"oauth"`
DB DBConfig `config:"db"`
}
@ -62,7 +62,7 @@ var db *sql.DB
func main() {
// Use the global cfg variable instead of declaring a new one
cfgReader := config.NewConfReader("config")
cfgReader := config.NewConfReader("config").WithSearchDirs("./", ".", "../", "../../")
cfgErr := cfgReader.Read(&cfg)
zapcfg := zap.NewProductionConfig()
@ -79,7 +79,8 @@ func main() {
logger.Fatal("Failed to load config", zap.Error(cfgErr))
}
logger.Debug("Loaded config", zap.Any("config", cfg))
// Print the raw config to see what's actually loaded
logger.Info("Raw config loaded", zap.Any("config", cfg))
// Add detailed logging of the OAuth config
logger.Info("OAuth Configuration",