@@ -128,6 +128,7 @@ func main() {
|
|||||||
// Service de démos avec le provisioner Helm
|
// Service de démos avec le provisioner Helm
|
||||||
demoSvc := demos.NewService(demoStore, demoPool, helmProv, demos.Config{
|
demoSvc := demos.NewService(demoStore, demoPool, helmProv, demos.Config{
|
||||||
BaseDomain: cfg.DemoDomain,
|
BaseDomain: cfg.DemoDomain,
|
||||||
|
HTTPSPort: cfg.DemoHTTPSPort,
|
||||||
TTL: demos.TTL,
|
TTL: demos.TTL,
|
||||||
MaxDemos: demos.MaxConcurrentDemos,
|
MaxDemos: demos.MaxConcurrentDemos,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ type Config struct {
|
|||||||
DatabaseURL string // OMNEX_DATABASE_URL (DSN PostgreSQL GORM)
|
DatabaseURL string // OMNEX_DATABASE_URL (DSN PostgreSQL GORM)
|
||||||
RedisURL string // OMNEX_REDIS_URL (sessions), ex. redis://:pass@host:6379/0
|
RedisURL string // OMNEX_REDIS_URL (sessions), ex. redis://:pass@host:6379/0
|
||||||
DemoDomain string // domaine des démos
|
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)
|
RegistrationCode string // OMNEX_REGISTRATION_CODE (vide = inscription ouverte)
|
||||||
Kubeconfig string
|
Kubeconfig string
|
||||||
FrontendImage string
|
FrontendImage string
|
||||||
@@ -37,6 +38,7 @@ func Load() (Config, error) {
|
|||||||
DatabaseURL: os.Getenv("OMNEX_DATABASE_URL"),
|
DatabaseURL: os.Getenv("OMNEX_DATABASE_URL"),
|
||||||
RedisURL: os.Getenv("OMNEX_REDIS_URL"),
|
RedisURL: os.Getenv("OMNEX_REDIS_URL"),
|
||||||
DemoDomain: getenv("OMNEX_DEMO_DOMAIN", "demo.omnex.app"),
|
DemoDomain: getenv("OMNEX_DEMO_DOMAIN", "demo.omnex.app"),
|
||||||
|
DemoHTTPSPort: getenv("OMNEX_DEMO_HTTPS_PORT", "443"),
|
||||||
RegistrationCode: os.Getenv("OMNEX_REGISTRATION_CODE"),
|
RegistrationCode: os.Getenv("OMNEX_REGISTRATION_CODE"),
|
||||||
Kubeconfig: os.Getenv("KUBECONFIG"),
|
Kubeconfig: os.Getenv("KUBECONFIG"),
|
||||||
FrontendImage: os.Getenv("FRONTEND_IMAGE_APP"),
|
FrontendImage: os.Getenv("FRONTEND_IMAGE_APP"),
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ var (
|
|||||||
// Config du service (injectable pour les tests).
|
// Config du service (injectable pour les tests).
|
||||||
type Config struct {
|
type Config struct {
|
||||||
BaseDomain string // ex. "demo.omnex.app"
|
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
|
TTL time.Duration // durée de vie
|
||||||
MaxDemos int // capacité
|
MaxDemos int // capacité
|
||||||
}
|
}
|
||||||
@@ -42,6 +43,9 @@ func NewService(store Store, pool Pool, prov Provisioner, cfg Config) *Service {
|
|||||||
if cfg.BaseDomain == "" {
|
if cfg.BaseDomain == "" {
|
||||||
cfg.BaseDomain = "demo.omnex.app"
|
cfg.BaseDomain = "demo.omnex.app"
|
||||||
}
|
}
|
||||||
|
if cfg.HTTPSPort == "" {
|
||||||
|
cfg.HTTPSPort = "443"
|
||||||
|
}
|
||||||
return &Service{store: store, pool: pool, prov: prov, cfg: cfg, now: time.Now}
|
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(),
|
CreatedAt: s.now().UTC(),
|
||||||
ExpiresAt: s.now().UTC().Add(s.cfg.TTL),
|
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.
|
// Réserve les ressources externes ; ErrPoolExhausted => capacité atteinte.
|
||||||
resources, err := s.pool.Borrow(id)
|
resources, err := s.pool.Borrow(id)
|
||||||
|
|||||||
Reference in New Issue
Block a user