gotosocial icon indicating copy to clipboard operation
gotosocial copied to clipboard

[chore] cleanup server CLI / environment / configuration file parsing

Open NyaaaWhatsUpDoc opened this issue 2 years ago • 2 comments

Current issues:

  • we accept almost every single configuration variable as CLI flags, our usage printing is already rather absurd but it will get worse as we add more configurables
  • all of our configuration variables live at the root json / toml / yaml "namespace"
  • ephemeral configurables are stored in the main configuration struct, and available all over the codebase via config.Get___() despite only ever being used in cmd/gotosocial/action/...
  • we have no way of outputting updated configuration files based on current settings

My proposed change:

  • we drastically reduce the CLI flags that we support to only the essentials to get the server running: e.g. ports, lets-encrypt, config path, database, storage path
  • move configuration variables into grouped structures e.g. DatabaseConfiguration{}, StorageConfiguration{} etc
  • ephemeral configurables are passed to gts action functions by means of context variables
  • move debug config action to be under config dump-json, and then add dump-yaml and dump-toml actions to allow printing current configuration to file. useful if you have an old configuration file that you want to easily update with the latest flags without manually doing it
  • to make migration from old configuration file format easier, create a cmd/config-migrate utility that allows converting from old to new configuration file format. environment variable parsing and those relying on CLI flags will unfortunately run into breakages, but ultimately we are alpha and I don't think many will be relying on them for the finer configurables (e.g. oidc)

NyaaaWhatsUpDoc avatar Dec 09 '22 21:12 NyaaaWhatsUpDoc

@tsmethurst if you're good with this, I have the start of some changes, and the rest of them ready in my head :)

NyaaaWhatsUpDoc avatar Dec 09 '22 21:12 NyaaaWhatsUpDoc

@NyaaaWhatsUpDoc should we still consider this issue open? Or should we close it? I don't think we're having too much trouble with our config stuff these days.

tsmethurst avatar Jun 16 '24 10:06 tsmethurst