use secure cockroach connection
This commit is contained in:
parent
0583c66d96
commit
4004c1a00d
1 changed files with 6 additions and 1 deletions
7
db/db.go
7
db/db.go
|
@ -20,13 +20,18 @@ func Connect() error {
|
|||
}
|
||||
|
||||
var username = "nobody"
|
||||
var password string
|
||||
|
||||
u, err := user.Current()
|
||||
if err == nil {
|
||||
username = u.Username
|
||||
}
|
||||
if os.Getenv("COCKROACH_USER") != "" {
|
||||
username = os.Getenv("COCKROACH_USER")
|
||||
password = os.Getenv("COCKROACH_PASS")
|
||||
}
|
||||
|
||||
dsn := fmt.Sprintf("postgresql://%s@localhost:26257/cycore?sslmode=disable", username)
|
||||
dsn := fmt.Sprintf("postgresql://%s:%s@localhost:26257/cycore?sslmode=require", username, password)
|
||||
if os.Getenv("DSN") != "" {
|
||||
dsn = os.Getenv("DSN")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue