gotosocial
gotosocial copied to clipboard
[chore] cleanup server CLI / environment / configuration file parsing
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 incmd/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 underconfig dump-json
, and then adddump-yaml
anddump-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)
@tsmethurst if you're good with this, I have the start of some changes, and the rest of them ready in my head :)
@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.