@skyhook-io/radar-app 1.20.1 → 1.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/package.json +10 -9
  2. package/src/App.tsx +65 -16
  3. package/src/api/client.audit-gating.test.tsx +105 -5
  4. package/src/api/client.auditBadgesSync.test.tsx +118 -0
  5. package/src/api/client.capabilitiesPoll.test.ts +61 -0
  6. package/src/api/client.namespaceSwitch.hook.test.tsx +170 -1
  7. package/src/api/client.pauseDeployment.test.tsx +77 -0
  8. package/src/api/client.restartError.test.ts +14 -0
  9. package/src/api/client.revisionRefresh.test.tsx +44 -0
  10. package/src/api/client.rollbackError.test.ts +14 -0
  11. package/src/api/client.ts +347 -16
  12. package/src/api/namespaceScopeRetry.test.ts +14 -0
  13. package/src/api/networkAttachments.test.tsx +120 -0
  14. package/src/api/networkAttachments.ts +30 -0
  15. package/src/api/radarFeatures.test.ts +5 -0
  16. package/src/api/radarFeatures.ts +10 -0
  17. package/src/api/secretsStore.test.ts +33 -0
  18. package/src/api/secretsStore.ts +37 -0
  19. package/src/api/substrateHealth.ts +134 -0
  20. package/src/api/velero.test.ts +60 -0
  21. package/src/api/velero.ts +201 -0
  22. package/src/api/vulnerabilities.ts +255 -0
  23. package/src/components/ConnectionErrorView.test.tsx +11 -0
  24. package/src/components/ConnectionErrorView.tsx +19 -0
  25. package/src/components/ContextSwitcher.tsx +9 -2
  26. package/src/components/NamespaceSwitcher.tsx +3 -1
  27. package/src/components/applications/ApplicationsView.openResource.test.tsx +118 -0
  28. package/src/components/applications/ApplicationsView.tsx +8 -11
  29. package/src/components/audit/AuditView.tsx +4 -0
  30. package/src/components/audit/ChecksViewTabs.test.tsx +33 -5
  31. package/src/components/audit/ChecksViewTabs.tsx +11 -1
  32. package/src/components/audit/UpgradeReadinessView.test.ts +35 -1
  33. package/src/components/audit/UpgradeReadinessView.tsx +60 -2
  34. package/src/components/audit/VulnerabilitiesView.tsx +907 -0
  35. package/src/components/cnpg/CNPGClusterTabs.tsx +3 -1
  36. package/src/components/cnpg/CNPGDrawerTrail.tsx +5 -26
  37. package/src/components/cnpg/CNPGInvestigationAction.test.tsx +27 -6
  38. package/src/components/cnpg/CNPGView.tsx +43 -117
  39. package/src/components/cnpg/CNPGWorkspace.compatibility.test.tsx +30 -0
  40. package/src/components/cnpg/host.tsx +2 -2
  41. package/src/components/cnpg/routes.ts +3 -1
  42. package/src/components/cnpg/shared.tsx +5 -53
  43. package/src/components/cnpg/useCNPGNavigate.ts +1 -21
  44. package/src/components/cnpg/useCNPGSidebarWorkspace.ts +16 -13
  45. package/src/components/community.tsx +42 -0
  46. package/src/components/cost/CostView.tsx +27 -9
  47. package/src/components/diagnose/InvestigationView.tsx +12 -3
  48. package/src/components/diagnose/diagnoseEvidenceTypes.ts +2 -0
  49. package/src/components/diagnose/investigationEvidence/adapters/helm.test.tsx +52 -0
  50. package/src/components/diagnose/investigationEvidence/adapters/helm.ts +10 -0
  51. package/src/components/diagnose/investigationEvidence/bodies/platform.tsx +82 -51
  52. package/src/components/diagnose/investigationEvidence/types.ts +5 -0
  53. package/src/components/diagnose/investigationMetrics.test.ts +20 -0
  54. package/src/components/diagnose/investigationMetrics.ts +2 -1
  55. package/src/components/dock/BottomDock.tsx +1 -0
  56. package/src/components/dock/LogsTab.tsx +3 -0
  57. package/src/components/dock/TerminalPreferences.query.test.tsx +57 -0
  58. package/src/components/dock/TerminalPreferences.test.tsx +68 -0
  59. package/src/components/dock/TerminalPreferences.tsx +73 -0
  60. package/src/components/gitops/GitOpsView.tsx +2 -10
  61. package/src/components/helm/HelmDrawerFrame.tsx +1 -1
  62. package/src/components/helm/HelmReleaseDrawer.tsx +24 -12
  63. package/src/components/helm/HelmView.tsx +25 -19
  64. package/src/components/helm/NotCheckedBadge.test.tsx +62 -0
  65. package/src/components/helm/NotCheckedBadge.tsx +39 -0
  66. package/src/components/helm/OwnedResources.test.tsx +86 -0
  67. package/src/components/helm/OwnedResources.tsx +69 -11
  68. package/src/components/home/ClusterHealthCard.heading.test.tsx +72 -0
  69. package/src/components/home/ClusterHealthCard.test.ts +44 -1
  70. package/src/components/home/ClusterHealthCard.tsx +25 -11
  71. package/src/components/home/HelmSummary.tsx +15 -15
  72. package/src/components/home/HomeAgentBlock.tsx +3 -0
  73. package/src/components/home/HomeView.tsx +7 -0
  74. package/src/components/home/MCPSetupDialog.test.tsx +19 -12
  75. package/src/components/home/MCPSetupDialog.tsx +4 -2
  76. package/src/components/home/mcpToolCatalog.ts +17 -4
  77. package/src/components/home/useVulnerabilitiesRow.test.ts +26 -0
  78. package/src/components/home/useVulnerabilitiesRow.ts +50 -0
  79. package/src/components/logs/LogsViewer.tsx +3 -1
  80. package/src/components/logs/MultiPodLogsTab.test.tsx +24 -4
  81. package/src/components/logs/MultiPodLogsTab.tsx +9 -5
  82. package/src/components/nav/PrimaryNavRail.test.tsx +17 -0
  83. package/src/components/nav/PrimaryNavRail.tsx +174 -29
  84. package/src/components/resource/PrometheusChartsGrid.tsx +5 -1
  85. package/src/components/resource/RightsizingStrip.test.ts +57 -0
  86. package/src/components/resource/RightsizingStrip.tsx +53 -4
  87. package/src/components/resource/SubstrateHealthCharts.test.tsx +143 -0
  88. package/src/components/resource/SubstrateHealthCharts.tsx +254 -0
  89. package/src/components/resource/SubstrateVerdictLine.test.tsx +131 -0
  90. package/src/components/resource/SubstrateVerdictLine.tsx +180 -0
  91. package/src/components/resources/ImageFilesystemModal.test.tsx +74 -6
  92. package/src/components/resources/ImageFilesystemModal.tsx +98 -6
  93. package/src/components/resources/PodFileUploadPanel.tsx +150 -0
  94. package/src/components/resources/PodFilesystemModal.tsx +246 -3
  95. package/src/components/resources/ResourcesView.tsx +12 -6
  96. package/src/components/resources/pod-file-upload.test.tsx +223 -0
  97. package/src/components/resources/pod-file-upload.ts +266 -0
  98. package/src/components/resources/renderers/HTTPRouteRenderer.test.tsx +50 -0
  99. package/src/components/resources/renderers/HTTPRouteRenderer.tsx +27 -0
  100. package/src/components/resources/renderers/PodRenderer.tsx +26 -1
  101. package/src/components/resources/renderers/SecretProviderClassRenderer.tsx +25 -0
  102. package/src/components/resources/renderers/UpgradePlanRenderer.test.tsx +20 -0
  103. package/src/components/resources/renderers/UpgradePlanRenderer.tsx +22 -0
  104. package/src/components/resources/renderers/VeleroBackupRenderer.tsx +16 -36
  105. package/src/components/resources/renderers/VeleroRestoreRenderer.tsx +6 -19
  106. package/src/components/resources/renderers/WorkloadRenderer.tsx +8 -0
  107. package/src/components/rightsizing/RightsizingScanView.tsx +19 -3
  108. package/src/components/rightsizing/model.test.ts +11 -0
  109. package/src/components/rightsizing/model.ts +3 -1
  110. package/src/components/rightsizing/presentation.test.ts +46 -0
  111. package/src/components/rightsizing/presentation.ts +17 -2
  112. package/src/components/shared/LargeClusterNamespacePicker.test.tsx +27 -0
  113. package/src/components/shared/LargeClusterNamespacePicker.tsx +8 -2
  114. package/src/components/timeline/TimelineView.tsx +3 -1
  115. package/src/components/traffic/TrafficConnectionsTable.test.tsx +94 -0
  116. package/src/components/traffic/TrafficConnectionsTable.tsx +21 -5
  117. package/src/components/traffic/TrafficData.test.tsx +37 -0
  118. package/src/components/traffic/TrafficData.tsx +27 -0
  119. package/src/components/traffic/TrafficFlowList.tsx +9 -7
  120. package/src/components/traffic/TrafficGraph.layoutEngine.test.tsx +193 -0
  121. package/src/components/traffic/TrafficGraph.test.tsx +269 -0
  122. package/src/components/traffic/TrafficGraph.tsx +135 -64
  123. package/src/components/traffic/TrafficGraphUnavailable.tsx +57 -0
  124. package/src/components/traffic/TrafficView.layoutUnavailable.test.tsx +211 -0
  125. package/src/components/traffic/TrafficView.tsx +72 -155
  126. package/src/components/traffic/trafficFilters.test.ts +189 -1
  127. package/src/components/traffic/trafficFilters.ts +169 -1
  128. package/src/components/ui/DiagnosticsOverlay.tsx +14 -1
  129. package/src/components/ui/Omnibar.tsx +4 -1
  130. package/src/components/ui/RadarOmnibar.test.tsx +55 -2
  131. package/src/components/ui/RadarOmnibar.tsx +7 -1
  132. package/src/components/ui/SearchSyntaxHelp.test.tsx +9 -2
  133. package/src/components/ui/SearchSyntaxHelp.tsx +3 -2
  134. package/src/components/ui/UpdateNotification.manual.test.tsx +5 -2
  135. package/src/components/ui/UpdateNotification.test.tsx +54 -3
  136. package/src/components/ui/UpdateNotification.tsx +60 -19
  137. package/src/components/ui/command-items.ts +24 -1
  138. package/src/components/ui/omnibar-match.test.ts +7 -0
  139. package/src/components/ui/omnibar-match.ts +1 -0
  140. package/src/components/ui/searchCoverageNote.test.ts +17 -0
  141. package/src/components/ui/searchCoverageNote.ts +31 -7
  142. package/src/components/useContextSwitchFlow.tsx +9 -1
  143. package/src/components/velero/VeleroBackupNow.test.tsx +165 -0
  144. package/src/components/velero/VeleroBackupNow.tsx +143 -0
  145. package/src/components/velero/VeleroDeleteBackup.test.tsx +364 -0
  146. package/src/components/velero/VeleroDeleteBackup.tsx +306 -0
  147. package/src/components/velero/VeleroDetailPage.tsx +148 -0
  148. package/src/components/velero/VeleroKindLists.test.tsx +48 -0
  149. package/src/components/velero/VeleroKindLists.tsx +43 -0
  150. package/src/components/velero/VeleroLocations.expand.test.tsx +27 -0
  151. package/src/components/velero/VeleroLocations.test.tsx +86 -0
  152. package/src/components/velero/VeleroLocations.tsx +240 -0
  153. package/src/components/velero/VeleroOverview.test.tsx +311 -0
  154. package/src/components/velero/VeleroOverview.tsx +485 -0
  155. package/src/components/velero/VeleroPages.test.tsx +516 -0
  156. package/src/components/velero/VeleroPages.tsx +1056 -0
  157. package/src/components/velero/VeleroRunLists.tsx +309 -0
  158. package/src/components/velero/VeleroRunMessagesHost.test.tsx +25 -0
  159. package/src/components/velero/VeleroRunMessagesHost.tsx +54 -0
  160. package/src/components/velero/VeleroScheduleStatusBadge.test.tsx +28 -0
  161. package/src/components/velero/VeleroScheduleStatusBadge.tsx +21 -0
  162. package/src/components/velero/VeleroSchedules.tsx +255 -0
  163. package/src/components/velero/VeleroView.tsx +59 -0
  164. package/src/components/velero/VeleroWorkspace.gate.test.tsx +97 -0
  165. package/src/components/velero/attention.test.ts +178 -0
  166. package/src/components/velero/attention.ts +281 -0
  167. package/src/components/velero/backupDelete.test.tsx +91 -0
  168. package/src/components/velero/backupDelete.tsx +182 -0
  169. package/src/components/velero/coverage.test.ts +87 -0
  170. package/src/components/velero/coverage.ts +150 -0
  171. package/src/components/velero/host.tsx +86 -0
  172. package/src/components/velero/routes.ts +78 -0
  173. package/src/components/velero/runs.tsx +121 -0
  174. package/src/components/velero/shared.test.ts +84 -0
  175. package/src/components/velero/shared.tsx +423 -0
  176. package/src/components/velero/useVeleroSidebarWorkspace.test.tsx +28 -0
  177. package/src/components/velero/useVeleroSidebarWorkspace.ts +71 -0
  178. package/src/components/velero/velero.fixtures.ts +61 -0
  179. package/src/components/velero/workspaceRoute.ts +21 -0
  180. package/src/components/vulnerabilities/WorkloadVulnerabilitiesSection.tsx +167 -0
  181. package/src/components/vulnerabilities/parts.test.ts +72 -0
  182. package/src/components/vulnerabilities/parts.tsx +291 -0
  183. package/src/components/workload/NodeCertificateEvidence.test.tsx +51 -0
  184. package/src/components/workload/NodeCertificateEvidence.tsx +44 -0
  185. package/src/components/workload/WorkloadView.tsx +114 -37
  186. package/src/components/workspace/DrawerTrailBack.tsx +32 -0
  187. package/src/components/workspace/WorkspaceFrame.tsx +71 -0
  188. package/src/components/workspace/coverage.ts +61 -0
  189. package/src/components/workspace/layout.test.tsx +29 -1
  190. package/src/components/workspace/layout.tsx +15 -5
  191. package/src/components/workspace/sidebar.ts +9 -0
  192. package/src/components/workspace/useWorkspaceDrawer.ts +63 -0
  193. package/src/components/workspace/useWorkspaceNavigate.ts +21 -0
  194. package/src/context/ConnectionContext.test.ts +1 -0
  195. package/src/context/ConnectionContext.tsx +2 -2
  196. package/src/desktop/AboutDialog.test.ts +12 -0
  197. package/src/desktop/AboutDialog.tsx +151 -0
  198. package/src/desktop/WindowsTitleBar.tsx +359 -0
  199. package/src/desktop/titleBar.test.ts +61 -0
  200. package/src/desktop/titleBar.ts +45 -0
  201. package/src/index.css +19 -0
  202. package/src/integrations/resourceHost.ts +5 -1
  203. package/src/integrations/resourceHosts.test.tsx +15 -3
  204. package/src/integrations/resourceHosts.tsx +26 -6
  205. package/src/integrations/workspaceRoute.ts +1 -1
  206. package/src/integrations/workspaceRoutes.test.ts +11 -0
  207. package/src/integrations/workspaceRoutes.ts +3 -1
  208. package/src/integrations/workspaceScreens.tsx +2 -0
  209. package/src/main.tsx +8 -0
  210. package/src/utils/desktop-zoom.test.ts +53 -0
  211. package/src/utils/desktop-zoom.ts +30 -0
  212. package/src/utils/namespacePick.test.ts +87 -0
  213. package/src/utils/namespacePick.ts +88 -0
  214. package/src/utils/staleAssetPrompt.test.tsx +76 -0
  215. package/src/utils/staleAssetPrompt.tsx +32 -0
@@ -0,0 +1,266 @@
1
+ import type { FileNode } from '../../types'
2
+ import { apiUrl, getAuthHeaders, getCredentialsMode } from '../../api/config'
3
+ import { formatBytes } from '../../utils/format'
4
+
5
+ export const POD_FILE_PERSISTENCE_NOTE =
6
+ "Changes apply to the running container immediately. Files in the container's own filesystem are lost when it's recreated; files on volumes may persist. For lasting changes, update the source (image, ConfigMap, manifest)."
7
+
8
+ /** Mirrors the server's podFileUploadMaxBytes, so an oversize file is refused before it is sent. */
9
+ export const POD_FILE_UPLOAD_MAX_BYTES = 100 * 1024 * 1024
10
+
11
+ export interface UploadGateInput {
12
+ canExec: boolean
13
+ featureSupported: boolean
14
+ }
15
+
16
+ /**
17
+ * Uploads ride on exec: anyone who can exec can already write through the
18
+ * terminal. The feature check keeps them off an older Radar without the endpoint.
19
+ */
20
+ export function canShowUpload({ canExec, featureSupported }: UploadGateInput): boolean {
21
+ return canExec && featureSupported
22
+ }
23
+
24
+ interface VolumeMountLike {
25
+ name?: string
26
+ mountPath?: string
27
+ readOnly?: boolean
28
+ }
29
+
30
+ interface ContainerLike {
31
+ name?: string
32
+ volumeMounts?: VolumeMountLike[]
33
+ securityContext?: { readOnlyRootFilesystem?: boolean }
34
+ }
35
+
36
+ interface ProjectionLike {
37
+ configMap?: { name?: string }
38
+ secret?: { name?: string }
39
+ }
40
+
41
+ interface VolumeLike {
42
+ name?: string
43
+ configMap?: { name?: string }
44
+ secret?: { secretName?: string }
45
+ projected?: { sources?: ProjectionLike[] }
46
+ downwardAPI?: object
47
+ }
48
+
49
+ interface PodLike {
50
+ spec?: {
51
+ containers?: ContainerLike[]
52
+ initContainers?: ContainerLike[]
53
+ ephemeralContainers?: ContainerLike[]
54
+ volumes?: VolumeLike[]
55
+ }
56
+ }
57
+
58
+ export interface MountSource {
59
+ kind: 'ConfigMap' | 'Secret'
60
+ name: string
61
+ }
62
+
63
+ export interface MountHint {
64
+ reason: string
65
+ source?: MountSource
66
+ }
67
+
68
+ function findContainer(pod: unknown, container: string): ContainerLike | undefined {
69
+ const spec = (pod as PodLike | undefined)?.spec ?? {}
70
+ // Native sidecars are init containers with restartPolicy Always; they are
71
+ // browsable, so their mounts count too.
72
+ for (const list of [spec.containers, spec.initContainers, spec.ephemeralContainers]) {
73
+ const found = (list ?? []).find((c) => c?.name === container)
74
+ if (found) return found
75
+ }
76
+ return undefined
77
+ }
78
+
79
+ function covers(mountPath: string, dir: string): boolean {
80
+ const mp = mountPath.length > 1 ? mountPath.replace(/\/+$/, '') : mountPath
81
+ return mp === '/' || dir === mp || dir.startsWith(mp + '/')
82
+ }
83
+
84
+ function managedVolumeHint(volume: VolumeLike | undefined, mountPath: string): MountHint | null {
85
+ if (volume?.configMap) {
86
+ return {
87
+ reason: `${mountPath} is a ConfigMap volume. Kubernetes manages these files and they are read-only; change the ConfigMap instead.`,
88
+ source: volume.configMap.name ? { kind: 'ConfigMap', name: volume.configMap.name } : undefined,
89
+ }
90
+ }
91
+ if (volume?.secret) {
92
+ return {
93
+ reason: `${mountPath} is a Secret volume. Kubernetes manages these files and they are read-only; change the Secret instead.`,
94
+ source: volume.secret.secretName ? { kind: 'Secret', name: volume.secret.secretName } : undefined,
95
+ }
96
+ }
97
+ if (volume?.projected) {
98
+ const sources = volume.projected.sources ?? []
99
+ const single = sources.length === 1 ? sources[0] : undefined
100
+ let source: MountSource | undefined
101
+ if (single?.configMap?.name) source = { kind: 'ConfigMap', name: single.configMap.name }
102
+ else if (single?.secret?.name) source = { kind: 'Secret', name: single.secret.name }
103
+ return {
104
+ reason: `${mountPath} is a projected volume. Kubernetes manages these files and they are read-only; change their source instead.`,
105
+ source,
106
+ }
107
+ }
108
+ if (volume?.downwardAPI) {
109
+ return { reason: `${mountPath} is a downward API volume. Kubernetes writes these files from the pod's own fields.` }
110
+ }
111
+ return null
112
+ }
113
+
114
+ /**
115
+ * Why uploading into `dir` of `container` cannot work, read from the pod spec,
116
+ * or null when nothing in the spec says so. A hint only: the server is the
117
+ * authority and reports what actually happened.
118
+ */
119
+ export function uploadBlockedHint(pod: unknown, container: string, dir: string): MountHint | null {
120
+ const c = findContainer(pod, container)
121
+ if (!c) return null
122
+ const volumes = (pod as PodLike | undefined)?.spec?.volumes ?? []
123
+ const mounts = (c.volumeMounts ?? [])
124
+ .filter((m): m is VolumeMountLike & { mountPath: string } => typeof m?.mountPath === 'string' && covers(m.mountPath, dir))
125
+ .sort((a, b) => b.mountPath.length - a.mountPath.length)
126
+ const mount = mounts[0]
127
+ if (mount) {
128
+ const volume = volumes.find((v) => v?.name === mount.name)
129
+ const managed = managedVolumeHint(volume, mount.mountPath)
130
+ if (managed) return managed
131
+ if (mount.readOnly) return { reason: `${mount.mountPath} is mounted read-only.` }
132
+ return null
133
+ }
134
+ if (c.securityContext?.readOnlyRootFilesystem) {
135
+ return { reason: "This container's root filesystem is read-only (readOnlyRootFilesystem), and this directory is not on a writable volume." }
136
+ }
137
+ return null
138
+ }
139
+
140
+ /** A volume mounted onto exactly `filePath` (a subPath file mount), which no rename can replace. */
141
+ export function fileMountHint(pod: unknown, container: string, filePath: string): MountHint | null {
142
+ const c = findContainer(pod, container)
143
+ const mount = (c?.volumeMounts ?? []).find((m) => m?.mountPath === filePath)
144
+ if (!mount) return null
145
+ const volume = (pod as PodLike | undefined)?.spec?.volumes?.find((v) => v?.name === mount.name)
146
+ const managed = managedVolumeHint(volume, filePath)
147
+ return {
148
+ reason: `${filePath} is mounted into the container on its own, so it cannot be replaced here.${managed?.source ? ` Change the ${managed.source.kind} instead.` : ''}`,
149
+ source: managed?.source,
150
+ }
151
+ }
152
+
153
+ export type UploadTarget =
154
+ | { kind: 'new' }
155
+ | { kind: 'replace' }
156
+ | { kind: 'refuse'; reason: string }
157
+
158
+ /** What uploading `name` into the listed directory would do, from the listing. */
159
+ export function uploadTarget(listing: FileNode | undefined, name: string): UploadTarget {
160
+ const existing = listing?.children?.find((c) => c.name === name)
161
+ if (!existing) return { kind: 'new' }
162
+ if (existing.type === 'dir') return { kind: 'refuse', reason: `${name} is a directory here.` }
163
+ if (existing.type === 'symlink') return { kind: 'refuse', reason: `${name} is a symlink here; uploads never follow symlinks.` }
164
+ return { kind: 'replace' }
165
+ }
166
+
167
+ /** Why a file is over the upload cap, or null when it fits. */
168
+ export function oversizeMessage(size: number, max: number = POD_FILE_UPLOAD_MAX_BYTES): string | null {
169
+ if (size <= max) return null
170
+ return `This file is ${formatBytes(size)}; uploads on this Radar are limited to ${formatBytes(max)}.`
171
+ }
172
+
173
+ /** A single path segment the server will accept as a file name. */
174
+ export function isValidUploadName(name: string): boolean {
175
+ if (name === '' || name === '.' || name === '..') return false
176
+ if (name.includes('/') || name.includes('\0')) return false
177
+ return new TextEncoder().encode(name).length <= 255
178
+ }
179
+
180
+ export interface UploadResult {
181
+ path: string
182
+ size: number
183
+ replaced: boolean
184
+ }
185
+
186
+ export class PodFileUploadError extends Error {
187
+ readonly code: string
188
+ readonly status: number
189
+ constructor(message: string, code: string, status: number) {
190
+ super(message)
191
+ this.name = 'PodFileUploadError'
192
+ this.code = code
193
+ this.status = status
194
+ }
195
+ }
196
+
197
+ // A 413 without Radar's own error body was refused before it reached Radar,
198
+ // usually by a proxy with a smaller request size limit than Radar's.
199
+ export function uploadResponseError(status: number, body: { error?: string; error_code?: string } | null): PodFileUploadError {
200
+ if (status === 413 && !body?.error) {
201
+ return new PodFileUploadError(
202
+ 'The upload was rejected as too large, possibly by a proxy in front of Radar. If so, that proxy\'s request size limit needs raising for uploads.',
203
+ 'file_too_large',
204
+ status,
205
+ )
206
+ }
207
+ return new PodFileUploadError(body?.error || `Upload failed (HTTP ${status})`, body?.error_code || 'upload_failed', status)
208
+ }
209
+
210
+ export const UPLOAD_CANCELLED = 'upload_cancelled'
211
+
212
+ export interface UploadRequest {
213
+ namespace: string
214
+ podName: string
215
+ container: string
216
+ dir: string
217
+ file: Blob
218
+ name: string
219
+ overwrite: boolean
220
+ onProgress?: (sent: number, total: number) => void
221
+ signal?: AbortSignal
222
+ }
223
+
224
+ /**
225
+ * Sends one file. XHR rather than fetch because fetch reports no upload
226
+ * progress.
227
+ */
228
+ export function uploadPodFile(req: UploadRequest): Promise<UploadResult> {
229
+ const params = new URLSearchParams({ container: req.container, dir: req.dir, name: req.name })
230
+ if (req.overwrite) params.set('overwrite', 'true')
231
+ const url = apiUrl(`/pods/${encodeURIComponent(req.namespace)}/${encodeURIComponent(req.podName)}/files/upload?${params}`)
232
+
233
+ return new Promise((resolve, reject) => {
234
+ const xhr = new XMLHttpRequest()
235
+ xhr.open('POST', url)
236
+ xhr.withCredentials = getCredentialsMode() === 'include'
237
+ for (const [k, v] of Object.entries(getAuthHeaders())) xhr.setRequestHeader(k, v)
238
+ xhr.setRequestHeader('Content-Type', 'application/octet-stream')
239
+ xhr.upload.onprogress = (e) => {
240
+ if (e.lengthComputable) req.onProgress?.(e.loaded, e.total)
241
+ }
242
+ xhr.onload = () => {
243
+ let body: { error?: string; error_code?: string } & Partial<UploadResult> | null = null
244
+ try {
245
+ body = JSON.parse(xhr.responseText)
246
+ } catch {
247
+ // fall through with the status alone
248
+ }
249
+ if (xhr.status >= 200 && xhr.status < 300 && body) {
250
+ resolve(body as UploadResult)
251
+ return
252
+ }
253
+ reject(uploadResponseError(xhr.status, body))
254
+ }
255
+ xhr.onerror = () => reject(new PodFileUploadError('The upload could not reach Radar', 'network_error', 0))
256
+ xhr.onabort = () => reject(new PodFileUploadError('Upload cancelled', UPLOAD_CANCELLED, 0))
257
+ if (req.signal) {
258
+ if (req.signal.aborted) {
259
+ xhr.abort()
260
+ return
261
+ }
262
+ req.signal.addEventListener('abort', () => xhr.abort(), { once: true })
263
+ }
264
+ xhr.send(req.file)
265
+ })
266
+ }
@@ -0,0 +1,50 @@
1
+ // @vitest-environment jsdom
2
+ import { act } from 'react'
3
+ import { createRoot } from 'react-dom/client'
4
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
5
+ import { describe, expect, it, vi } from 'vitest'
6
+ import { HTTPRouteRenderer } from './HTTPRouteRenderer'
7
+
8
+ vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
9
+
10
+ const mock = vi.hoisted(() => ({ reads: [] as unknown[][], responses: new Map<string, () => Promise<unknown>>() }))
11
+ vi.mock('../../../api/client', () => ({
12
+ resourceQueryOptions: (kind: string, namespace: string, name: string, group: string) => {
13
+ mock.reads.push([kind, namespace, name, group])
14
+ return { queryKey: ['resource', kind, namespace, name, group], queryFn: mock.responses.get(`${namespace}/${name}`)!, retry: false }
15
+ },
16
+ }))
17
+
18
+ const route = {
19
+ metadata: { name: 'storefront', namespace: 'shop' },
20
+ spec: { parentRefs: [{ name: 'main-gw' }], hostnames: ['store.example.com'], rules: [] },
21
+ }
22
+
23
+ async function mount() {
24
+ const element = document.createElement('div')
25
+ document.body.append(element)
26
+ const root = createRoot(element)
27
+ const client = new QueryClient()
28
+ await act(async () => root.render(<QueryClientProvider client={client}><HTTPRouteRenderer data={route} /></QueryClientProvider>))
29
+ await act(async () => { await new Promise(r => setTimeout(r, 0)) })
30
+ return { element, done: async () => { await act(async () => root.unmount()); element.remove() } }
31
+ }
32
+
33
+ describe('HTTPRoute host wrapper', () => {
34
+ it('reads the parent Gateway from the resource envelope and opens with its listener scheme', async () => {
35
+ mock.reads = []
36
+ mock.responses.set('shop/main-gw', async () => ({ resource: { spec: { listeners: [{ name: 'https', protocol: 'HTTPS', port: 443 }] } }, relationships: {} }))
37
+ const { element, done } = await mount()
38
+ expect(new Set(mock.reads.map(r => r.join('|')))).toEqual(new Set(['gateways|shop|main-gw|gateway.networking.k8s.io']))
39
+ expect(element.querySelector('a[target="_blank"]')?.getAttribute('href')).toBe('https://store.example.com')
40
+ await done()
41
+ })
42
+
43
+ it('falls back to copying the hostname when the Gateway read fails', async () => {
44
+ mock.responses.set('shop/main-gw', async () => { throw new Error('forbidden') })
45
+ const { element, done } = await mount()
46
+ expect(element.querySelector('a[target="_blank"]')).toBeNull()
47
+ expect(element.querySelector('button[aria-label^="Copy hostname"]')).not.toBeNull()
48
+ await done()
49
+ })
50
+ })
@@ -0,0 +1,27 @@
1
+ import { useQueries } from '@tanstack/react-query'
2
+ import { HTTPRouteRenderer as BaseHTTPRouteRenderer } from '@skyhook-io/k8s-ui/components/resources/renderers/HTTPRouteRenderer'
3
+ import { routeGateways, type GatewayLookup, type GatewayObject } from '@skyhook-io/k8s-ui/utils/host-url'
4
+ import { resourceQueryOptions } from '../../../api/client'
5
+ import type { ResourceRef } from '../../../types'
6
+
7
+ const GATEWAY_GROUP = 'gateway.networking.k8s.io'
8
+
9
+ interface HTTPRouteRendererProps {
10
+ data: any
11
+ onNavigate?: (ref: ResourceRef) => void
12
+ }
13
+
14
+ /** Reads the route's parent Gateways so its hostnames can open with the
15
+ * scheme their listeners serve. Shares the Gateway drawer's query. */
16
+ export function HTTPRouteRenderer({ data, onNavigate }: HTTPRouteRendererProps) {
17
+ const refs = routeGateways(data)
18
+ const parentGateways = useQueries({
19
+ queries: refs.map(ref => resourceQueryOptions<GatewayObject>('gateways', ref.namespace, ref.name, GATEWAY_GROUP)),
20
+ combine: (results): GatewayLookup[] => results.map((result, i) => ({
21
+ ...refs[i],
22
+ gateway: result.data?.resource,
23
+ status: result.data?.resource ? 'loaded' : result.isPending ? 'loading' : 'unavailable',
24
+ })),
25
+ })
26
+ return <BaseHTTPRouteRenderer data={data} onNavigate={onNavigate} parentGateways={parentGateways} />
27
+ }
@@ -1,12 +1,19 @@
1
1
  import { PodRenderer as BasePodRenderer } from '@skyhook-io/k8s-ui/components/resources/renderers/PodRenderer'
