@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user