Skip to content

Commit

Permalink
Let tools use PG* env variables
Browse files Browse the repository at this point in the history
If options are not specified in the connection string, the postgres
driver will pick the corresponding environment variables.

Therefore this commit changes the default connection string to the empty
string.

This commit fixes nnev#70.
  • Loading branch information
fgrsnau committed Nov 16, 2019
1 parent de4dbba commit 9b90391
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion c14h/db_port.go
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ import (
var (
db *sql.DB
driver = flag.String("driver", "postgres", "The database driver to use")
connect = flag.String("connect", "dbname=nnev host=/var/run/postgresql sslmode=disable", "The connection string to use")
connect = flag.String("connect", "", "The connection string to use")
)

func openDB() (err error) {
2 changes: 1 addition & 1 deletion c14h/main.go
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ import (
var (
addr = flag.String("listen", "0.0.0.0:6725", "The address to listen on")
driver = flag.String("driver", "postgres", "The database driver to use")
connect = flag.String("connect", "dbname=nnev host=/var/run/postgresql sslmode=disable", "The connection string to use")
connect = flag.String("connect", "", "The connection string to use")
gettpl = flag.String("template", "/var/www/www.noname-ev.de/edit_c14.html", "The template to serve for editing c¼")
hook = flag.String("hook", "", "A hook to run on every change")

5 changes: 4 additions & 1 deletion data/data.go
Original file line number Diff line number Diff line change
@@ -14,7 +14,10 @@ import (

var (
driver = flag.String("driver", "postgres", "Der benutzte sql-Treiber")
connect = flag.String("connect", "dbname=nnev user=anon host=/var/run/postgresql sslmode=disable", "Die Verbindungsspezifikation")

// If the connection string is empty, the postgres driver will extract the
// config out of environment variables (PGHOST, PGUSER, PGDATABASE, ...).
connect = flag.String("connect", "", "Die Verbindungsspezifikation")
)

// OpenDB opens a connection to the database with parameters derived from flags.
2 changes: 1 addition & 1 deletion yarpnarp/main.go
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ import (
var (
addr = flag.String("listen", "0.0.0.0:5417", "The address to listen on")
driver = flag.String("driver", "postgres", "The database driver to use")
connect = flag.String("connect", "dbname=nnev host=/var/run/postgresql sslmode=disable", "The connection string to use")
connect = flag.String("connect", "", "The connection string to use")
gettpl = flag.String("template", "/var/www/www.noname-ev.de/yarpnarp.html", "The template to serve for editing zusagen")
hook = flag.String("hook", "", "A hook to run on every change")

0 comments on commit 9b90391

Please sign in to comment.