PostgreSQL: Support PGPASSFILE by making password optional (#108856)
* datasource(postgresql): add support of pgpass file * remove `required` label for password field * set `runPostgresTests` back to false * fix after merge conflict * add pgx_test * set `runPostgresTests` back to `false` * Add `no password` test case to the `pgx_test.go` as well * fix `postgres_pgx_test.go` * Update datasource docs * docs wording * docs: `datasource` -> `data source` * Update docs/sources/datasources/postgres/configure/_index.md Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com> * run prettier - docs --------- Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
This commit is contained in:
@@ -329,8 +329,13 @@ func parseNetworkAddress(url string, logger log.Logger) (string, int, error) {
|
||||
}
|
||||
|
||||
func buildBaseConnectionString(params connectionParams) string {
|
||||
connStr := fmt.Sprintf("user='%s' password='%s' host='%s' dbname='%s'",
|
||||
escape(params.user), escape(params.password), escape(params.host), escape(params.database))
|
||||
connStr := fmt.Sprintf("user='%s' host='%s' dbname='%s'",
|
||||
escape(params.user), escape(params.host), escape(params.database))
|
||||
|
||||
if params.password != "" {
|
||||
connStr += fmt.Sprintf(" password='%s'", escape(params.password))
|
||||
}
|
||||
|
||||
if params.port > 0 {
|
||||
connStr += fmt.Sprintf(" port=%d", params.port)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user