Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions admin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,13 @@ func init() {
EnvVars: []string{"DB_PASS"},
Destination: &dbConfigValues.Password,
},
&cli.StringFlag{
Name: "db-sslmode",
Value: "disable",
Usage: "SSL native support to encrypt the connection to the backend",
EnvVars: []string{"DB_SSLMODE"},
Destination: &dbConfigValues.SSLMode,
},
&cli.IntFlag{
Name: "db-max-idle-conns",
Value: 20,
Expand Down
7 changes: 7 additions & 0 deletions api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,13 @@ func init() {
EnvVars: []string{"DB_PASS"},
Destination: &dbConfigValues.Password,
},
&cli.StringFlag{
Name: "db-sslmode",
Value: "disable",
Usage: "SSL native support to encrypt the connection to the backend",
EnvVars: []string{"DB_SSLMODE"},
Destination: &dbConfigValues.SSLMode,
},
&cli.IntFlag{
Name: "db-max-idle-conns",
Value: 20,
Expand Down
5 changes: 3 additions & 2 deletions backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

const (
// DBString to format connection string to database for postgres
DBString = "host=%s port=%s dbname=%s user=%s password=%s sslmode=disable"
DBString = "host=%s port=%s dbname=%s user=%s password=%s sslmode=%s"
// DBKey to identify the configuration JSON key
DBKey = "db"
)
Expand All @@ -31,6 +31,7 @@ type JSONConfigurationDB struct {
Name string `json:"name"`
Username string `json:"username"`
Password string `json:"password"`
SSLMode string `json:"sslmode"`
MaxIdleConns int `json:"maxIdleConns"`
MaxOpenConns int `json:"maxOpenConns"`
ConnMaxLifetime int `json:"connMaxLifetime"`
Expand All @@ -57,7 +58,7 @@ func LoadConfiguration(file, key string) (JSONConfigurationDB, error) {
// PrepareDSN to generate DB connection string
func PrepareDSN(config JSONConfigurationDB) string {
return fmt.Sprintf(
DBString, config.Host, config.Port, config.Name, config.Username, config.Password)
DBString, config.Host, config.Port, config.Name, config.Username, config.Password, config.SSLMode)
}

// GetDB to get PostgreSQL DB using GORM
Expand Down
1 change: 1 addition & 0 deletions deploy/config/db.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"name": "_DB_NAME",
"username": "_DB_USERNAME",
"password": "_DB_PASSWORD",
"sslmode": "disable",
"maxIdleConns": 20,
"maxOpenConns": 100,
"connMaxLifetime": 30,
Expand Down
7 changes: 7 additions & 0 deletions tls/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,13 @@ func init() {
EnvVars: []string{"DB_PASS"},
Destination: &dbConfigValues.Password,
},
&cli.StringFlag{
Name: "db-sslmode",
Value: "disable",
Usage: "SSL native support to encrypt the connection to the backend",
EnvVars: []string{"DB_SSLMODE"},
Destination: &dbConfigValues.SSLMode,
},
&cli.IntFlag{
Name: "db-max-idle-conns",
Value: 20,
Expand Down