48 lines
2.2 KiB
Go
48 lines
2.2 KiB
Go
package demos
|
|
|
|
import "time"
|
|
|
|
type Demo struct {
|
|
ID string `gorm:"type:uuid;primaryKey" json:"id"`
|
|
Username string `gorm:"type:varchar(64);index" json:"username,omitempty"`
|
|
LeadID string `gorm:"type:varchar(36);index" json:"lead_id,omitempty"`
|
|
Status Status `gorm:"size:20;not null;index" json:"status"`
|
|
Namespace string `gorm:"size:63;uniqueIndex" json:"namespace"`
|
|
URL string `gorm:"size:255" json:"url"`
|
|
TypeAbo string `gorm:"type:varchar(35)" json:"type_abonnement"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
ExpiresAt time.Time `json:"expires_at"`
|
|
}
|
|
|
|
func (Demo) TableName() string { return "demos" }
|
|
|
|
type ExternalResource struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
Service string `gorm:"size:20;not null;index:idx_service_status" json:"service"`
|
|
Label string `gorm:"size:120" json:"label"` // ex. "@omnex_demo_bot_1"
|
|
SecretRef string `gorm:"size:200;not null" json:"-"` // clé dans le secret manager
|
|
Status ResourceStatus `gorm:"size:20;not null;index:idx_service_status" json:"status"`
|
|
DemoID string `gorm:"type:varchar(36);index" json:"demo_id,omitempty"` // FK optionnelle (vide si libre)
|
|
}
|
|
|
|
func (ExternalResource) TableName() string { return "external_pool" }
|
|
|
|
// ComponentState : état live d'un composant (pod) d'une démo — phase k8s +
|
|
// usage CPU/mémoire actuel rapporté par metrics-server, avec les limites
|
|
// configurées dans le chart Helm correspondant (pour calculer un pourcentage).
|
|
type ComponentState struct {
|
|
Phase string `json:"phase"` // Running, Pending, Failed, Unknown, "" si pod introuvable
|
|
CPUMilli int64 `json:"cpu_milli"` // usage CPU actuel, en millicores
|
|
CPULimitMilli int64 `json:"cpu_limit_milli"` // limite CPU configurée, en millicores
|
|
MemoryMi int64 `json:"memory_mi"` // usage mémoire actuel, en Mi
|
|
MemoryLimitMi int64 `json:"memory_limit_mi"` // limite mémoire configurée, en Mi
|
|
}
|
|
|
|
// ResourceState : état live des 4 composants d'une démo.
|
|
type ResourceState struct {
|
|
API ComponentState `json:"api"`
|
|
Web ComponentState `json:"web"`
|
|
DB ComponentState `json:"db"`
|
|
DBM ComponentState `json:"dbm"`
|
|
}
|