mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-22 19:51:39 +00:00
51d229b025
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
39 lines
1.2 KiB
Go
39 lines
1.2 KiB
Go
package config
|
|
|
|
type SyncAPI struct {
|
|
Matrix *Global `yaml:"-"`
|
|
|
|
InternalAPI InternalAPIOptions `yaml:"internal_api,omitempty"`
|
|
ExternalAPI ExternalAPIOptions `yaml:"external_api,omitempty"`
|
|
|
|
Database DatabaseOptions `yaml:"database,omitempty"`
|
|
|
|
RealIPHeader string `yaml:"real_ip_header"`
|
|
}
|
|
|
|
func (c *SyncAPI) Defaults(opts DefaultOpts) {
|
|
if !opts.Monolithic {
|
|
c.InternalAPI.Listen = "http://localhost:7773"
|
|
c.InternalAPI.Connect = "http://localhost:7773"
|
|
c.ExternalAPI.Listen = "http://localhost:8073"
|
|
c.Database.Defaults(20)
|
|
}
|
|
if opts.Generate {
|
|
if !opts.Monolithic {
|
|
c.Database.ConnectionString = "file:syncapi.db"
|
|
}
|
|
}
|
|
}
|
|
|
|
func (c *SyncAPI) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
|
if isMonolith { // polylith required configs below
|
|
return
|
|
}
|
|
if c.Matrix.DatabaseOptions.ConnectionString == "" {
|
|
checkNotEmpty(configErrs, "sync_api.database", string(c.Database.ConnectionString))
|
|
}
|
|
checkURL(configErrs, "sync_api.internal_api.listen", string(c.InternalAPI.Listen))
|
|
checkURL(configErrs, "sync_api.internal_api.connect", string(c.InternalAPI.Connect))
|
|
checkURL(configErrs, "sync_api.external_api.listen", string(c.ExternalAPI.Listen))
|
|
}
|