feature: integrate SSL mode for PG connections (#77)

Right now, the default connection for postgres is `disable`. Some
databases require `verify` or even `required`.
This PR introduces a new implementation that allows the user to override
the `disable` mode. The PR keeps a backwards compatible config entry, that
sets the default behavior to `disable` if it's missing.
This commit is contained in:
Roman
2021-05-18 13:00:40 +02:00
committed by GitHub
parent b9b7ed25ca
commit 7bbbc01f84
4 changed files with 33 additions and 1 deletions

View File

@@ -57,9 +57,10 @@ func New(config ...Config) *Storage {
dsn += "@"
}
dsn += fmt.Sprintf("%s:%d", url.QueryEscape(cfg.Host), cfg.Port)
dsn += fmt.Sprintf("/%s?connect_timeout=%d&sslmode=disable",
dsn += fmt.Sprintf("/%s?connect_timeout=%d&sslmode=%s",
url.QueryEscape(cfg.Database),
int64(cfg.timeout.Seconds()),
cfg.SslMode,
)
// Create db