All checks were successful
Tests / Run Go Tests (push) Successful in 1m24s
improved ci/cd pipeline + interactive install script Reviewed-on: #58 Co-authored-by: Tom Tröger <t.troeger.02@gmail.com> Co-committed-by: Tom Tröger <t.troeger.02@gmail.com>
22 lines
630 B
Go
22 lines
630 B
Go
package main
|
|
|
|
import (
|
|
"arbeitszeitmessung/helper"
|
|
"arbeitszeitmessung/models"
|
|
"database/sql"
|
|
"fmt"
|
|
|
|
_ "github.com/lib/pq"
|
|
)
|
|
|
|
func OpenDatabase() (models.IDatabase, error) {
|
|
dbHost := helper.GetEnv("POSTGRES_HOST", "localhost")
|
|
dbName := helper.GetEnv("POSTGRES_DB", "arbeitszeitmessung")
|
|
dbUser := helper.GetEnv("POSTGRES_API_USER", "api_nutzer")
|
|
dbPassword := helper.GetEnv("POSTGRES_API_PASS", "password")
|
|
dbTz := helper.GetEnv("TZ", "Europe/Berlin")
|
|
|
|
connStr := fmt.Sprintf("postgres://%s:%s@%s:5432/%s?sslmode=disable&TimeZone=%s", dbUser, dbPassword, dbHost, dbName, dbTz)
|
|
return sql.Open("postgres", connStr)
|
|
}
|