Skip to content

Commit dd1ff0b

Browse files
author
ohotnikov.ivan
committed
feat(console): fetch branding config from Kubernetes ConfigMap at runtime
Replace static /config.json file fetch with a live read of the cozy-dashboard-console-config ConfigMap via the Kubernetes API. This way branding is applied without restarting the pod and without nginx volume mounts — any change to _cluster.branding values is reflected on next page load. Signed-off-by: ohotnikov.ivan <[email protected]>
1 parent 2a28ecc commit dd1ff0b

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

‎apps/console/src/lib/config.ts‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@ export interface AppConfig {
66
iconSvg?: string
77
}
88

9+
const CONFIG_NAMESPACE = "cozy-dashboard"
10+
const CONFIG_MAP_NAME = "cozy-dashboard-console-config"
11+
912
export async function loadConfig(): Promise<AppConfig> {
1013
try {
11-
const resp = await fetch("/config.json")
12-
if (resp.ok) return resp.json() as Promise<AppConfig>
14+
const resp = await fetch(
15+
`/api/v1/namespaces/${CONFIG_NAMESPACE}/configmaps/${CONFIG_MAP_NAME}`,
16+
)
17+
if (!resp.ok) return {}
18+
const cm = await resp.json()
19+
const raw = cm?.data?.["config.json"]
20+
if (!raw) return {}
21+
return JSON.parse(raw) as AppConfig
1322
} catch {
14-
// config.json is optional; fall back to defaults
23+
return {}
1524
}
16-
return {}
1725
}

0 commit comments

Comments
 (0)