maplibre/martin

Remove automatic ENV var usage except inside config files

Aperta

#1052 aperta il 7 dic 2023

 (0 commenti) (0 reazioni) (0 assegnatari)Rust (377 fork)auto 404
breakingcliconfiggood first issuehelp wantedpgrust

Metriche repository

Star
 (3761 stelle)
Metriche merge PR
 (Merge medio 2g 16h) (78 PR mergiate in 30 g)

Descrizione

Per discussion in #1050, we should scale down on Martin's implicit usage of the environment variables. This is too unpredictable and could result in all sorts of weird behavior. Instead, Martin should only rely on two things: command line parameters and config files. The config files will continue supporting explicit environment variables, e.g. connection_string: ${MY_DATABASE_URL} or even with a fallback like connection_string: ${MY_DATABASE_URL:-postgresql://postgres@localhost/db}

Tasks

  • Ensure ALL env vars can be set at least with the config file, or best -- with both config file and CLI parameters. (I think they already are, but double check)
  • Detect if any of these env vars are set, and if they are, show a warning with clear instructions on doing it with either CLI parameters or with config (or both, or a link to docs).
    • For example, if DATABASE_URL is set, suggest to use martin "$DATABASE_URL" instead, or add postgres.connection_string: ${DATABASE_URL} to the config file.
  • Remove any magical handling of the env vars from the code (except for the above detection and warnings)
  • Update documentation

Alternatives

Instead of removing, we could follow other Rust tools pattern, and rename all environment variables to be MARTIN_*, e.g. MARTIN_DATABASE_URL. In my opinion, we should still disable the existing ones as they create too many conflicts with other tooling that relies on the same env vars.

Guida contributor