// Package infra gère l'infrastructure (serveurs, containers, nginx). package infra import "time" // ServerStatus représente l'état d'un serveur. type ServerStatus string const ( ServerStatusOnline ServerStatus = "online" ServerStatusOffline ServerStatus = "offline" ServerStatusUnknown ServerStatus = "unknown" ) // ContainerStatus représente l'état d'un container. type ContainerStatus string const ( ContainerStatusRunning ContainerStatus = "running" ContainerStatusStopped ContainerStatus = "stopped" ContainerStatusUnknown ContainerStatus = "unknown" ) // NginxConfigStatus représente l'état d'une config Nginx. type NginxConfigStatus string const ( NginxConfigStatusActive NginxConfigStatus = "active" NginxConfigStatusInactive NginxConfigStatus = "inactive" NginxConfigStatusError NginxConfigStatus = "error" ) // NginxConfigType représente le type de config Nginx. type NginxConfigType string const ( NginxTypeProxy NginxConfigType = "proxy" NginxTypeStatic NginxConfigType = "static" NginxTypeSocket NginxConfigType = "socket" ) // BindingType représente le type de binding app. type BindingType string const ( BindingTypeContainer BindingType = "container" BindingTypeNginx BindingType = "nginx" BindingTypeServer BindingType = "server" ) // Server représente un serveur physique ou VM. type Server struct { ID int64 `json:"id"` Name string `json:"name"` Host string `json:"host"` VpnIP string `json:"vpn_ip,omitempty"` SSHPort int `json:"ssh_port"` SSHUser string `json:"ssh_user"` SSHKeyFile string `json:"ssh_key_file"` HasIncus bool `json:"has_incus"` HasNginx bool `json:"has_nginx"` Status ServerStatus `json:"status"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` } // Container représente un container Incus. type Container struct { ID int64 `json:"id"` ServerID int64 `json:"server_id"` Name string `json:"name"` IncusName string `json:"incus_name"` IP string `json:"ip"` VpnIP string `json:"vpn_ip,omitempty"` Image string `json:"image"` Status ContainerStatus `json:"status"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` // Relation (populé par query) Server *Server `json:"server,omitempty"` } // NginxConfig représente une configuration Nginx. type NginxConfig struct { ID int64 `json:"id"` ServerID int64 `json:"server_id"` Domain string `json:"domain"` Type NginxConfigType `json:"type"` Template string `json:"template,omitempty"` Upstream string `json:"upstream,omitempty"` SSLEnabled bool `json:"ssl_enabled"` ConfigContent string `json:"config_content,omitempty"` Status NginxConfigStatus `json:"status"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` // Relation (populé par query) Server *Server `json:"server,omitempty"` } // AppBinding représente le lien entre une app SOGOMS et l'infrastructure. type AppBinding struct { ID int64 `json:"id"` AppID string `json:"app_id"` ContainerID *int64 `json:"container_id,omitempty"` NginxConfigID *int64 `json:"nginx_config_id,omitempty"` ServerID *int64 `json:"server_id,omitempty"` Type BindingType `json:"type"` CreatedAt time.Time `json:"created_at"` // Relations (populées par query) Container *Container `json:"container,omitempty"` NginxConfig *NginxConfig `json:"nginx_config,omitempty"` Server *Server `json:"server,omitempty"` } // ServerWithContainers représente un serveur avec ses containers. type ServerWithContainers struct { Server Containers []Container `json:"containers"` } // InfraOverview représente une vue globale de l'infrastructure. type InfraOverview struct { Servers []ServerWithContainers `json:"servers"` NginxConfigs []NginxConfig `json:"nginx_configs"` AppBindings []AppBinding `json:"app_bindings"` }