fix: add sslmode check and apend flag to conn string (#3009)

This commit is contained in:
Laurence Jones 2024-05-14 17:31:15 +01:00 committed by GitHub
parent 11893b2915
commit b5e5078fc7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -48,7 +48,7 @@ type AuthGCCfg struct {
}
type FlushDBCfg struct {
MaxItems *int `yaml:"max_items,omitempty"`
MaxItems *int `yaml:"max_items,omitempty"`
// We could unmarshal as time.Duration, but alert filters right now are a map of strings
MaxAge *string `yaml:"max_age,omitempty"`
BouncersGC *AuthGCCfg `yaml:"bouncers_autodelete,omitempty"`
@ -131,6 +131,9 @@ func (d *DatabaseCfg) ConnectionString() string {
} else {
connString = fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?parseTime=True", d.User, d.Password, d.Host, d.Port, d.DbName)
}
if d.Sslmode != "" {
connString = fmt.Sprintf("%s&tls=%s", connString, d.Sslmode)
}
case "postgres", "postgresql", "pgx":
if d.isSocketConfig() {
connString = fmt.Sprintf("host=%s user=%s dbname=%s password=%s", d.DbPath, d.User, d.DbName, d.Password)