/* * SysDeck - Service Mesh Panel * Author: Jeremy Anderson (https://dcos.net) * * Queries Kubernetes services via `kubectl get svc -A -o json`. Renders * the service list with namespaces. Falls back to a hint card when * kubectl is absent or the cluster is unreachable. * * v0.1.4 FIX + SECURITY: the table used to read svc.metadata.* / * svc.spec.*, but bridge/mesh.py returns a FLATTENED shape * {name, namespace, type, clusterIP, ports} — any populated cluster * threw a TypeError and the panel died. Names/namespace values come * from kubectl output and are now escaped too (0.3.0 audit). */ function escapeHtml(s) { return String(s == null ? '' : s) .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/'/g, '''); } export async function mount(panel, { bridge, EventBus }) { panel.innerHTML = renderSkeleton(); const data = await bridge.mesh.services(); const items = data?.items ?? []; panel.innerHTML = `

Service Mesh

${items.length} Kubernetes services

${items.map((svc) => ` `).join('') || ''}
NamespaceServiceTypeCluster IPPorts
${escapeHtml(svc.namespace)} ${escapeHtml(svc.name)} ${escapeHtml(svc.type ?? '—')} ${escapeHtml(svc.clusterIP ?? '—')} ${escapeHtml((svc.ports ?? []).join(', ') || '—')}
No services. Confirm kubectl is installed and kubeconfig is reachable.
`; EventBus.emit('mesh.loaded', { serviceCount: items.length }); } function renderSkeleton() { return `
`; }