Skip to content

Commit

Permalink
Use methods to set query parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
jrauh01 committed Dec 3, 2024
1 parent f365c82 commit 702e2e6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions database/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,32 +175,32 @@ func NewDbFromConfig(c *Config, logger *logging.Logger, connectorCallbacks Retry
if port == 0 {
port = 5432
}
query["port"] = []string{strconv.FormatInt(int64(port), 10)}
query.Set("port", strconv.FormatInt(int64(port), 10))

if _, err := c.TlsOptions.MakeConfig(c.Host); err != nil {
return nil, err
}

if c.TlsOptions.Enable {
if c.TlsOptions.Insecure {
query["sslmode"] = []string{"require"}
query.Set("sslmode", "require")
} else {
query["sslmode"] = []string{"verify-full"}
query.Set("sslmode", "verify-full")
}

if c.TlsOptions.Cert != "" {
query["sslcert"] = []string{c.TlsOptions.Cert}
query.Set("sslcert", c.TlsOptions.Cert)
}

if c.TlsOptions.Key != "" {
query["sslkey"] = []string{c.TlsOptions.Key}
query.Set("sslkey", c.TlsOptions.Key)
}

if c.TlsOptions.Ca != "" {
query["sslrootcert"] = []string{c.TlsOptions.Ca}
query.Set("sslrootcert", c.TlsOptions.Ca)
}
} else {
query["sslmode"] = []string{"disable"}
query.Set("sslmode", "disable")
}

uri.RawQuery = query.Encode()
Expand Down

0 comments on commit 702e2e6

Please sign in to comment.