chore: update
ci-api / test (push) Successful in 22m17s
ci-web / test (push) Successful in 13m44s

This commit is contained in:
Xor290
2026-08-02 18:34:59 +02:00
parent 6992e505ae
commit c5ee5636ef
34 changed files with 2660 additions and 498 deletions
+30
View File
@@ -10,6 +10,7 @@ import (
"github.com/google/uuid"
"github.com/redis/go-redis/v9"
"github.com/omnex/control-plane/api/internal/alerts"
"github.com/omnex/control-plane/api/internal/auth"
"github.com/omnex/control-plane/api/internal/config"
"github.com/omnex/control-plane/api/internal/db"
@@ -67,6 +68,10 @@ func main() {
var demoPool demos.Pool
var codeStore sub.Store
var profileStore profile.Store
// Résout les destinataires d'alerte pods depuis les réglages de chaque
// admin (table users) — nil si pas de base (mode mémoire, dev), auquel
// cas le monitoring reste désactivé (rien à interroger).
var alertRecipients func(ctx context.Context) ([]alerts.Notifier, error)
if cfg.DatabaseURL != "" {
gdb, err := db.Open(cfg.DatabaseURL)
if err != nil {
@@ -85,6 +90,7 @@ func main() {
demoStore = demos.NewGormStore(gdb)
demoPool = demos.NewGormPool(gdb)
profileStore = profile.NewGormStore(gdb)
alertRecipients = alerts.GormRecipients(gdb)
log.Printf("persistance: PostgreSQL (GORM)")
} else {
userStore = seedMemUsers()
@@ -141,6 +147,30 @@ func main() {
TTL: demos.TTL,
})
// Alerting : surveille les pods des démos actives, notifie Discord et/ou
// Telegram de chaque admin ayant configuré son propre canal (voir profil
// admin, /profile/alerts). Désactivé en mode mémoire (pas de réglages
// persistés à interroger).
if alertRecipients != nil {
watcher := alerts.NewWatcher(k8sClient, alertRecipients, func() ([]string, error) {
all, err := demoSvc.List()
if err != nil {
return nil, err
}
ns := make([]string, 0, len(all))
for _, d := range all {
if d.Status.Active() {
ns = append(ns, d.Namespace)
}
}
return ns, nil
})
go watcher.Run(context.Background())
log.Printf("alerts: monitoring des pods actif (réglages par admin, voir /profile/alerts)")
} else {
log.Printf("alerts: monitoring désactivé (nécessite OMNEX_DATABASE_URL — réglages persistés par admin)")
}
deps := router.Deps{
Cfg: cfg,
Issuer: iss,