feat(ops/site-mappings): wire site domain mapping routes and monitoring DB
Register site-domain-mappings CRUD endpoints under the authenticated ops router, add a monitoring_database config block (falling back to the main ops database when unset) for the service to share the monitoring pool.
This commit is contained in:
@@ -12,6 +12,16 @@ database:
|
||||
max_open_conns: 10
|
||||
max_idle_conns: 2
|
||||
|
||||
monitoring_database:
|
||||
host: postgres
|
||||
port: 5432
|
||||
user: geo
|
||||
password: geo_dev
|
||||
dbname: geo_monitoring
|
||||
sslmode: disable
|
||||
max_open_conns: 10
|
||||
max_idle_conns: 2
|
||||
|
||||
log:
|
||||
level: info
|
||||
format: json
|
||||
|
||||
@@ -12,6 +12,16 @@ database:
|
||||
max_open_conns: 10
|
||||
max_idle_conns: 2
|
||||
|
||||
monitoring_database:
|
||||
host: localhost
|
||||
port: 5432
|
||||
user: geo
|
||||
password: geo_dev
|
||||
dbname: geo_monitoring
|
||||
sslmode: disable
|
||||
max_open_conns: 10
|
||||
max_idle_conns: 2
|
||||
|
||||
log:
|
||||
level: info
|
||||
format: json
|
||||
|
||||
@@ -12,13 +12,14 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Server sharedconfig.ServerConfig `mapstructure:"server"`
|
||||
Database sharedconfig.DatabaseConfig `mapstructure:"database"`
|
||||
Log sharedconfig.LogConfig `mapstructure:"log"`
|
||||
JWT JWTConfig `mapstructure:"jwt"`
|
||||
DefaultAdmin DefaultAdminConfig `mapstructure:"default_admin"`
|
||||
AdminUsers AdminUsersConfig `mapstructure:"admin_users"`
|
||||
IPRegion IPRegionConfig `mapstructure:"ip_region"`
|
||||
Server sharedconfig.ServerConfig `mapstructure:"server"`
|
||||
Database sharedconfig.DatabaseConfig `mapstructure:"database"`
|
||||
MonitoringDatabase sharedconfig.DatabaseConfig `mapstructure:"monitoring_database"`
|
||||
Log sharedconfig.LogConfig `mapstructure:"log"`
|
||||
JWT JWTConfig `mapstructure:"jwt"`
|
||||
DefaultAdmin DefaultAdminConfig `mapstructure:"default_admin"`
|
||||
AdminUsers AdminUsersConfig `mapstructure:"admin_users"`
|
||||
IPRegion IPRegionConfig `mapstructure:"ip_region"`
|
||||
}
|
||||
|
||||
type JWTConfig struct {
|
||||
@@ -77,6 +78,9 @@ func Load(path string) (*Config, error) {
|
||||
if cfg.JWT.Secret == "" {
|
||||
return nil, fmt.Errorf("jwt.secret is required (set jwt.secret in yaml or OPS_JWT_SECRET env)")
|
||||
}
|
||||
if cfg.MonitoringDatabase.DBName == "" {
|
||||
cfg.MonitoringDatabase = cfg.Database
|
||||
}
|
||||
|
||||
return &cfg, nil
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ type Deps struct {
|
||||
Accounts *app.AccountService
|
||||
AdminUsers *app.AdminUserService
|
||||
Audits *app.AuditService
|
||||
SiteDomains *app.SiteDomainMappingService
|
||||
}
|
||||
|
||||
func RegisterRoutes(d Deps) {
|
||||
@@ -74,5 +75,11 @@ func RegisterRoutes(d Deps) {
|
||||
authed.POST("/admin-users/:id/password", resetAdminUserPasswordHandler(d.AdminUsers))
|
||||
|
||||
authed.GET("/audits", listAuditsHandler(d.Audits))
|
||||
|
||||
authed.GET("/site-domain-mappings", listSiteDomainMappingsHandler(d.SiteDomains))
|
||||
authed.POST("/site-domain-mappings", createSiteDomainMappingHandler(d.SiteDomains))
|
||||
authed.PATCH("/site-domain-mappings/:id", updateSiteDomainMappingHandler(d.SiteDomains))
|
||||
authed.POST("/site-domain-mappings/:id/active", setSiteDomainMappingActiveHandler(d.SiteDomains))
|
||||
authed.DELETE("/site-domain-mappings/:id", deleteSiteDomainMappingHandler(d.SiteDomains))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user