aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2022-05-13 09:33:55 +0200
committerGitHub <noreply@github.com>2022-05-13 09:33:55 +0200
commit870f9b0c3f288950ab843b048485a0767e177bd1 (patch)
tree499872e8d3b44f493f7d3e8a13e56e5a5422adfa
parentfc670f03a2ac13adc7e022bcb21b82ad874d6706 (diff)
Shuffle config Verify/Defaults a bit around (#2459)
-rw-r--r--setup/config/config_appservice.go7
-rw-r--r--setup/config/config_clientapi.go22
-rw-r--r--setup/config/config_federationapi.go16
-rw-r--r--setup/config/config_jetstream.go7
-rw-r--r--setup/config/config_keyserver.go7
-rw-r--r--setup/config/config_mediaapi.go17
-rw-r--r--setup/config/config_roomserver.go7
-rw-r--r--setup/config/config_syncapi.go11
-rw-r--r--setup/config/config_userapi.go13
9 files changed, 60 insertions, 47 deletions
diff --git a/setup/config/config_appservice.go b/setup/config/config_appservice.go
index d93b6ebe..ff328771 100644
--- a/setup/config/config_appservice.go
+++ b/setup/config/config_appservice.go
@@ -50,11 +50,14 @@ func (c *AppServiceAPI) Defaults(generate bool) {
}
func (c *AppServiceAPI) Verify(configErrs *ConfigErrors, isMonolith bool) {
- checkURL(configErrs, "app_service_api.internal_api.listen", string(c.InternalAPI.Listen))
- checkURL(configErrs, "app_service_api.internal_api.bind", string(c.InternalAPI.Connect))
if c.Matrix.DatabaseOptions.ConnectionString == "" {
checkNotEmpty(configErrs, "app_service_api.database.connection_string", string(c.Database.ConnectionString))
}
+ if isMonolith { // polylith required configs below
+ return
+ }
+ checkURL(configErrs, "app_service_api.internal_api.listen", string(c.InternalAPI.Listen))
+ checkURL(configErrs, "app_service_api.internal_api.connect", string(c.InternalAPI.Connect))
}
// ApplicationServiceNamespace is the namespace that a specific application
diff --git a/setup/config/config_clientapi.go b/setup/config/config_clientapi.go
index 6104ed8b..bb786a14 100644
--- a/setup/config/config_clientapi.go
+++ b/setup/config/config_clientapi.go
@@ -67,19 +67,13 @@ func (c *ClientAPI) Defaults(generate bool) {
}
func (c *ClientAPI) Verify(configErrs *ConfigErrors, isMonolith bool) {
- checkURL(configErrs, "client_api.internal_api.listen", string(c.InternalAPI.Listen))
- checkURL(configErrs, "client_api.internal_api.connect", string(c.InternalAPI.Connect))
- if !isMonolith {
- checkURL(configErrs, "client_api.external_api.listen", string(c.ExternalAPI.Listen))
- }
- if c.RecaptchaEnabled {
- checkNotEmpty(configErrs, "client_api.recaptcha_public_key", string(c.RecaptchaPublicKey))
- checkNotEmpty(configErrs, "client_api.recaptcha_private_key", string(c.RecaptchaPrivateKey))
- checkNotEmpty(configErrs, "client_api.recaptcha_siteverify_api", string(c.RecaptchaSiteVerifyAPI))
- }
c.TURN.Verify(configErrs)
c.RateLimiting.Verify(configErrs)
-
+ if c.RecaptchaEnabled {
+ checkNotEmpty(configErrs, "client_api.recaptcha_public_key", c.RecaptchaPublicKey)
+ checkNotEmpty(configErrs, "client_api.recaptcha_private_key", c.RecaptchaPrivateKey)
+ checkNotEmpty(configErrs, "client_api.recaptcha_siteverify_api", c.RecaptchaSiteVerifyAPI)
+ }
// Ensure there is any spam counter measure when enabling registration
if !c.RegistrationDisabled && !c.OpenRegistrationWithoutVerificationEnabled {
if !c.RecaptchaEnabled {
@@ -93,6 +87,12 @@ func (c *ClientAPI) Verify(configErrs *ConfigErrors, isMonolith bool) {
)
}
}
+ if isMonolith { // polylith required configs below
+ return
+ }
+ checkURL(configErrs, "client_api.internal_api.listen", string(c.InternalAPI.Listen))
+ checkURL(configErrs, "client_api.internal_api.connect", string(c.InternalAPI.Connect))
+ checkURL(configErrs, "client_api.external_api.listen", string(c.ExternalAPI.Listen))
}
type TURN struct {
diff --git a/setup/config/config_federationapi.go b/setup/config/config_federationapi.go
index f62a23e1..a7a515fd 100644
--- a/setup/config/config_federationapi.go
+++ b/setup/config/config_federationapi.go
@@ -34,24 +34,24 @@ func (c *FederationAPI) Defaults(generate bool) {
c.InternalAPI.Listen = "http://localhost:7772"
c.InternalAPI.Connect = "http://localhost:7772"
c.ExternalAPI.Listen = "http://[::]:8072"
+ c.FederationMaxRetries = 16
+ c.DisableTLSValidation = false
c.Database.Defaults(10)
if generate {
c.Database.ConnectionString = "file:federationapi.db"
}
-
- c.FederationMaxRetries = 16
- c.DisableTLSValidation = false
}
func (c *FederationAPI) Verify(configErrs *ConfigErrors, isMonolith bool) {
- checkURL(configErrs, "federation_api.internal_api.listen", string(c.InternalAPI.Listen))
- checkURL(configErrs, "federation_api.internal_api.connect", string(c.InternalAPI.Connect))
- if !isMonolith {
- checkURL(configErrs, "federation_api.external_api.listen", string(c.ExternalAPI.Listen))
- }
if c.Matrix.DatabaseOptions.ConnectionString == "" {
checkNotEmpty(configErrs, "federation_api.database.connection_string", string(c.Database.ConnectionString))
}
+ if isMonolith { // polylith required configs below
+ return
+ }
+ checkURL(configErrs, "federation_api.external_api.listen", string(c.ExternalAPI.Listen))
+ checkURL(configErrs, "federation_api.internal_api.listen", string(c.InternalAPI.Listen))
+ checkURL(configErrs, "federation_api.internal_api.connect", string(c.InternalAPI.Connect))
}
// The config for setting a proxy to use for server->server requests
diff --git a/setup/config/config_jetstream.go b/setup/config/config_jetstream.go
index b6a93d39..e4cfd4d3 100644
--- a/setup/config/config_jetstream.go
+++ b/setup/config/config_jetstream.go
@@ -36,9 +36,10 @@ func (c *JetStream) Defaults(generate bool) {
}
func (c *JetStream) Verify(configErrs *ConfigErrors, isMonolith bool) {
+ if isMonolith { // polylith required configs below
+ return
+ }
// If we are running in a polylith deployment then we need at least
// one NATS JetStream server to talk to.
- if !isMonolith {
- checkNotZero(configErrs, "global.jetstream.addresses", int64(len(c.Addresses)))
- }
+ checkNotZero(configErrs, "global.jetstream.addresses", int64(len(c.Addresses)))
}
diff --git a/setup/config/config_keyserver.go b/setup/config/config_keyserver.go
index 9e2d54cd..5f2f22c8 100644
--- a/setup/config/config_keyserver.go
+++ b/setup/config/config_keyserver.go
@@ -18,9 +18,12 @@ func (c *KeyServer) Defaults(generate bool) {
}
func (c *KeyServer) Verify(configErrs *ConfigErrors, isMonolith bool) {
- checkURL(configErrs, "key_server.internal_api.listen", string(c.InternalAPI.Listen))
- checkURL(configErrs, "key_server.internal_api.bind", string(c.InternalAPI.Connect))
if c.Matrix.DatabaseOptions.ConnectionString == "" {
checkNotEmpty(configErrs, "key_server.database.connection_string", string(c.Database.ConnectionString))
}
+ if isMonolith { // polylith required configs below
+ return
+ }
+ checkURL(configErrs, "key_server.internal_api.listen", string(c.InternalAPI.Listen))
+ checkURL(configErrs, "key_server.internal_api.connect", string(c.InternalAPI.Connect))
}
diff --git a/setup/config/config_mediaapi.go b/setup/config/config_mediaapi.go
index 273de322..9717aa59 100644
--- a/setup/config/config_mediaapi.go
+++ b/setup/config/config_mediaapi.go
@@ -42,26 +42,19 @@ func (c *MediaAPI) Defaults(generate bool) {
c.InternalAPI.Listen = "http://localhost:7774"
c.InternalAPI.Connect = "http://localhost:7774"
c.ExternalAPI.Listen = "http://[::]:8074"
+ c.MaxFileSizeBytes = DefaultMaxFileSizeBytes
+ c.MaxThumbnailGenerators = 10
c.Database.Defaults(5)
if generate {
c.Database.ConnectionString = "file:mediaapi.db"
c.BasePath = "./media_store"
}
-
- c.MaxFileSizeBytes = DefaultMaxFileSizeBytes
- c.MaxThumbnailGenerators = 10
}
func (c *MediaAPI) Verify(configErrs *ConfigErrors, isMonolith bool) {
- checkURL(configErrs, "media_api.internal_api.listen", string(c.InternalAPI.Listen))
- checkURL(configErrs, "media_api.internal_api.connect", string(c.InternalAPI.Connect))
- if !isMonolith {
- checkURL(configErrs, "media_api.external_api.listen", string(c.ExternalAPI.Listen))
- }
if c.Matrix.DatabaseOptions.ConnectionString == "" {
checkNotEmpty(configErrs, "media_api.database.connection_string", string(c.Database.ConnectionString))
}
-
checkNotEmpty(configErrs, "media_api.base_path", string(c.BasePath))
checkPositive(configErrs, "media_api.max_file_size_bytes", int64(c.MaxFileSizeBytes))
checkPositive(configErrs, "media_api.max_thumbnail_generators", int64(c.MaxThumbnailGenerators))
@@ -70,4 +63,10 @@ func (c *MediaAPI) Verify(configErrs *ConfigErrors, isMonolith bool) {
checkPositive(configErrs, fmt.Sprintf("media_api.thumbnail_sizes[%d].width", i), int64(size.Width))
checkPositive(configErrs, fmt.Sprintf("media_api.thumbnail_sizes[%d].height", i), int64(size.Height))
}
+ if isMonolith { // polylith required configs below
+ return
+ }
+ checkURL(configErrs, "media_api.internal_api.listen", string(c.InternalAPI.Listen))
+ checkURL(configErrs, "media_api.internal_api.connect", string(c.InternalAPI.Connect))
+ checkURL(configErrs, "media_api.external_api.listen", string(c.ExternalAPI.Listen))
}
diff --git a/setup/config/config_roomserver.go b/setup/config/config_roomserver.go
index 8a322734..bd6aa116 100644
--- a/setup/config/config_roomserver.go
+++ b/setup/config/config_roomserver.go
@@ -18,9 +18,12 @@ func (c *RoomServer) Defaults(generate bool) {
}
func (c *RoomServer) Verify(configErrs *ConfigErrors, isMonolith bool) {
- checkURL(configErrs, "room_server.internal_api.listen", string(c.InternalAPI.Listen))
- checkURL(configErrs, "room_server.internal_ap.bind", string(c.InternalAPI.Connect))
if c.Matrix.DatabaseOptions.ConnectionString == "" {
checkNotEmpty(configErrs, "room_server.database.connection_string", string(c.Database.ConnectionString))
}
+ if isMonolith { // polylith required configs below
+ return
+ }
+ checkURL(configErrs, "room_server.internal_api.listen", string(c.InternalAPI.Listen))
+ checkURL(configErrs, "room_server.internal_ap.connect", string(c.InternalAPI.Connect))
}
diff --git a/setup/config/config_syncapi.go b/setup/config/config_syncapi.go
index 48fd9f50..7d5e3808 100644
--- a/setup/config/config_syncapi.go
+++ b/setup/config/config_syncapi.go
@@ -22,12 +22,13 @@ func (c *SyncAPI) Defaults(generate bool) {
}
func (c *SyncAPI) Verify(configErrs *ConfigErrors, isMonolith bool) {
- checkURL(configErrs, "sync_api.internal_api.listen", string(c.InternalAPI.Listen))
- checkURL(configErrs, "sync_api.internal_api.bind", string(c.InternalAPI.Connect))
- if !isMonolith {
- checkURL(configErrs, "sync_api.external_api.listen", string(c.ExternalAPI.Listen))
- }
if c.Matrix.DatabaseOptions.ConnectionString == "" {
checkNotEmpty(configErrs, "sync_api.database", string(c.Database.ConnectionString))
}
+ if isMonolith { // polylith required configs below
+ return
+ }
+ 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))
}
diff --git a/setup/config/config_userapi.go b/setup/config/config_userapi.go
index 4aa3b57b..d1e2b7fe 100644
--- a/setup/config/config_userapi.go
+++ b/setup/config/config_userapi.go
@@ -26,19 +26,22 @@ const DefaultOpenIDTokenLifetimeMS = 3600000 // 60 minutes
func (c *UserAPI) Defaults(generate bool) {
c.InternalAPI.Listen = "http://localhost:7781"
c.InternalAPI.Connect = "http://localhost:7781"
+ c.BCryptCost = bcrypt.DefaultCost
+ c.OpenIDTokenLifetimeMS = DefaultOpenIDTokenLifetimeMS
c.AccountDatabase.Defaults(10)
if generate {
c.AccountDatabase.ConnectionString = "file:userapi_accounts.db"
}
- c.BCryptCost = bcrypt.DefaultCost
- c.OpenIDTokenLifetimeMS = DefaultOpenIDTokenLifetimeMS
}
func (c *UserAPI) Verify(configErrs *ConfigErrors, isMonolith bool) {
- checkURL(configErrs, "user_api.internal_api.listen", string(c.InternalAPI.Listen))
- checkURL(configErrs, "user_api.internal_api.connect", string(c.InternalAPI.Connect))
+ checkPositive(configErrs, "user_api.openid_token_lifetime_ms", c.OpenIDTokenLifetimeMS)
if c.Matrix.DatabaseOptions.ConnectionString == "" {
checkNotEmpty(configErrs, "user_api.account_database.connection_string", string(c.AccountDatabase.ConnectionString))
}
- checkPositive(configErrs, "user_api.openid_token_lifetime_ms", c.OpenIDTokenLifetimeMS)
+ if isMonolith { // polylith required configs below
+ return
+ }
+ checkURL(configErrs, "user_api.internal_api.listen", string(c.InternalAPI.Listen))
+ checkURL(configErrs, "user_api.internal_api.connect", string(c.InternalAPI.Connect))
}