mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Add stordb pgSSLCertMode option
This commit is contained in:
committed by
Dan Christian Bogos
parent
9a79b092a5
commit
73fc386036
@@ -29,7 +29,7 @@ import (
|
||||
|
||||
// NewPostgresStorage returns the posgres storDB
|
||||
func NewPostgresStorage(host, port, name, user, password, pgSchema,
|
||||
sslmode, sslcert, sslkey, sslpassword, sslrootcert string,
|
||||
sslmode, sslcert, sslkey, sslpassword, sslcertmode, sslrootcert string,
|
||||
maxConn, maxIdleConn int, connMaxLifetime time.Duration) (*SQLStorage, error) {
|
||||
connStr := fmt.Sprintf(
|
||||
"host=%s port=%s dbname=%s user=%s password=%s sslmode=%s",
|
||||
@@ -43,6 +43,9 @@ func NewPostgresStorage(host, port, name, user, password, pgSchema,
|
||||
if sslpassword != "" {
|
||||
connStr = connStr + " sslpassword=" + sslpassword
|
||||
}
|
||||
if sslcertmode != "" {
|
||||
connStr = connStr + " sslcertmode=" + sslcertmode
|
||||
}
|
||||
if sslrootcert != "" {
|
||||
connStr = connStr + " sslrootcert=" + sslrootcert
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ func NewStorDBConn(dbType, host, port, name, user, pass, marshaler string,
|
||||
db, err = NewMongoStorage(opts.MongoConnScheme, host, port, name, user, pass, marshaler, utils.StorDB, stringIndexedFields, opts.MongoQueryTimeout)
|
||||
case utils.MetaPostgres:
|
||||
db, err = NewPostgresStorage(host, port, name, user, pass, opts.PgSchema, opts.PgSSLMode,
|
||||
opts.PgSSLCert, opts.PgSSLKey, opts.PgSSLPassword, opts.PgSSLRootCert,
|
||||
opts.PgSSLCert, opts.PgSSLKey, opts.PgSSLPassword, opts.PgSSLCertMode, opts.PgSSLRootCert,
|
||||
opts.SQLMaxOpenConns, opts.SQLMaxIdleConns, opts.SQLConnMaxLifetime)
|
||||
case utils.MetaMySQL:
|
||||
db, err = NewMySQLStorage(host, port, name, user, pass, opts.SQLMaxOpenConns, opts.SQLMaxIdleConns,
|
||||
|
||||
@@ -108,9 +108,10 @@ func TestStorDBit(t *testing.T) {
|
||||
if storDB, err = NewPostgresStorage(storDBCfg.StorDbCfg().Host,
|
||||
storDBCfg.StorDbCfg().Port, storDBCfg.StorDbCfg().Name,
|
||||
storDBCfg.StorDbCfg().User, storDBCfg.StorDbCfg().Password,
|
||||
storDBCfg.StorDbCfg().Opts.PgSchema, storDBCfg.StorDbCfg().Opts.PgSSLMode,
|
||||
storDBCfg.StorDbCfg().Opts.PgSSLCert, storDBCfg.StorDbCfg().Opts.PgSSLKey,
|
||||
storDBCfg.StorDbCfg().Opts.PgSSLPassword, storDBCfg.StorDbCfg().Opts.PgSSLRootCert,
|
||||
storDBCfg.StorDbCfg().Opts.PgSchema,
|
||||
storDBCfg.StorDbCfg().Opts.PgSSLMode, storDBCfg.StorDbCfg().Opts.PgSSLCert,
|
||||
storDBCfg.StorDbCfg().Opts.PgSSLKey, storDBCfg.StorDbCfg().Opts.PgSSLPassword,
|
||||
storDBCfg.StorDbCfg().Opts.PgSSLCertMode, storDBCfg.StorDbCfg().Opts.PgSSLRootCert,
|
||||
100, 10, 0); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user