dev postgres_exporter: respect PG* env var effective values
Created by: sqs
PostgreSQL's PG*
env vars have defined fallbacks. For example, the default for PGUSER (if unset) is $USER
. This commit makes the dev postgres_exporter use the effective values instead of hardcoding the defaults.
This fixes many instances of errors in the dev/start.sh script of the form:
22:21:17 postgres_exporter | time="2020-01-11T06:21:17Z" level=error msg="Error opening connection to database (postgresql://sourcegraph:PASSWORD_REMOVED@localhost:5432/postgres?sslmode=disable): pq: password authentication failed for user \"sourcegraph\"" source="postgres_exporter.go:1403"
(Personally, I do not have PGUSER set in my environment, and my PostgreSQL username is sqs
. I could set PGUSER, but this change makes it so I don't need to, and it will work in more cases without the dev needing to do manual workarounds for the dev postgres_exporter.)