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_open_conns: 10
|
||||||
max_idle_conns: 2
|
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:
|
log:
|
||||||
level: info
|
level: info
|
||||||
format: json
|
format: json
|
||||||
|
|||||||
@@ -12,6 +12,16 @@ database:
|
|||||||
max_open_conns: 10
|
max_open_conns: 10
|
||||||
max_idle_conns: 2
|
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:
|
log:
|
||||||
level: info
|
level: info
|
||||||
format: json
|
format: json
|
||||||
|
|||||||
@@ -12,13 +12,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Server sharedconfig.ServerConfig `mapstructure:"server"`
|
Server sharedconfig.ServerConfig `mapstructure:"server"`
|
||||||
Database sharedconfig.DatabaseConfig `mapstructure:"database"`
|
Database sharedconfig.DatabaseConfig `mapstructure:"database"`
|
||||||
Log sharedconfig.LogConfig `mapstructure:"log"`
|
MonitoringDatabase sharedconfig.DatabaseConfig `mapstructure:"monitoring_database"`
|
||||||
JWT JWTConfig `mapstructure:"jwt"`
|
Log sharedconfig.LogConfig `mapstructure:"log"`
|
||||||
DefaultAdmin DefaultAdminConfig `mapstructure:"default_admin"`
|
JWT JWTConfig `mapstructure:"jwt"`
|
||||||
AdminUsers AdminUsersConfig `mapstructure:"admin_users"`
|
DefaultAdmin DefaultAdminConfig `mapstructure:"default_admin"`
|
||||||
IPRegion IPRegionConfig `mapstructure:"ip_region"`
|
AdminUsers AdminUsersConfig `mapstructure:"admin_users"`
|
||||||
|
IPRegion IPRegionConfig `mapstructure:"ip_region"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type JWTConfig struct {
|
type JWTConfig struct {
|
||||||
@@ -77,6 +78,9 @@ func Load(path string) (*Config, error) {
|
|||||||
if cfg.JWT.Secret == "" {
|
if cfg.JWT.Secret == "" {
|
||||||
return nil, fmt.Errorf("jwt.secret is required (set jwt.secret in yaml or OPS_JWT_SECRET env)")
|
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
|
return &cfg, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ type Deps struct {
|
|||||||
Accounts *app.AccountService
|
Accounts *app.AccountService
|
||||||
AdminUsers *app.AdminUserService
|
AdminUsers *app.AdminUserService
|
||||||
Audits *app.AuditService
|
Audits *app.AuditService
|
||||||
|
SiteDomains *app.SiteDomainMappingService
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterRoutes(d Deps) {
|
func RegisterRoutes(d Deps) {
|
||||||
@@ -74,5 +75,11 @@ func RegisterRoutes(d Deps) {
|
|||||||
authed.POST("/admin-users/:id/password", resetAdminUserPasswordHandler(d.AdminUsers))
|
authed.POST("/admin-users/:id/password", resetAdminUserPasswordHandler(d.AdminUsers))
|
||||||
|
|
||||||
authed.GET("/audits", listAuditsHandler(d.Audits))
|
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