mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-02 22:22:46 +00:00
Configuration tweaks (#2567)
This makes the following changes: * The various `Defaults` functions are now responsible for setting sane defaults if `generate` is specified, rather than hiding them in `generate-config` * Some configuration options have been marked as `omitempty` so that they don't appear in generated configs unnecessarily (monolith-specific vs. polylith-specific options) * A new option `-polylith` has been added to `generate-config` to create a config that makes sense for polylith deployments (i.e. including the internal/external API listeners and per-component database sections) * A new option `-normalise` has been added to `generate-config` to take an existing file and add any missing options and/or defaults
This commit is contained in:
parent
ad6b902b84
commit
51d229b025
23 changed files with 322 additions and 212 deletions
|
@ -211,7 +211,10 @@ func loadConfig(
|
|||
monolithic bool,
|
||||
) (*Dendrite, error) {
|
||||
var c Dendrite
|
||||
c.Defaults(false)
|
||||
c.Defaults(DefaultOpts{
|
||||
Generate: false,
|
||||
Monolithic: monolithic,
|
||||
})
|
||||
c.IsMonolith = monolithic
|
||||
|
||||
var err error
|
||||
|
@ -295,21 +298,25 @@ func (config *Dendrite) Derive() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
type DefaultOpts struct {
|
||||
Generate bool
|
||||
Monolithic bool
|
||||
}
|
||||
|
||||
// SetDefaults sets default config values if they are not explicitly set.
|
||||
func (c *Dendrite) Defaults(generate bool) {
|
||||
func (c *Dendrite) Defaults(opts DefaultOpts) {
|
||||
c.Version = Version
|
||||
|
||||
c.Global.Defaults(generate)
|
||||
c.ClientAPI.Defaults(generate)
|
||||
c.FederationAPI.Defaults(generate)
|
||||
c.KeyServer.Defaults(generate)
|
||||
c.MediaAPI.Defaults(generate)
|
||||
c.RoomServer.Defaults(generate)
|
||||
c.SyncAPI.Defaults(generate)
|
||||
c.UserAPI.Defaults(generate)
|
||||
c.AppServiceAPI.Defaults(generate)
|
||||
c.MSCs.Defaults(generate)
|
||||
|
||||
c.Global.Defaults(opts)
|
||||
c.ClientAPI.Defaults(opts)
|
||||
c.FederationAPI.Defaults(opts)
|
||||
c.KeyServer.Defaults(opts)
|
||||
c.MediaAPI.Defaults(opts)
|
||||
c.RoomServer.Defaults(opts)
|
||||
c.SyncAPI.Defaults(opts)
|
||||
c.UserAPI.Defaults(opts)
|
||||
c.AppServiceAPI.Defaults(opts)
|
||||
c.MSCs.Defaults(opts)
|
||||
c.Wiring()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue