chore: fix
ci-api / test (push) Successful in 26m33s

This commit is contained in:
Nuxgrid
2026-08-01 16:33:08 +02:00
parent 7374616e4a
commit 6e77f05f00
3 changed files with 16 additions and 1 deletions
+1
View File
@@ -128,6 +128,7 @@ func main() {
// Service de démos avec le provisioner Helm
demoSvc := demos.NewService(demoStore, demoPool, helmProv, demos.Config{
BaseDomain: cfg.DemoDomain,
HTTPSPort: cfg.DemoHTTPSPort,
TTL: demos.TTL,
MaxDemos: demos.MaxConcurrentDemos,
})
@@ -15,6 +15,7 @@ type Config struct {
DatabaseURL string // OMNEX_DATABASE_URL (DSN PostgreSQL GORM)
RedisURL string // OMNEX_REDIS_URL (sessions), ex. redis://:pass@host:6379/0
DemoDomain string // domaine des démos
DemoHTTPSPort string // port HTTPS public à afficher dans l'URL des démos (443 = omis, sinon ex. NodePort)
RegistrationCode string // OMNEX_REGISTRATION_CODE (vide = inscription ouverte)
Kubeconfig string
FrontendImage string
@@ -37,6 +38,7 @@ func Load() (Config, error) {
DatabaseURL: os.Getenv("OMNEX_DATABASE_URL"),
RedisURL: os.Getenv("OMNEX_REDIS_URL"),
DemoDomain: getenv("OMNEX_DEMO_DOMAIN", "demo.omnex.app"),
DemoHTTPSPort: getenv("OMNEX_DEMO_HTTPS_PORT", "443"),
RegistrationCode: os.Getenv("OMNEX_REGISTRATION_CODE"),
Kubeconfig: os.Getenv("KUBECONFIG"),
FrontendImage: os.Getenv("FRONTEND_IMAGE_APP"),
+13 -1
View File
@@ -19,6 +19,7 @@ var (
// Config du service (injectable pour les tests).
type Config struct {
BaseDomain string // ex. "demo.omnex.app"
HTTPSPort string // port public HTTPS pour l'URL affichée ("443" = omis, sinon ex. NodePort)
TTL time.Duration // durée de vie
MaxDemos int // capacité
}
@@ -42,6 +43,9 @@ func NewService(store Store, pool Pool, prov Provisioner, cfg Config) *Service {
if cfg.BaseDomain == "" {
cfg.BaseDomain = "demo.omnex.app"
}
if cfg.HTTPSPort == "" {
cfg.HTTPSPort = "443"
}
return &Service{store: store, pool: pool, prov: prov, cfg: cfg, now: time.Now}
}
@@ -66,7 +70,15 @@ func (s *Service) Create(leadID, username string) (Demo, error) {
CreatedAt: s.now().UTC(),
ExpiresAt: s.now().UTC().Add(s.cfg.TTL),
}
demo.URL = "https://" + demo.Namespace + "." + s.cfg.BaseDomain
// Port omis dans l'URL s'il s'agit du 443 standard ; sinon affiché
// explicitement (ex. NodePort HTTPS sans LoadBalancer). Ne concerne que
// l'URL affichée : le Host() de l'IngressRoute reste sans port (voir
// buildIngressRouteValues), le port n'y a pas sa place pour le matching.
portSuffix := ""
if s.cfg.HTTPSPort != "" && s.cfg.HTTPSPort != "443" {
portSuffix = ":" + s.cfg.HTTPSPort
}
demo.URL = "https://" + demo.Namespace + "." + s.cfg.BaseDomain + portSuffix
// Réserve les ressources externes ; ErrPoolExhausted => capacité atteinte.
resources, err := s.pool.Borrow(id)