good morning!!!!

Skip to content
Snippets Groups Projects
Commit 9b334934 authored by Garet Halliday's avatar Garet Halliday
Browse files

Merge remote-tracking branch 'origin/master'

parents b1b5b2b9 f5e779c9
No related branches found
No related tags found
No related merge requests found
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
PgGat (rat-ta-tat-tat) is a rewrite of [pgcat](github.com/levkk/pgcat) in golang PgGat (rat-ta-tat-tat) is a rewrite of [pgcat](github.com/levkk/pgcat) in golang
the name is inspired by dr. dre: the name is inspired by dr. dre:
https://www.youtube.com/watch?v=-DqCc2DJ0sg https://www.youtube.com/watch?v=-DqCc2DJ0sg
...@@ -26,6 +24,20 @@ i'll lyk when its done ...@@ -26,6 +24,20 @@ i'll lyk when its done
| Client authentication | :white_check_mark: :wrench: | same as them | MD5 password authentication is supported, SCRAM is on the roadmap; one user is used to connect to Postgres with both SCRAM and MD5 supported. | | Client authentication | :white_check_mark: :wrench: | same as them | MD5 password authentication is supported, SCRAM is on the roadmap; one user is used to connect to Postgres with both SCRAM and MD5 supported. |
| Admin database | :white_check_mark: | :white_check_mark: | The admin database, similar to PgBouncer's, allows to query for statistics and reload the configuration. | | Admin database | :white_check_mark: | :white_check_mark: | The admin database, similar to PgBouncer's, allows to query for statistics and reload the configuration. |
## Config
"environmentable fields" are Username, Password, Host, for server and Name, Password for users
for these fields, if the string you put ENV$SOME_ENV_VAR then the env var value of var SOME_ENV_VAR will be used as that value
otherwise, its mostly similar to the original pgcat config. follow the example.
# original README # original README
PostgreSQL pooler (like PgBouncer) with sharding, load balancing and failover support. PostgreSQL pooler (like PgBouncer) with sharding, load balancing and failover support.
......
...@@ -55,7 +55,7 @@ pools: ...@@ -55,7 +55,7 @@ pools:
port: 5432 port: 5432
role: primary role: primary
username: postgres username: postgres
password: example password: ENV$PGGAT_DB_PASS
sharded: sharded:
pool_mode: transaction pool_mode: transaction
default_role: any default_role: any
......
...@@ -3,8 +3,10 @@ package config ...@@ -3,8 +3,10 @@ package config
import ( import (
"os" "os"
"path/filepath" "path/filepath"
"strings"
"github.com/BurntSushi/toml" "github.com/BurntSushi/toml"
"github.com/davecgh/go-spew/spew"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
) )
...@@ -52,6 +54,31 @@ func Load(path string) (*Global, error) { ...@@ -52,6 +54,31 @@ func Load(path string) (*Global, error) {
return nil, err return nil, err
} }
} }
for _, g := range g.Pools {
for _, shard := range g.Shards {
for _, srv := range shard.Servers {
if strings.HasPrefix(srv.Host, "ENV$") {
srv.Host = os.Getenv(strings.TrimPrefix(srv.Host, "ENV$"))
}
if strings.HasPrefix(srv.Username, "ENV$") {
srv.Username = os.Getenv(strings.TrimPrefix(srv.Username, "ENV$"))
}
if strings.HasPrefix(srv.Password, "ENV$") {
srv.Password = os.Getenv(strings.TrimPrefix(srv.Password, "ENV$"))
}
}
for _, srv := range g.Users {
if strings.HasPrefix(srv.Name, "ENV$") {
srv.Name = os.Getenv(strings.TrimPrefix(srv.Name, "ENV$"))
}
if strings.HasPrefix(srv.Password, "ENV$") {
srv.Password = os.Getenv(strings.TrimPrefix(srv.Password, "ENV$"))
}
}
}
}
spew.Println(g)
return &g, nil return &g, nil
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment