refactor(models): split Site into SiteConfig + SiteState
Site now embeds SiteConfig (22 persistent fields) and SiteState (11 ephemeral runtime fields). Field access unchanged via promotion — site.Name and site.Status still work. Store layer deals exclusively in SiteConfig — the DB never sees runtime state. Engine's liveState keeps full Site composites. UpdateSiteConfig reduced from 11-line field-by-field copy to `existing.SiteConfig = cfg`. RunCheck takes SiteConfig (only needs config fields). Checker is now statically prevented from reading/writing runtime state. Backup.Sites changed to []SiteConfig — exports no longer carry zero-valued runtime fields. Import backward-compatible (json ignores unknown fields).
This commit was merged in pull request #109.
This commit is contained in:
@@ -3,9 +3,10 @@ package importer
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"gitea.lerkolabs.com/lerkolabs/uptop/internal/models"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"gitea.lerkolabs.com/lerkolabs/uptop/internal/models"
|
||||
)
|
||||
|
||||
type KumaBackup struct {
|
||||
@@ -80,7 +81,7 @@ func ConvertKuma(kb *KumaBackup) models.Backup {
|
||||
}
|
||||
}
|
||||
|
||||
var sites []models.Site
|
||||
var sites []models.SiteConfig
|
||||
for _, m := range kb.MonitorList {
|
||||
site := convertKumaMonitor(m, kumaToUpkeepAlert)
|
||||
sites = append(sites, site)
|
||||
@@ -132,8 +133,8 @@ func convertKumaNotifications(entries []KumaNotifEntry) map[int]models.AlertConf
|
||||
return result
|
||||
}
|
||||
|
||||
func convertKumaMonitor(m KumaMonitor, alertMap map[int]int) models.Site {
|
||||
site := models.Site{
|
||||
func convertKumaMonitor(m KumaMonitor, alertMap map[int]int) models.SiteConfig {
|
||||
site := models.SiteConfig{
|
||||
ID: m.ID,
|
||||
Name: m.Name,
|
||||
Description: m.Description,
|
||||
|
||||
Reference in New Issue
Block a user