maplibre/martin

Remove automatic ENV var usage except inside config files

Open

#1,052 opened on Dec 7, 2023

 (0 comments) (0 reactions) (0 assignees)Rust (377 forks)auto 404
breakingcliconfiggood first issuehelp wantedpgrust

Repository metrics

Stars
 (3,761 stars)
PR merge metrics
 (PR metrics pending)

Description

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.

Contributor guide