Skip to content

Commit

Permalink
added custom cli
Browse files Browse the repository at this point in the history
  • Loading branch information
adubovikov committed Jun 19, 2024
1 parent e03dc66 commit 9e5c7b8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
25 changes: 20 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1166,16 +1166,21 @@ func getDataDBSession() (map[string]*gorm.DB, []model.DatabasesMap) {
keepAlive = viper.GetBool(keyData + ".keepalive")
}

customcli := ""
if viper.IsSet(keyData + ".custom_cli") {
customcli = viper.GetString(keyData + ".custom_cli")
}

sslMode := "disable"
if viper.IsSet(keyData + ".sslmode") {
sslMode = viper.GetString(keyData + ".sslmode")
} else if viper.IsSet(keyData+".usessl") && viper.GetBool(keyData+".usessl") {
sslMode = "require"
}

logger.Info(fmt.Sprintf("Connecting to [%s, %s, %s, %s, %d, ssl: %s]\n", host, user, name, node, port, sslMode))
logger.Info(fmt.Sprintf("Connecting to [%s, %s, %s, %s, %d, ssl: %s, custom_cli: %s]\n", host, user, name, node, port, sslMode, customcli))

connectString := fmt.Sprintf("host=%s user=%s dbname=%s sslmode=%s password=%s", host, user, name, sslMode, password)
connectString := fmt.Sprintf("host=%s user=%s dbname=%s sslmode=%s password=%s %s", host, user, name, sslMode, password, customcli)

if port != 0 {
connectString += fmt.Sprintf(" port=%d", port)
Expand Down Expand Up @@ -1273,7 +1278,12 @@ func getDataDBSession() (map[string]*gorm.DB, []model.DatabasesMap) {
keepAlive = viper.GetBool("database_data.keepalive")
}

logger.Info(fmt.Sprintf("Connecting to the old way: [%s, %s, %s, %d]\n", host, user, name, port))
customcli := ""
if viper.IsSet("database_data.custom_cli") {
customcli = viper.GetString("database_data.custom_cli")
}

logger.Info(fmt.Sprintf("Connecting to the old way: [%s, %s, %s, %d, %s]\n", host, user, name, port, customcli))

sslMode := "disable"
if viper.IsSet("database_data.sslmode") {
Expand All @@ -1282,7 +1292,7 @@ func getDataDBSession() (map[string]*gorm.DB, []model.DatabasesMap) {
sslMode = "require"
}

connectString := fmt.Sprintf("host=%s user=%s dbname=%s sslmode=%s password=%s", host, user, name, sslMode, password)
connectString := fmt.Sprintf("host=%s user=%s dbname=%s sslmode=%s password=%s %s", host, user, name, sslMode, password, customcli)

if port != 0 {
connectString += fmt.Sprintf(" port=%d", port)
Expand Down Expand Up @@ -1357,7 +1367,12 @@ func getConfigDBSession() *gorm.DB {
sslMode = "require"
}

connectString := fmt.Sprintf("host=%s user=%s dbname=%s sslmode=%s password=%s", host, user, name, sslMode, password)
customcli := ""
if viper.IsSet("database_config.custom_cli") {
customcli = viper.GetString("database_config.custom_cli")
}

connectString := fmt.Sprintf("host=%s user=%s dbname=%s sslmode=%s password=%s %s", host, user, name, sslMode, password, customcli)

if port != 0 {
connectString += fmt.Sprintf(" port=%d", port)
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

// VERSION
var VERSION_APPLICATION = "1.5.2"
var VERSION_APPLICATION = "1.5.3"

// NAME
var NAME_APPLICATION = "homer-app"
Expand Down

0 comments on commit 9e5c7b8

Please sign in to comment.