Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

docs(cloudcp): pin Pulse Account bootstrap contract

rcourtman145c3a95d9f0
diff --git a/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md b/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md
index d2535bc2f5..9fb3763ef9 100644
--- a/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md
+++ b/docs/release-control/v6/internal/PULSE_ACCOUNT_PORTAL_SPEC.md
@@ -221,6 +221,22 @@ The `customer-account-portal` lane should deliver:
memberships, and recovery
4. de-duplication of fragmented public utility flows where a real authenticated
account area is the better product shape
+5. a renderer-owned frontend bootstrap contract for the account shell, so a
+ maintained frontend can consume canonical account state without scraping
+ ad-hoc DOM attributes or hardcoded production URLs
+
+### Current frontend seam
+
+The current `/portal` shell now emits a machine-owned bootstrap payload in a
+`pulse-account-bootstrap` JSON script tag. That payload is the canonical
+frontend state seam for:
+
+1. account identity context
+2. hosted account and workspace summaries
+3. public/commercial edge URLs needed by the account shell
+
+New frontend work should extend that contract deliberately instead of adding
+one-off data attributes or baking production hostnames into static assets.
### Post-lane follow-on
diff --git a/internal/cloudcp/portal/handlers_test.go b/internal/cloudcp/portal/handlers_test.go
index df9dde74f6..d5e88625d0 100644
--- a/internal/cloudcp/portal/handlers_test.go
+++ b/internal/cloudcp/portal/handlers_test.go
@@ -760,6 +760,73 @@ func TestPortalPageTemplate_AccountServicesRendered(t *testing.T) {
}
}
+func TestBuildPortalBootstrapJSON_Contract(t *testing.T) {
+ bootstrapJSON, err := buildPortalBootstrapJSON("[email protected]", []portalPageAccount{
+ {
+ ID: "a_test",
+ Kind: "cloud",
+ KindLabel: "Cloud",
+ Name: "Test Account",
+ Role: "owner",
+ CanManage: true,
+ HasBilling: true,
+ Workspaces: []portalPageWorkspace{
+ {
+ ID: "t_one",
+ DisplayName: "Tenant One",
+ State: "active",
+ Healthy: true,
+ },
+ },
+ },
+ })
+ if err != nil {
+ t.Fatalf("buildPortalBootstrapJSON: %v", err)
+ }
+
+ var payload map[string]any
+ if err := json.Unmarshal([]byte(bootstrapJSON), &payload); err != nil {
+ t.Fatalf("unmarshal bootstrap JSON: %v", err)
+ }
+
+ if got := payload["email"]; got != "[email protected]" {
+ t.Fatalf("email = %#v, want [email protected]", got)
+ }
+ if got := payload["commercial_api_base_url"]; got != "https://license.pulserelay.pro" {
+ t.Fatalf("commercial_api_base_url = %#v", got)
+ }
+
+ accounts, ok := payload["accounts"].([]any)
+ if !ok || len(accounts) != 1 {
+ t.Fatalf("accounts = %#v, want one account", payload["accounts"])
+ }
+ account, ok := accounts[0].(map[string]any)
+ if !ok {
+ t.Fatalf("account payload = %#v", accounts[0])
+ }
+ if got := account["id"]; got != "a_test" {
+ t.Fatalf("account id = %#v", got)
+ }
+ if got := account["can_manage"]; got != true {
+ t.Fatalf("account can_manage = %#v", got)
+ }
+
+ workspaces, ok := account["workspaces"].([]any)
+ if !ok || len(workspaces) != 1 {
+ t.Fatalf("workspaces = %#v, want one workspace", account["workspaces"])
+ }
+ workspace, ok := workspaces[0].(map[string]any)
+ if !ok {
+ t.Fatalf("workspace payload = %#v", workspaces[0])
+ }
+ if got := workspace["display_name"]; got != "Tenant One" {
+ t.Fatalf("workspace display_name = %#v", got)
+ }
+ if got := workspace["healthy"]; got != true {
+ t.Fatalf("workspace healthy = %#v", got)
+ }
+}
+
func TestPortalLoginTemplate_UsesPulseAccountBranding(t *testing.T) {
html := renderLoginHTML(t, "test-nonce")