Support of PGTARGETSESSIONATTRS ENV variable
Signed-off-by: Artemiy Ryabinkov <getlag@ya.ru>
This commit is contained in:
@@ -1016,6 +1016,7 @@ func ParseURI(uri string) (ConnConfig, error) {
|
|||||||
if cp.Password == "" {
|
if cp.Password == "" {
|
||||||
pgpass(&cp)
|
pgpass(&cp)
|
||||||
}
|
}
|
||||||
|
|
||||||
return cp, nil
|
return cp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1181,7 +1182,7 @@ func ParseConnectionString(s string) (ConnConfig, error) {
|
|||||||
// PGSSLROOTCERT
|
// PGSSLROOTCERT
|
||||||
// PGAPPNAME
|
// PGAPPNAME
|
||||||
// PGCONNECT_TIMEOUT
|
// PGCONNECT_TIMEOUT
|
||||||
// TODO: PGTARGETSESSIONATTRS support
|
// PGTARGETSESSIONATTRS
|
||||||
// @see: https://www.postgresql.org/docs/10/libpq-envars.html
|
// @see: https://www.postgresql.org/docs/10/libpq-envars.html
|
||||||
//
|
//
|
||||||
// Important TLS Security Notes:
|
// Important TLS Security Notes:
|
||||||
@@ -1228,6 +1229,11 @@ func ParseEnvLibpq() (ConnConfig, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cc.TargetSessionAttrs = TargetSessionType(os.Getenv("PGTARGETSESSIONATTRS"))
|
||||||
|
if err := cc.TargetSessionAttrs.isValid(); err != nil {
|
||||||
|
return cc, err
|
||||||
|
}
|
||||||
|
|
||||||
tlsArgs := configTLSArgs{
|
tlsArgs := configTLSArgs{
|
||||||
sslMode: os.Getenv("PGSSLMODE"),
|
sslMode: os.Getenv("PGSSLMODE"),
|
||||||
sslKey: os.Getenv("PGSSLKEY"),
|
sslKey: os.Getenv("PGSSLKEY"),
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ func parsepgpass(line, cfgHost, cfgPort, cfgDatabase, cfgUsername string) *strin
|
|||||||
return &parts[4]
|
return &parts[4]
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Multi-host support
|
|
||||||
func pgpass(cfg *ConnConfig) (found bool) {
|
func pgpass(cfg *ConnConfig) (found bool) {
|
||||||
passfile := os.Getenv("PGPASSFILE")
|
passfile := os.Getenv("PGPASSFILE")
|
||||||
if passfile == "" {
|
if passfile == "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user