Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: PGSQL JDBC password parsing #10

Merged
merged 3 commits into from
Aug 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"flag"
"log"
"net/http"
Expand All @@ -14,6 +15,12 @@ var addr = flag.String("addr", ":8080", "http service address")

var (
Logger *log.Logger
host string = os.Getenv("DB_HOST")
port string = os.Getenv("DB_PORT")
user string = os.Getenv("DB_USER")
password string = os.Getenv("DB_PASSWORD")
dbname string = os.Getenv("DB_NAME")
params string = os.Getenv("DB_PARAMS")
)

func main() {
Expand All @@ -38,7 +45,10 @@ func main() {
}

func getOrganizationId(userId string) string {
db, dberr := sql.Open("postgres", os.Getenv("DB_DSN"))
psqlInfo := fmt.Sprintf(
"host=%s port=%s user=%s password=%s dbname=%s %s",
host, port, user, password, dbname, params)
db, dberr := sql.Open("postgres", psqlInfo)
if dberr != nil {
log.Fatal("Failed to open a DB connection: ", dberr)
}
Expand Down
Loading