Files
ops-assistant/internal/core/ops/bootstrap.go
T

36 lines
1004 B
Go

package ops
import (
"path/filepath"
"ops-assistant/internal/core/registry"
"ops-assistant/internal/core/runbook"
"ops-assistant/internal/module/cf"
"ops-assistant/internal/module/cfdav"
"ops-assistant/internal/module/cpa"
"ops-assistant/internal/module/mail"
"ops-assistant/internal/module/rate"
"ops-assistant/internal/module/sub"
"gorm.io/gorm"
)
func BuildDefault(db *gorm.DB, dbPath, baseDir string) *Service {
r := registry.New()
exec := runbook.NewExecutor(db, filepath.Join(baseDir, "runbooks"))
cpaModule := cpa.New(db, exec)
cfModule := cf.New(db, exec)
mailModule := mail.New(db, exec)
rateModule := rate.New()
cfdavModule := cfdav.New(db)
subModule := sub.New(db)
r.RegisterModule("cpa", cpaModule.Handle)
r.RegisterModule("cf", cfModule.Handle)
r.RegisterModule("mail", mailModule.Handle)
r.RegisterModule("rate", rateModule.Handle)
r.RegisterModule("cfdav", cfdavModule.Handle)
r.RegisterModule("sub", subModule.Handle)
return NewService(dbPath, baseDir, r)
}