-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
(refactor) Too easy to miss enabling a config as in-db and show it on the CLI #3101
Comments
The https://hackage.haskell.org/package/configuration-tools (source at https://github.com/alephcloud/hs-configuration-tools) could be the right tool for the job — it combines CLI options parser, *JSON instances, JSON/YAML config parsing (that's where it falls short for us, though — need to investigate how hard adding custom config formats' support could be), remote configs even, if needed. The problem here is not every parameter is exposed to command line, configs and/or database, that's where it doesn't quite meet the needs as well. |
I was independently looking for alternatives to One thing I like about configuration-tools is, that it looks like it combines a few very useful things. Some that we already do (config file, environment variables), but also new stuff on top (cli arguments, --help output with a information about the current build, dependencies, licences...). The one thing I am not sure about is how to integrate the in-database-configuration nicely... which is exactly part of this issue :) |
If we're going to change the file format, I think what would make most sense is using an INI format to be compatible with the pg service file (also see this blog post). That way, we could support multiple databases (#2798) with a config like: # pg_service.ini
[serviceone]
port=5432
user=stevechavez
dbname=stevechavez
[serviceone.postgrest]
jwt-secret = xxxx
db-pool = 10
[servicetwo]
port=5432
...
[servicetwo.postgrest]
jwt-secret = yyy
db-pool = 20
other-configs = ".." This also has the advantage of being able to use psql like:
|
Since this is part of libpq, this should already work with postgrest right now. Just export PGSERVICE before you start PostgREST.. should do it already. That also means it might be hard to use this file in a different way - i.e. use multiple services from that file at the same time, because that is not what libpq wants to do. Supporting multiple databases would also easily be possible with yaml. The problem for this ini-based file format is, that it will again be impossible to represent anything more complex. YAML can do much more: arrays, objects, anchors, references, ... so much more. |
Right, so my intention was to process the
We don't have complex values now and we always need to consider that values have to be compatible with the in-db config. pgbouncer seems to do fine with an ini config too. So that doesn't seem like a blocker. |
Problem
This occurred on:
server-timing-enabled
missing on the CLI chore: add missing --example for server-timing-enabled #3069jwt-cache-max-lifetime
missing in-db config on No in-db config forjwt-cache-max-lifetime
#3100This happens because the logic for the CLI and the in-db config is disconnected from the
AppConfig
typepostgrest/src/PostgREST/CLI.hs
Lines 124 to 233 in 0c65bf4
postgrest/src/PostgREST/Config/Database.hs
Lines 44 to 69 in 0c65bf4
postgrest/src/PostgREST/Config.hs
Lines 70 to 115 in 0c65bf4
Solution
Tie the
AppConfig
or other intermediate type to the CLI and the in-db logic.The text was updated successfully, but these errors were encountered: