/** * PVDetailSection — injected into Headlamp's PersistentVolume detail view. * * Shown only when the PV uses tns.csi.io as the CSI driver. * Uses registerDetailsViewSection in index.tsx. */ import { NameValueTable, SectionBox } from '@kinvolk/headlamp-plugin/lib/CommonComponents'; import React from 'react'; import { formatProtocol, TNS_CSI_PROVISIONER } from '../api/k8s'; interface PVDetailSectionProps { resource: { kind?: string; metadata?: { name?: string; namespace?: string }; spec?: { csi?: { driver?: string; volumeHandle?: string; volumeAttributes?: Record; }; storageClassName?: string; capacity?: { storage?: string }; persistentVolumeReclaimPolicy?: string; }; // KubeObject instance — raw JSON lives under jsonData jsonData?: { spec?: { csi?: { driver?: string; volumeHandle?: string; volumeAttributes?: Record; }; storageClassName?: string; }; }; }; } export default function PVDetailSection({ resource }: PVDetailSectionProps) { // Extract from jsonData (KubeObject instance) or fall back to direct properties const spec = resource?.jsonData?.spec ?? resource?.spec; const csi = spec?.csi; if (!csi || csi.driver !== TNS_CSI_PROVISIONER) { return null; } const attrs = csi.volumeAttributes ?? {}; const protocol = formatProtocol(attrs['protocol']); const otherAttrs = Object.entries(attrs).filter( ([k]) => !['protocol', 'server', 'pool'].includes(k) ); return ( ({ name: k, value: v ?? '—' })), ]} /> ); }