From f5dc6cded2440daccc100012042ef480bb766616 Mon Sep 17 00:00:00 2001 From: Bugs5382 <12115015+Bugs5382@users.noreply.github.com> Date: Mon, 27 Jul 2026 12:11:19 -0400 Subject: [PATCH] fix(manager): do not seed the demo catalog into a live store The demo catalog (fixture nodes, cert profiles, protocol adapters, audit events, and enrollments) was seeded into every store, so a fresh Postgres deployment came up showing fake enrollments and audit history. Scope the demo catalog to the dev-only in-memory store; a live Postgres store now starts clean and is seeded only with configured nodes and, when an operator CA node is set, the functional operator- issuing profiles. Closes #55 --- cmd/manager/main.go | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/cmd/manager/main.go b/cmd/manager/main.go index 6f4923c..4b66996 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -67,23 +67,26 @@ func main() { CACert: n.CACertPath, } } - profiles, adapters, audit, enrollments := seed.Catalog() - - // When an operator-CA node is configured, seed the three operator- - // issuing profiles into the catalog so an admin can push them to that node - // (via ApplyProfileToNode) and S9 issuance can route to them. + // Operator-CA issuing profiles (operator-viewer/operator/admin) are + // functional config, not demo data: seed them when an operator CA node is + // configured so S9 issuance can route to them. + var operatorProfiles []store.Profile if cfg.OperatorCANode != "" { - opProfiles, err := fleet.OperatorProfiles() + var err error + operatorProfiles, err = fleet.OperatorProfiles() if err != nil { log.Fatalf("manager: build operator profiles: %v", err) } - profiles = append(profiles, opProfiles...) } var st store.Store if cfg.DatabaseURL == "" { + // Dev-only in-memory store: seed the demo catalog so the offline mock UI + // renders against fixtures. The demo catalog never touches a real store. + profiles, adapters, audit, enrollments := seed.Catalog() + profiles = append(profiles, operatorProfiles...) st = memory.NewWithCatalog(nodes, profiles, adapters, audit, enrollments) - log.Printf("manager: no database_url configured, using in-memory store") + log.Printf("manager: no database_url configured, using in-memory store (demo catalog seeded)") } else { ctx := context.Background() pg, err := postgres.New(ctx, cfg.DatabaseURL) @@ -91,7 +94,10 @@ func main() { log.Fatalf("manager: connect postgres: %v", err) } defer pg.Close() - if err := pg.SeedIfEmpty(ctx, nodes, profiles, adapters, audit, enrollments); err != nil { + // A live store starts clean: no demo nodes, profiles, adapters, audit, + // or enrollments. Only configured nodes and the functional operator-CA + // profiles are seeded. + if err := pg.SeedIfEmpty(ctx, nodes, operatorProfiles, nil, nil, nil); err != nil { log.Fatalf("manager: seed postgres: %v", err) } st = pg @@ -189,8 +195,7 @@ func main() { // store.Store interface; see #40. rootHandler := withRecover(withCORS(cfg.CORSOrigins, authMW(mux))) - log.Printf("manager: %d node(s) configured, catalog seeded (%d profiles, %d adapters, %d audit events, %d enrollments)", - len(nodes), len(profiles), len(adapters), len(audit), len(enrollments)) + log.Printf("manager: %d node(s) configured", len(nodes)) server := &http.Server{Addr: cfg.Listen}