Skip to content

Commit

Permalink
Merge pull request #246 from databacker/no-override-config-unless-set
Browse files Browse the repository at this point in the history
server connection flags should not override unless explicitly set
  • Loading branch information
deitch authored Nov 21, 2023
2 parents 624330f + 4dffb94 commit 85e24ae
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,19 @@ func rootCmd(execs execs) (*cobra.Command, error) {
}
// override config with env var or CLI flag, if set
dbHost := v.GetString("server")
if dbHost != "" {
if dbHost != "" && v.IsSet("server") {
dbconn.Host = dbHost
}
dbPort := v.GetInt("port")
if dbPort != 0 {
if dbPort != 0 && v.IsSet("port") {
dbconn.Port = dbPort
}
dbUser := v.GetString("user")
if dbUser != "" {
if dbUser != "" && v.IsSet("dbUser") {
dbconn.User = dbUser
}
dbPass := v.GetString("pass")
if dbPass != "" {
if dbPass != "" && v.IsSet("pass") {
dbconn.Pass = dbPass
}

Expand Down

0 comments on commit 85e24ae

Please sign in to comment.