2
2
  import type { CopyHandler } from '@skyhook-io/k8s-ui/components/ui/drawer-components'
3
+ import { getPodNetworks, uniqueNetworkAttachmentRefs } from '@skyhook-io/k8s-ui/utils/multus'
3
4
  import type { PodEnvironmentRevealResponse, ResolvedEnvFrom } from '@skyhook-io/k8s-ui'
5
+ import { useMemo } from 'react'
4
6
  import { useNavigate } from 'react-router-dom'
5
7
  import { useOpenTerminal, useOpenLogs } from '../../dock'
6
8
  import { useCapabilitiesContext, useNamespacedCapabilities, useIsLocalDeployment } from '../../../contexts/CapabilitiesContext'
7
- import { getVisibleLiveMetrics, isLiveMetricsUnavailable, shouldFetchLiveMetrics, usePodEnvironment, usePodMetrics, usePodMetricsHistory, usePrometheusResourceMetrics, usePrometheusStatus, useRevealPodEnvironment } from '../../../api/client'
9
+ import { getVisibleLiveMetrics, isLiveMetricsUnavailable, shouldFetchLiveMetrics, usePodEnvironment, usePodMetrics, usePodMetricsHistory, usePrometheusResourceMetrics, usePrometheusStatus, useResourceEvents, useResources, useRevealPodEnvironment } from '../../../api/client'
10
+ import { toSecretsStoreRead } from '../../../api/secretsStore'
11
+ import {
12
+ SECRETS_STORE_GROUP, SECRET_PROVIDER_CLASSES, SECRET_PROVIDER_CLASS_POD_STATUSES, getSecretsStoreVolumes,
13
+ } from '@skyhook-io/k8s-ui/components/resources/resource-utils-secrets-store'
8
14
  import { useRBACSubject } from '../../../api/rbac'
