Add POSTGRES_SSLMODE for gocoder (#760)

This commit is contained in:
Zoe Roux 2025-01-04 16:57:30 +01:00 committed by GitHub
parent 9be48de1fd
commit 3182cc8d07
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 1 deletions

View File

@ -26,6 +26,8 @@ POSTGRES_PASSWORD=
POSTGRES_DB=
POSTGRES_SERVER=
POSTGRES_PORT=5432
# can also be "require" ("prefer" is not supported)
POSTGRES_SSLMODE="disable"
# Default is gocoder, you can specify "disabled" to use the default search_path of the user.
# If this is not "disabled", the schema will be created (if it does not exists) and
# the search_path of the user will be ignored (only the schema specified will be used).

View File

@ -24,12 +24,13 @@ type MetadataService struct {
func NewMetadataService() (*MetadataService, error) {
con := fmt.Sprintf(
"postgresql://%v:%v@%v:%v/%v?application_name=gocoder&sslmode=disable",
"postgresql://%v:%v@%v:%v/%v?application_name=gocoder&sslmode=%s",
url.QueryEscape(os.Getenv("POSTGRES_USER")),
url.QueryEscape(os.Getenv("POSTGRES_PASSWORD")),
url.QueryEscape(os.Getenv("POSTGRES_SERVER")),
url.QueryEscape(os.Getenv("POSTGRES_PORT")),
url.QueryEscape(os.Getenv("POSTGRES_DB")),
url.QueryEscape(GetEnvOr("POSTGRES_SSLMODE", "disable")),
)
schema := GetEnvOr("POSTGRES_SCHEMA", "gocoder")
if schema != "disabled" {