chore: build
ci-web / test (push) Canceled after 0s
ci-api / test (push) Successful in 23m8s

This commit is contained in:
Xor290
2026-10-04 17:39:39 +02:00
parent 4bb8c143e2
commit 89bf45f738
21 changed files with 2974 additions and 1537 deletions
@@ -12,6 +12,7 @@ import (
"github.com/google/uuid"
"github.com/omnex/control-plane/api/internal/auth"
"github.com/omnex/control-plane/api/internal/demos"
)
@@ -65,6 +66,8 @@ type CreateInput struct {
AdminUsername string
AdminPassword string
AdminNumber int // 0 => DefaultAdminNumber
// OwnerUsername : compte client propriétaire (voir Request), facultatif.
OwnerUsername string
}
// Validate normalise et valide la saisie.
@@ -141,6 +144,7 @@ func (s *Service) Create(in CreateInput) (Project, error) {
URL: "https://" + host,
AdminUsername: in.AdminUsername,
AdminNumber: in.AdminNumber,
OwnerUsername: auth.NormalizeUsername(in.OwnerUsername),
MonthsPurchased: in.Months,
CreatedAt: now,
ExpiresAt: expires,
@@ -190,6 +194,22 @@ func (s *Service) Get(id string) (Project, error) {
func (s *Service) List() ([]Project, error) { return s.store.List() }
// ListForOwner : sites du client (hors supprimés), du plus récent au plus ancien.
func (s *Service) ListForOwner(username string) ([]Project, error) {
username = auth.NormalizeUsername(username)
all, err := s.store.List()
if err != nil {
return nil, err
}
out := []Project{}
for _, p := range all {
if p.OwnerUsername == username && p.Status != StatusDeleted {
out = append(out, p)
}
}
return out, nil
}
// State : état live des composants du projet (phase + CPU/mémoire). Un projet
// qui n'a pas (ou plus) de pods (échec, suppression) renvoie un état vide sans
// interroger le cluster.