2020-08-10 14:18:04 +01:00
|
|
|
package config
|
|
|
|
|
|
|
|
type KeyServer struct {
|
|
|
|
Matrix *Global `yaml:"-"`
|
|
|
|
|
2022-09-01 14:15:41 +01:00
|
|
|
InternalAPI InternalAPIOptions `yaml:"internal_api,omitempty"`
|
2020-08-10 14:18:04 +01:00
|
|
|
|
2022-09-01 14:15:41 +01:00
|
|
|
Database DatabaseOptions `yaml:"database,omitempty"`
|
2020-08-10 14:18:04 +01:00
|
|
|
}
|
|
|
|
|
2022-09-01 14:15:41 +01:00
|
|
|
func (c *KeyServer) Defaults(opts DefaultOpts) {
|
|
|
|
if !opts.Monolithic {
|
|
|
|
c.InternalAPI.Listen = "http://localhost:7779"
|
|
|
|
c.InternalAPI.Connect = "http://localhost:7779"
|
|
|
|
c.Database.Defaults(10)
|
|
|
|
}
|
|
|
|
if opts.Generate {
|
|
|
|
if !opts.Monolithic {
|
|
|
|
c.Database.ConnectionString = "file:keyserver.db"
|
|
|
|
}
|
2021-11-24 11:57:39 +00:00
|
|
|
}
|
2020-08-10 14:18:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *KeyServer) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
2022-05-13 08:33:55 +01:00
|
|
|
if isMonolith { // polylith required configs below
|
|
|
|
return
|
|
|
|
}
|
2022-09-01 14:15:41 +01:00
|
|
|
if c.Matrix.DatabaseOptions.ConnectionString == "" {
|
|
|
|
checkNotEmpty(configErrs, "key_server.database.connection_string", string(c.Database.ConnectionString))
|
|
|
|
}
|
2022-05-13 08:33:55 +01:00
|
|
|
checkURL(configErrs, "key_server.internal_api.listen", string(c.InternalAPI.Listen))
|
|
|
|
checkURL(configErrs, "key_server.internal_api.connect", string(c.InternalAPI.Connect))
|
2020-08-10 14:18:04 +01:00
|
|
|
}
|