9
15
  import { usePolicyResource } from '../../../api/policy'
16
+ import { useNetworkAttachmentLookups } from '../../../api/networkAttachments'
10
17
  import { podLimitRangeNames, useNamespaceLimitRanges } from '../../../api/quotas'
11
18
  import { podAwaitsScheduling } from '../../capacity/podDemandGate'
12
19
  import { PortForwardInlineButton } from '../../portforward/PortForwardButton'
@@ -83,6 +90,16 @@ export function PodRenderer({ data, onCopy, copied, onNavigate, onOpenLogs, reso
83
90
 
84
91
  const { data: limitRanges, isSuccess: limitRangesReady } = useNamespaceLimitRanges(namespace ?? '', !!namespace)
85
92
 
93
+ const networkAttachmentRefs = useMemo(() => uniqueNetworkAttachmentRefs(getPodNetworks(data).rows), [data])
94
+ const networkAttachmentLookups = useNetworkAttachmentLookups(networkAttachmentRefs)
95
+
96
+ // Secrets Store CSI: read only for a Pod that mounts such a volume.
97
+ const usesSecretsStore = !!namespace && getSecretsStoreVolumes(data).length > 0
98
+ const providerClasses = useResources<any>(SECRET_PROVIDER_CLASSES, namespace, SECRETS_STORE_GROUP, { enabled: usesSecretsStore })
99
+ const providerStatuses = useResources<any>(SECRET_PROVIDER_CLASS_POD_STATUSES, namespace, SECRETS_STORE_GROUP, { enabled: usesSecretsStore })
100
+ // The query the detail view's Events section already runs, so it shares that cache.
101
+ const podEvents = useResourceEvents(usesSecretsStore ? 'pods' : '', namespace ?? '', podName ?? '', '')
102
+
86
103
  return (
87
104
  <BasePodRenderer
88
105
  data={data}
@@ -115,6 +132,13 @@ export function PodRenderer({ data, onCopy, copied, onNavigate, onOpenLogs, reso
115
132
  policyLoading={policyLoading}
116
133
  policyError={policyError as Error | null}
117
134
  namespaceLimitRangeNames={limitRangesReady ? podLimitRangeNames(limitRanges) : undefined}
135
+ networkAttachmentLookups={networkAttachmentLookups}
136
+
137
+ secretsStore={usesSecretsStore ? {
138
+ classes: toSecretsStoreRead({ data: providerClasses.data, coverage: providerClasses.coverage, error: providerClasses.error, isLoading: providerClasses.isLoading }),
139
+ statuses: toSecretsStoreRead({ data: providerStatuses.data, coverage: providerStatuses.coverage, error: providerStatuses.error, isLoading: providerStatuses.isLoading }),
140
+ events: podEvents.k8sError ? undefined : podEvents.k8sEvents,
141
+ } : undefined}
118
142
  canExec={canExec}
119
143
  canViewLogs={canViewLogs}
120
144
  canPortForward={showPortForward}
@@ -155,6 +179,7 @@ export function PodRenderer({ data, onCopy, copied, onNavigate, onOpenLogs, reso
155
179
  containers={containers}
156
180
  initialContainer={initialContainer}
157
181
  onSwitchToImageFiles={onSwitchToImageFiles}
182
+ pod={data}
158
183
  />
159
184
  )}
160
185
  />
@@ -0,0 +1,25 @@
1
+ import { SecretProviderClassRenderer as BaseSecretProviderClassRenderer } from '@skyhook-io/k8s-ui/components/resources/renderers/SecretsStoreRenderers'
2
+ import {
3
+ SECRETS_STORE_GROUP, SECRET_PROVIDER_CLASS_POD_STATUSES,
4
+ } from '@skyhook-io/k8s-ui/components/resources/resource-utils-secrets-store'
5
+ import type { ResourceRef } from '@skyhook-io/k8s-ui'
6
+ import { useResources } from '../../../api/client'
7
+ import { toSecretsStoreRead } from '../../../api/secretsStore'
8
+
9
+ /**
10
+ * Host wrapper adding the reverse lookup the package renderer cannot do: which
11
+ * Pods in this namespace mount the class, and what the driver recorded for each.
12
+ */
13
+ export function SecretProviderClassRenderer({ data, onNavigate }: { data: any; onNavigate?: (ref: ResourceRef) => void }) {
14
+ const namespace = data?.metadata?.namespace ?? ''
15
+ const pods = useResources<any>('pods', namespace, undefined, { enabled: !!namespace })
16
+ const statuses = useResources<any>(SECRET_PROVIDER_CLASS_POD_STATUSES, namespace, SECRETS_STORE_GROUP, { enabled: !!namespace })
17
+ return (
18
+ <BaseSecretProviderClassRenderer
19
+ data={data}
20
+ pods={toSecretsStoreRead({ data: pods.data, coverage: pods.coverage, error: pods.error, isLoading: pods.isLoading })}
21
+ statuses={toSecretsStoreRead({ data: statuses.data, coverage: statuses.coverage, error: statuses.error, isLoading: statuses.isLoading })}
22
+ onNavigate={onNavigate}
23
+ />
24
+ )
25
+ }
@@ -0,0 +1,20 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import { toPlanNodes } from './UpgradePlanRenderer'
3
+
4
+ const node = { metadata: { name: 'n1', labels: { role: 'cp' } } }
5
+
6
+ describe('toPlanNodes', () => {
7
+ it('passes Nodes as name and labels', () => {
8
+ expect(toPlanNodes({ data: [node], coverage: { status: 'complete' } as any, error: null, isLoading: false })).toEqual({ nodes: [{ name: 'n1', labels: { role: 'cp' } }], loading: false })
9
+ })
10
+ it('treats a denied or partial Node read as unreadable', () => {
11
+ expect(toPlanNodes({ data: undefined, error: new Error('403'), isLoading: false }).nodes).toBeNull()
12
+ expect(toPlanNodes({ data: [node], coverage: { status: 'partial' } as any, error: null, isLoading: false }).nodes).toBeNull()
13
+ })
14
+ it('accepts a list from an older Radar that reports no coverage', () => {
15
+ expect(toPlanNodes({ data: [node], coverage: { status: 'unknown' } as any, error: null, isLoading: false }).nodes).toHaveLength(1)
16
+ })
17
+ it('waits while Nodes load', () => {
18
+ expect(toPlanNodes({ data: undefined, error: null, isLoading: true })).toEqual({ nodes: undefined, loading: true })
19
+ })
20
+ })
@@ -0,0 +1,22 @@
1
+ import { UpgradePlanRenderer as BaseUpgradePlanRenderer } from '@skyhook-io/k8s-ui/components/resources/renderers/UpgradePlanRenderer'
2
+ import type { PlanNode } from '@skyhook-io/k8s-ui/components/resources/resource-utils-upgrade-plan'
3
+ import type { ResourceRef } from '@skyhook-io/k8s-ui'
4
+ import type { ResourceCoverage } from '@skyhook-io/k8s-ui/types/resource-coverage'
5
+ import { useResources } from '../../../api/client'
6
+
7
+ // A Node read the caller was denied, or one that covered only part of the
8
+ // cluster, is unreadable: progress is then unknown, never "0 of 0". An older
9
+ // Radar reports no coverage; Nodes are cluster-scoped, so its list is whole.
10
+ export function toPlanNodes(query: { data?: any[]; coverage?: ResourceCoverage; error: unknown; isLoading: boolean }): { nodes: PlanNode[] | null | undefined; loading: boolean } {
11
+ if (query.error) return { nodes: null, loading: false }
12
+ if (query.isLoading && !query.data) return { nodes: undefined, loading: true }
13
+ if (!query.data || (query.coverage && query.coverage.status !== 'complete' && query.coverage.status !== 'unknown')) return { nodes: null, loading: false }
14
+ return { nodes: query.data.map((n) => ({ name: n?.metadata?.name ?? '', labels: n?.metadata?.labels ?? {} })), loading: false }
15
+ }
16
+
17
+ /** Host wrapper: feeds the cluster's Nodes to the Plan drawer's per-node progress. */
18
+ export function UpgradePlanRenderer({ data, onNavigate }: { data: any; onNavigate?: (ref: ResourceRef) => void }) {
19
+ const query = useResources<any>('nodes')
20
+ const { nodes, loading } = toPlanNodes({ data: query.data, coverage: query.coverage, error: query.error, isLoading: query.isLoading })
21
+ return <BaseUpgradePlanRenderer data={data} onNavigate={onNavigate} nodes={nodes} nodesLoading={loading} />
22
+ }
@@ -1,9 +1,8 @@
1
- import { LookupFailureNote } from '@skyhook-io/k8s-ui/components/resources/renderers/LookupFailureNote'
2
1
  import { VeleroBackupRenderer as BaseVeleroBackupRenderer } from '@skyhook-io/k8s-ui/components/resources/renderers/VeleroBackupRenderer'
3
- import { resolveBackupStorageLocation } from '@skyhook-io/k8s-ui/components/resources/resource-utils-velero'
4
- import type { ResourceRef } from '@skyhook-io/k8s-ui'
2
+ import { getBackupStorageLocation } from '@skyhook-io/k8s-ui/components/resources/resource-utils-velero'
3
+ import { useOperationalIssuesShown, type ResourceRef } from '@skyhook-io/k8s-ui'
4
+ import { useVeleroRunMessagesFetch, veleroMessagesInIssue } from '../../velero/VeleroRunMessagesHost'
5
5
  import { useResources } from '../../../api/client'
6
- import { useVeleroRunMessages } from '../../../api/policy'
7
6
 
8
7
  /**
9
8
  * Host wrapper adding the two things a Backup cannot answer from its own status:
@@ -21,55 +20,36 @@ import { useVeleroRunMessages } from '../../../api/policy'
21
20
  * this question.
22
21
  */
23
22
  export function VeleroBackupRenderer({ data, onNavigate }: { data: any; onNavigate?: (ref: ResourceRef) => void }) {
24
- const messages = useRunMessages('backups', data)
23
+ const messages = useVeleroRunMessagesFetch('backups', data)
24
+ // A failed run's messages sit with its issue, which says what is wrong.
25
+ const inIssue = veleroMessagesInIssue(data, useOperationalIssuesShown())
25
26
  const namespace = data?.metadata?.namespace ?? ''
26
27
 
28
+ // An unset spec.storageLocation means Velero has not processed the backup
29
+ // yet; there is no location to look up until it does.
30
+ const name = getBackupStorageLocation(data)
27
31
  const locations = useResources<any>('backupstoragelocations', namespace, 'velero.io', {
28
- enabled: !!namespace,
32
+ enabled: !!namespace && !!name,
29
33
  })
30
34
 
31
- // Everything below is gated on the lookup having answered. A location we have
32
- // not read is not a healthy one, and neither is a name we have not resolved:
33
- // an unset spec.storageLocation means whichever location carries spec.default,
34
- // so resolving it against a list that has not loaded produces the literal
35
- // "default", which is wrong on any install that renamed it — and wrong
36
- // permanently when the list errors rather than for a moment.
37
- const answered = !locations.isLoading && !locations.error && locations.data !== undefined
38
- const resolved = answered ? resolveBackupStorageLocation(data, locations.data) : undefined
39
-
40
- const match = answered
41
- ? (locations.data ?? []).find((l: any) => l?.metadata?.name === resolved)
42
- : undefined
35
+ // A location we have not read is not a healthy one, so nothing is claimed
36
+ // until the lookup answers.
37
+ const answered = !!name && !locations.isLoading && !locations.error && locations.data !== undefined
38
+ const match = answered ? (locations.data ?? []).find((l: any) => l?.metadata?.name === name) : undefined
43
39
  const phase = match?.status?.phase
44
40
 
45
41
  // The location the backup names is gone. Velero restores from the location
46
42
  // recorded on the backup, so this is not restorable — and it is invisible
47
43
  // otherwise, because a location that does not exist has no phase to report.
48
- const missing = answered && !!resolved && match === undefined
44
+ const missing = answered && match === undefined
49
45
 
50
46
  return (
51
47
  <BaseVeleroBackupRenderer
52
48
  data={data}
53
49
  storageLocationPhase={phase}
54
- storageLocationName={resolved}
55
50
  storageLocationMissing={missing}
56
- messages={messages}
51
+ messages={inIssue ? undefined : messages}
57
52
  onNavigate={onNavigate}
58
53
  />
59
54
  )
60
55
  }
61
-
62
- // The messages behind the counts. Nothing is fetched until the operator asks:
63
- // reading them makes Velero create a DownloadRequest and pulls an object out of
64
- // storage, which is not work to do on every drawer open.
65
- function useRunMessages(kind: 'backups' | 'restores', data: any) {
66
- const namespace = data?.metadata?.namespace ?? ''
67
- const name = data?.metadata?.name ?? ''
68
- const fetcher = useVeleroRunMessages(kind, namespace, name)
69
- return {
70
- messages: fetcher.data,
71
- loading: fetcher.isPending,
72
- lookupNote: fetcher.error ? <LookupFailureNote errors={[fetcher.error]} what="the messages behind these counts" /> : undefined,
73
- onFetch: namespace && name ? () => fetcher.mutate() : undefined,
74
- }
75
- }
@@ -1,7 +1,6 @@
1
- import { LookupFailureNote } from '@skyhook-io/k8s-ui/components/resources/renderers/LookupFailureNote'
2
1
  import { VeleroRestoreRenderer as BaseVeleroRestoreRenderer } from '@skyhook-io/k8s-ui/components/resources/renderers/VeleroRestoreRenderer'
3
- import type { ResourceRef } from '@skyhook-io/k8s-ui'
4
- import { useVeleroRunMessages } from '../../../api/policy'
2
+ import { useOperationalIssuesShown, type ResourceRef } from '@skyhook-io/k8s-ui'
3
+ import { useVeleroRunMessagesFetch, veleroMessagesInIssue } from '../../velero/VeleroRunMessagesHost'
5
4
 
6
5
  /**
7
6
  * Host wrapper adding the messages behind the run's error and warning counts.
@@ -16,20 +15,8 @@ import { useVeleroRunMessages } from '../../../api/policy'
16
15
  * object out of storage. Same bargain as the network trace's probes.
17
16
  */
18
17
  export function VeleroRestoreRenderer({ data, onNavigate }: { data: any; onNavigate?: (ref: ResourceRef) => void }) {
19
- const namespace = data?.metadata?.namespace ?? ''
20
- const name = data?.metadata?.name ?? ''
21
- const fetcher = useVeleroRunMessages('restores', namespace, name)
22
-
23
- return (
24
- <BaseVeleroRestoreRenderer
25
- data={data}
26
- onNavigate={onNavigate}
27
- messages={{
28
- messages: fetcher.data,
29
- loading: fetcher.isPending,
30
- lookupNote: fetcher.error ? <LookupFailureNote errors={[fetcher.error]} what="the messages behind these counts" /> : undefined,
31
- onFetch: namespace && name ? () => fetcher.mutate() : undefined,
32
- }}
33
- />
34
- )
18
+ const messages = useVeleroRunMessagesFetch('restores', data)
19
+ // A failed run's messages sit with its issue, which says what is wrong.
20
+ const inIssue = veleroMessagesInIssue(data, useOperationalIssuesShown())
21
+ return <BaseVeleroRestoreRenderer data={data} onNavigate={onNavigate} messages={inIssue ? undefined : messages} />
35
22
  }
@@ -8,6 +8,7 @@ import { useQueries, useQueryClient } from '@tanstack/react-query'
8
8
  import { kindToPlural, kindToPluralWithGroup } from '@skyhook-io/k8s-ui/utils/navigation'
9
9
  import type { Relationships, ResourceRef, ResourceWithRelationships, WorkloadPodInfo } from '../../../types'
10
10
  import type { ScalerDiagnosis } from '@skyhook-io/k8s-ui/components/resources/renderers/WorkloadRenderer'
11
+ import { WorkloadVulnerabilitiesSection } from '../../vulnerabilities/WorkloadVulnerabilitiesSection'
11
12
 
12
13
  // Map plural lowercase kind to singular PascalCase for ownerReferences matching
13
14
  function getOwnerKind(kind: string): string {
@@ -21,6 +22,10 @@ function getOwnerKind(kind: string): string {
21
22
  return kindMap[kind] || kind
22
23
  }
23
24
 
25
+ // The workloads the vulnerability rollup names: a ReplicaSet's Pods are
26
+ // named by their Deployment, so a ReplicaSet drawer has no section.
27
+ const VULNERABILITY_KINDS = new Set(['Deployment', 'StatefulSet', 'DaemonSet'])
28
+
24
29
  interface WorkloadRendererProps {
25
30
  kind: string
26
31
  data: any
@@ -99,6 +104,9 @@ export function WorkloadRenderer({ kind, data, onNavigate, scaleBlockedBy, workl
99
104
  policyLoading={policyLoading}
100
105
  policyError={policyError as Error | null}
101
106
  namespaceLimitRangeNames={limitRangesReady ? podLimitRangeNames(limitRanges) : undefined}
107
+ vulnerabilitySection={VULNERABILITY_KINDS.has(getOwnerKind(kind)) && metadata.name ? (
108
+ <WorkloadVulnerabilitiesSection kind={getOwnerKind(kind)} namespace={namespace} name={metadata.name} />
109
+ ) : undefined}
102
110
  scaleBlockedBy={scaleBlockedBy}
103
111
  workloadPods={workloadPods}
104
112
  scalerDiagnostics={scalerDiagnostics}