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

Do not required hardcoded postgres connection uri in config file #1016

Open
apjoseph opened this issue Dec 17, 2024 · 4 comments
Open

Do not required hardcoded postgres connection uri in config file #1016

apjoseph opened this issue Dec 17, 2024 · 4 comments

Comments

@apjoseph
Copy link

Tegola is using PGX to connect to Postgis enabled postgres database. By default, PGX handles standard libpq env variables like PGHOST, PGDATABASE, PGPORT, PGUSER, PGPASSWORD. However Tegola forces either hardcoding the connection url into the config file or manually setting interpolated env vars. This is clunky and unintuitive (especially if you have a password that contains a character that needs escaping) and could be solved by making the connection uri in the config file optional and allowing pgx to handle validating the connection. directly.

If multiple postgis providers are needed, postgres has a built in convention for this using the pgservicefile which is also supported by default by PGX without any additional configuration needed

an optional service parameter could be added to allow switching between multiple providers. This way Tegola does not need to reinvent the wheel and manually handle what PGX can already do.

@apjoseph
Copy link
Author

actually you don't even need the extra service parameter. if tegola just feeds the url directly to pgx you can specify the service in the uri like postgres:///?service=pg-db all that needs to be done is not pre-validate the connection uri

@ARolek
Copy link
Member

ARolek commented Dec 19, 2024

@apjoseph I'm all for supporting more ways to load in the connection string. I just want to make sure we prove the connection is valid at start up. I think this change could be fairly easy to implement by just doing a check if a connection string is present, and if not then let pgx run through it's load routine. If that fails, return an error.

Do you want to tackle implementing this?

@iwpnd
Copy link
Member

iwpnd commented Dec 19, 2024

happy to look into it otherwise.

@ARolek
Copy link
Member

ARolek commented Dec 19, 2024

@iwpnd if you want to tackle this feel free to pick it up as well. I think it is a good enhancement and you're pretty familiar with that part of the codebase ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants