@skyhook-io/radar-app 1.17.1 → 1.18.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.
- package/package.json +9 -9
- package/src/App.tsx +14 -30
- package/src/api/client.gitopsPoll.test.ts +99 -0
- package/src/api/client.helmPreview.test.tsx +48 -0
- package/src/api/client.resourceAvailability.test.ts +24 -0
- package/src/api/client.ts +337 -87
- package/src/api/client.workloadRuns.test.ts +53 -0
- package/src/api/config.test.ts +23 -1
- package/src/api/config.ts +7 -3
- package/src/api/diagnose.ts +4 -1
- package/src/api/drain-plan.test.ts +70 -40
- package/src/api/policy.ts +5 -5
- package/src/api/radarFeatures.ts +1 -0
- package/src/api/traffic.scope.render.test.tsx +60 -0
- package/src/api/traffic.ts +3 -1
- package/src/components/cnpg/CNPGSummaryHost.tsx +4 -3
- package/src/components/diagnose/DiagnoseSurface.tsx +3 -3
- package/src/components/diagnose/InvestigationChangesEvidence.test.tsx +352 -0
- package/src/components/diagnose/InvestigationEvidencePane.test.tsx +101 -0
- package/src/components/diagnose/InvestigationView.tsx +2 -1
- package/src/components/diagnose/investigationEvidence/adapters/changes.test.ts +123 -0
- package/src/components/diagnose/investigationEvidence/adapters/changes.ts +192 -3
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +73 -51
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +64 -2
- package/src/components/diagnose/investigationEvidence/adapters/resource.test.ts +37 -0
- package/src/components/diagnose/investigationEvidence/adapters/testdata/get-changes-created.json +323 -0
- package/src/components/diagnose/investigationEvidence/bodies/streams.tsx +144 -15
- package/src/components/diagnose/investigationEvidence/observations.ts +20 -0
- package/src/components/diagnose/investigationEvidence/parse.ts +57 -1
- package/src/components/diagnose/investigationEvidence/projection.test.ts +107 -0
- package/src/components/diagnose/investigationEvidence/types.ts +11 -0
- package/src/components/diagnose/investigationEvidencePresentation.test.ts +18 -0
- package/src/components/diagnose/investigationState.test.ts +36 -1
- package/src/components/diagnose/investigationState.ts +8 -0
- package/src/components/diagnose/launch.ts +2 -2
- package/src/components/dock/BottomDock.tsx +6 -3
- package/src/components/dock/WorkloadLogsTab.tsx +3 -0
- package/src/components/execution/BatchExecutionView.render.test.tsx +29 -1
- package/src/components/execution/BatchExecutionView.tsx +23 -8
- package/src/components/execution/cluster-template-runs.render.test.tsx +42 -0
- package/src/components/gitops/GitOpsView.tsx +7 -0
- package/src/components/helm/HelmReleaseDrawer.tsx +139 -55
- package/src/components/helm/HelmReleaseNotes.test.tsx +42 -0
- package/src/components/helm/HelmReleaseNotes.tsx +26 -0
- package/src/components/helm/OwnedResources.tsx +2 -2
- package/src/components/helm/TrackChartSourceDialog.render.test.tsx +76 -4
- package/src/components/helm/TrackChartSourceDialog.test.ts +3 -2
- package/src/components/helm/TrackChartSourceDialog.tsx +41 -15
- package/src/components/helm/ValuesDiffPreview.tsx +4 -1
- package/src/components/home/ClusterHealthCard.tsx +4 -4
- package/src/components/home/CostCard.test.tsx +100 -0
- package/src/components/home/CostCard.tsx +2 -2
- package/src/components/home/HelmSummary.tsx +2 -2
- package/src/components/home/HomeView.tsx +15 -6
- package/src/components/home/MCPSetupDialog.test.tsx +30 -0
- package/src/components/home/MCPSetupDialog.tsx +13 -6
- package/src/components/home/ProblemsPanel.test.tsx +1 -0
- package/src/components/home/mcpToolCatalog.ts +18 -2
- package/src/components/issues/IssuesPane.render.test.tsx +21 -0
- package/src/components/issues/IssuesPane.tsx +31 -7
- package/src/components/issues/UncheckedSourceHelp.test.tsx +42 -0
- package/src/components/issues/UncheckedSourceHelp.tsx +24 -0
- package/src/components/issues/uncheckedSources.test.ts +43 -0
- package/src/components/issues/uncheckedSources.ts +58 -5
- package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +4 -2
- package/src/components/resources/ImageFilesystemModal.test.tsx +68 -0
- package/src/components/resources/ImageFilesystemModal.tsx +11 -4
- package/src/components/resources/PodFilesystemModal.tsx +2 -2
- package/src/components/resources/ResourcesView.scope.render.test.tsx +58 -0
- package/src/components/resources/ResourcesView.tsx +18 -3
- package/src/components/resources/renderers/FluxHelmReleaseRenderer.test.tsx +111 -0
- package/src/components/resources/renderers/FluxHelmReleaseRenderer.tsx +67 -0
- package/src/components/resources/renderers/KyvernoPolicyCoverage.scope.render.test.tsx +64 -0
- package/src/components/resources/renderers/KyvernoPolicyCoverage.tsx +6 -7
- package/src/components/settings/SettingsDialog.tsx +21 -15
- package/src/components/traffic/TrafficFilterSidebar.test.tsx +77 -0
- package/src/components/traffic/TrafficFilterSidebar.tsx +42 -31
- package/src/components/traffic/TrafficView.tsx +12 -12
- package/src/components/traffic/trafficFilters.test.ts +20 -1
- package/src/components/traffic/trafficFilters.ts +13 -0
- package/src/components/ui/Omnibar.tsx +13 -2
- package/src/components/ui/Toast.tsx +1 -1
- package/src/components/ui/omnibar-match.test.ts +30 -0
- package/src/components/ui/omnibar-match.ts +18 -0
- package/src/components/workload/CronJobSchedulingEvidence.test.tsx +35 -0
- package/src/components/workload/CronJobSchedulingEvidence.tsx +37 -0
- package/src/components/workload/NodeDrainStatus.test.tsx +253 -0
- package/src/components/workload/NodeDrainStatus.tsx +55 -0
- package/src/components/workload/WorkloadView.tsx +37 -5
- package/src/context/ConnectionContext.test.ts +27 -1
- package/src/context/ConnectionContext.tsx +17 -7
- package/src/integrations/resourceHosts.test.tsx +1 -0
- package/src/integrations/resourceHosts.tsx +2 -0
- package/src/utils/navigation.ts +14 -0
- package/src/utils/wails-clipboard.ts +4 -2
|
@@ -8,6 +8,7 @@ import { Disclosure } from '@skyhook-io/k8s-ui/components/ui/Disclosure'
|
|
|
8
8
|
interface MCPSetupDialogProps {
|
|
9
9
|
open: boolean
|
|
10
10
|
onClose: () => void
|
|
11
|
+
readOnly?: boolean
|
|
11
12
|
mcpUrl: string
|
|
12
13
|
}
|
|
13
14
|
|
|
@@ -43,7 +44,7 @@ function CodeBlock({ children }: { children: string }) {
|
|
|
43
44
|
)
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
export function MCPSetupDialog({ open, onClose, mcpUrl }: MCPSetupDialogProps) {
|
|
47
|
+
export function MCPSetupDialog({ open, onClose, mcpUrl, readOnly = false }: MCPSetupDialogProps) {
|
|
47
48
|
const dialogRef = useRef<HTMLDivElement>(null)
|
|
48
49
|
const [isDesktop, setIsDesktop] = useState(false)
|
|
49
50
|
const [portPinned, setPortPinned] = useState(false)
|
|
@@ -116,6 +117,12 @@ export function MCPSetupDialog({ open, onClose, mcpUrl }: MCPSetupDialogProps) {
|
|
|
116
117
|
|
|
117
118
|
const currentPort = Number(window.location.port) || 80
|
|
118
119
|
|
|
120
|
+
const tools = MCP_TOOL_CATALOG
|
|
121
|
+
.filter((tool) => !readOnly || !tool.write)
|
|
122
|
+
.map((tool) => readOnly && tool.name === 'diagnose'
|
|
123
|
+
? { ...tool, params: tool.params.filter((param) => param.arg !== 'in_cluster') }
|
|
124
|
+
: tool)
|
|
125
|
+
|
|
119
126
|
const mcpServersUrlConfig = (key: 'url' | 'serverUrl') => JSON.stringify({
|
|
120
127
|
mcpServers: {
|
|
121
128
|
radar: {
|
|
@@ -210,17 +217,17 @@ export function MCPSetupDialog({ open, onClose, mcpUrl }: MCPSetupDialogProps) {
|
|
|
210
217
|
<a href="https://modelcontextprotocol.io" target="_blank" rel="noopener noreferrer" className="text-purple-400 hover:text-purple-300 underline underline-offset-2">
|
|
211
218
|
Model Context Protocol
|
|
212
219
|
</a>{' '}
|
|
213
|
-
(MCP) server that lets AI agents inspect, investigate, and operate your cluster through Radar.
|
|
220
|
+
(MCP) server that lets AI agents {readOnly ? 'inspect and investigate' : 'inspect, investigate, and operate'} your cluster through Radar.
|
|
214
221
|
Unlike raw kubectl access, Radar gives your AI pre-processed, enriched data —
|
|
215
222
|
topology graphs, health assessments, deduplicated events, filtered logs — so it
|
|
216
223
|
can understand your cluster state quickly without burning through context on
|
|
217
224
|
verbose YAML output.
|
|
218
225
|
</p>
|
|
219
226
|
<p className="text-sm text-theme-text-secondary leading-relaxed">
|
|
220
|
-
Most read tools do not change cluster state. An in-cluster route probe can create up
|
|
227
|
+
{readOnly ? 'Read-only mode blocks write tools and diagnostic options that create temporary Kubernetes resources. It does not restrict the Radar UI or REST API.' : <>Most read tools do not change cluster state. An in-cluster route probe can create up
|
|
221
228
|
to five self-deleting probe pods when explicitly requested. Write tools (restart,
|
|
222
229
|
scale, sync, apply, node drain) are annotated as destructive so your AI client
|
|
223
|
-
can flag them and prompt before running
|
|
230
|
+
can flag them and prompt before running.</>}
|
|
224
231
|
</p>
|
|
225
232
|
</div>
|
|
226
233
|
|
|
@@ -319,10 +326,10 @@ export function MCPSetupDialog({ open, onClose, mcpUrl }: MCPSetupDialogProps) {
|
|
|
319
326
|
<div className="space-y-2">
|
|
320
327
|
<div className="flex items-baseline justify-between">
|
|
321
328
|
<h4 className="text-sm font-semibold text-theme-text-primary">Tools</h4>
|
|
322
|
-
<span className="text-[11px] text-theme-text-tertiary">{
|
|
329
|
+
<span className="text-[11px] text-theme-text-tertiary">{tools.length} tools</span>
|
|
323
330
|
</div>
|
|
324
331
|
<div className="grid grid-cols-1 gap-1.5">
|
|
325
|
-
{
|
|
332
|
+
{tools.map((tool) => (
|
|
326
333
|
<div key={tool.name} className="card-inner space-y-1.5">
|
|
327
334
|
<div className="flex items-center gap-2">
|
|
328
335
|
<code className="inline-code text-[11px]">{tool.name}</code>
|
|
@@ -20,6 +20,7 @@ function render(props: { issues?: Issue[]; unchecked?: IssuesResponse['unchecked
|
|
|
20
20
|
issues={issues}
|
|
21
21
|
issueCount={issues.length}
|
|
22
22
|
uncheckedLines={uncheckedSourceLines(props.unchecked)}
|
|
23
|
+
onRetryIssues={() => {}}
|
|
23
24
|
visibility={props.visibility}
|
|
24
25
|
hasData
|
|
25
26
|
isLoading={false}
|
|
@@ -373,13 +373,29 @@ export const MCP_TOOL_CATALOG: MCPToolInfo[] = [
|
|
|
373
373
|
{
|
|
374
374
|
name: 'manage_node',
|
|
375
375
|
write: true,
|
|
376
|
-
desc: '
|
|
376
|
+
desc: 'Cordon, uncordon, or drain a node. Drain waits for required pod deletions by default and reports complete, incomplete, unconfirmed or started. Expected exclusions do not prevent completion. Completion does not certify shutdown safety.',
|
|
377
377
|
params: [
|
|
378
378
|
{ arg: 'action', required: true, desc: 'cordon, uncordon, or drain' },
|
|
379
379
|
{ arg: 'name', required: true, desc: 'node name' },
|
|
380
380
|
{ arg: 'delete_empty_dir_data', desc: 'evict pods with emptyDir volumes (default true)' },
|
|
381
381
|
{ arg: 'force', desc: 'evict pods not managed by a controller (default false)' },
|
|
382
|
-
{ arg: '
|
|
382
|
+
{ arg: 'wait_for_deletion', desc: 'wait for pod deletion (default true); false returns after eviction acceptance' },
|
|
383
|
+
{ arg: 'timeout', desc: 'shared eviction and deletion deadline in seconds (default 120 when waiting, 60 otherwise)' },
|
|
384
|
+
],
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
name: 'wait_for',
|
|
388
|
+
desc: 'Wait after a fix for a rollout, readiness, completion, deletion, or a status condition. Each call waits at most 45s and returns met, waiting, blocked, or failed; call again within your own time limit.',
|
|
389
|
+
params: [
|
|
390
|
+
{ arg: 'kind', required: true, desc: 'resource kind, including CRDs' },
|
|
391
|
+
{ arg: 'name', desc: 'object name; or set label_selector or all' },
|
|
392
|
+
{ arg: 'uid', desc: 'with name: pin to the uid returned by a previous call' },
|
|
393
|
+
{ arg: 'label_selector', desc: "every current match; to wait for replacements, wait on their controller's rollout" },
|
|
394
|
+
{ arg: 'all', desc: 'every object of the kind in the namespace' },
|
|
395
|
+
{ arg: 'namespace', desc: 'namespace for namespaced kinds' },
|
|
396
|
+
{ arg: 'group', desc: 'API group when the kind is ambiguous' },
|
|
397
|
+
{ arg: 'condition', desc: 'rollout, complete, ready, deleted, Type[=Status], or jsonpath={.status.path}=value; defaults by kind' },
|
|
398
|
+
{ arg: 'timeout_seconds', desc: '1-45 seconds (default 45); larger values wait 45' },
|
|
383
399
|
],
|
|
384
400
|
},
|
|
385
401
|
]
|
|
@@ -95,6 +95,27 @@ describe('Issues page when Radar could not read Helm releases', () => {
|
|
|
95
95
|
expect(html).toContain('The selected Pod keeps crashing')
|
|
96
96
|
})
|
|
97
97
|
|
|
98
|
+
it.each([true, false])('keeps the last unchecked result and retry after a failed refresh (rows: %s)', (hasRows) => {
|
|
99
|
+
state.fleet.data = { issues: hasRows ? [issue] : [], unchecked_sources: [{ source: 'helm', reason: 'read_failed' }] }
|
|
100
|
+
state.fleet.error = new Error('Refresh unavailable')
|
|
101
|
+
const html = text(render('/issues'))
|
|
102
|
+
expect(html).toContain('Issue refresh failed. Showing the last successful result.')
|
|
103
|
+
expect(html).toContain(line)
|
|
104
|
+
expect(html).toContain('Check again')
|
|
105
|
+
expect(html).not.toContain('Failed to load issues')
|
|
106
|
+
expect(html).not.toContain('Nothing broken right now')
|
|
107
|
+
if (hasRows) expect(html).toContain('The selected Pod keeps crashing')
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
it('does not show an all-clear from a cached empty result after refresh fails', () => {
|
|
111
|
+
state.fleet.data = { issues: [], total: 0 }
|
|
112
|
+
state.fleet.error = new Error('Refresh unavailable')
|
|
113
|
+
const html = text(render('/issues'))
|
|
114
|
+
expect(html).toContain('No issues in the last successful result')
|
|
115
|
+
expect(html).not.toContain('Nothing broken right now')
|
|
116
|
+
expect(html).not.toContain('Failed to load issues')
|
|
117
|
+
})
|
|
118
|
+
|
|
98
119
|
it('shows no all-clear for a source this version does not know, with a generic line', () => {
|
|
99
120
|
state.fleet.data = { issues: [], total: 0, total_matched: 0, unchecked_sources: [{ source: 'some-new-source', reason: 'read_failed' }] }
|
|
100
121
|
const html = text(render('/issues'))
|
|
@@ -26,6 +26,7 @@ import { builtinGroupForKind } from "@skyhook-io/k8s-ui/utils/api-resources";
|
|
|
26
26
|
import { AlertTriangle } from "lucide-react";
|
|
27
27
|
import { IssueDiagnoseButton } from "../diagnose/LocalDiagnoseAction";
|
|
28
28
|
import { uncheckedSourceLines } from "./uncheckedSources";
|
|
29
|
+
import { UncheckedSourceHelp } from "./UncheckedSourceHelp";
|
|
29
30
|
|
|
30
31
|
// A capacity-relevant issue links to its Karpenter diagnosis. Karpenter is
|
|
31
32
|
// always single-cluster (unlike Argo hub-and-spoke), so the issue and the
|
|
@@ -181,7 +182,7 @@ export function IssuesPane({
|
|
|
181
182
|
}: IssuesPaneProps) {
|
|
182
183
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
183
184
|
const subject = useMemo(() => issueSubjectFromParams(searchParams), [searchParams]);
|
|
184
|
-
const { data, isLoading, error, dataUpdatedAt, refetch } =
|
|
185
|
+
const { data, isLoading, isFetching, error, dataUpdatedAt, refetch } =
|
|
185
186
|
useIssues(namespaces, !subject);
|
|
186
187
|
const { connection } = useConnection();
|
|
187
188
|
const navigate = useNavigate();
|
|
@@ -246,7 +247,7 @@ export function IssuesPane({
|
|
|
246
247
|
return <PaneLoader label="Loading issues…" className="flex-1" />;
|
|
247
248
|
}
|
|
248
249
|
|
|
249
|
-
if (!subject && error) {
|
|
250
|
+
if (!subject && error && !data) {
|
|
250
251
|
return (
|
|
251
252
|
<div className="flex-1 flex items-center justify-center text-theme-text-secondary">
|
|
252
253
|
<p>Failed to load issues</p>
|
|
@@ -295,6 +296,13 @@ export function IssuesPane({
|
|
|
295
296
|
}
|
|
296
297
|
/>
|
|
297
298
|
|
|
299
|
+
{!subject && error && (
|
|
300
|
+
<div className="flex items-start gap-2 rounded-lg border border-theme-border bg-theme-elevated px-3 py-2 text-xs text-theme-text-secondary">
|
|
301
|
+
<AlertTriangle className="mt-0.5 h-4 w-4 shrink-0 text-amber-500" aria-hidden />
|
|
302
|
+
<span>Issue refresh failed. Showing the last successful result.</span>
|
|
303
|
+
</div>
|
|
304
|
+
)}
|
|
305
|
+
|
|
298
306
|
{/* Visibility honesty: when RBAC reads are incomplete, an empty queue may
|
|
299
307
|
mean "can't see" rather than "nothing broken" — say so up front so the
|
|
300
308
|
empty state isn't mistaken for a clean bill of health. */}
|
|
@@ -311,12 +319,15 @@ export function IssuesPane({
|
|
|
311
319
|
{/* Unchecked-source honesty: the rows can't include issues from a
|
|
312
320
|
source Radar couldn't check. With no rows the empty state below says
|
|
313
321
|
it instead. */}
|
|
314
|
-
{scopeIssues.length > 0 && uncheckedLines.
|
|
315
|
-
<div
|
|
322
|
+
{scopeIssues.length > 0 && uncheckedLines.length > 0 && (
|
|
323
|
+
<div className="flex items-start gap-2 rounded-lg border border-theme-border bg-theme-elevated px-3 py-2 text-xs text-theme-text-secondary">
|
|
316
324
|
<AlertTriangle className="mt-0.5 h-4 w-4 shrink-0 text-amber-500" />
|
|
317
|
-
<
|
|
325
|
+
<div className="min-w-0 flex-1">
|
|
326
|
+
{uncheckedLines.map((line) => <p key={line}>{line}</p>)}
|
|
327
|
+
<UncheckedSourceHelp onRetry={() => { void refetch({ cancelRefetch: false }); }} isRefreshing={isFetching} />
|
|
328
|
+
</div>
|
|
318
329
|
</div>
|
|
319
|
-
)
|
|
330
|
+
)}
|
|
320
331
|
|
|
321
332
|
{/* Truncation honesty: when more issues matched than were returned, say
|
|
322
333
|
so — don't present a capped list as the complete picture. */}
|
|
@@ -385,7 +396,20 @@ export function IssuesPane({
|
|
|
385
396
|
</button>
|
|
386
397
|
</div>
|
|
387
398
|
) : uncheckedLines.length > 0 && scopeIssues.length === 0 ? (
|
|
388
|
-
<EmptyState
|
|
399
|
+
<EmptyState
|
|
400
|
+
tone="neutral"
|
|
401
|
+
variant="card"
|
|
402
|
+
headline="No issues found"
|
|
403
|
+
body={uncheckedLines.join(" ")}
|
|
404
|
+
action={<UncheckedSourceHelp onRetry={() => { void refetch({ cancelRefetch: false }); }} isRefreshing={isFetching} />}
|
|
405
|
+
/>
|
|
406
|
+
) : !subject && error && scopeIssues.length === 0 ? (
|
|
407
|
+
<EmptyState
|
|
408
|
+
tone="neutral"
|
|
409
|
+
variant="card"
|
|
410
|
+
headline="No issues in the last successful result"
|
|
411
|
+
body="Current issues could not be checked."
|
|
412
|
+
/>
|
|
389
413
|
) : (
|
|
390
414
|
/* anyData = the query resolved, i.e. the cluster is reachable; an empty
|
|
391
415
|
list then means "nothing broken" rather than "not connected". */
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { expect, it, vi } from 'vitest'
|
|
5
|
+
import { UncheckedSourceHelp } from './UncheckedSourceHelp'
|
|
6
|
+
|
|
7
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
8
|
+
|
|
9
|
+
it('keeps the coverage warning visible when help closes and prevents duplicate retries', async () => {
|
|
10
|
+
const host = document.createElement('div')
|
|
11
|
+
document.body.append(host)
|
|
12
|
+
const root = createRoot(host)
|
|
13
|
+
const retry = vi.fn()
|
|
14
|
+
const render = (refreshing: boolean) => (
|
|
15
|
+
<div>
|
|
16
|
+
<p>Helm releases couldn't be checked.</p>
|
|
17
|
+
<UncheckedSourceHelp onRetry={retry} isRefreshing={refreshing} />
|
|
18
|
+
</div>
|
|
19
|
+
)
|
|
20
|
+
try {
|
|
21
|
+
await act(async () => root.render(render(false)))
|
|
22
|
+
const disclosure = host.querySelector<HTMLButtonElement>('button[aria-expanded]')
|
|
23
|
+
expect(disclosure).not.toBeNull()
|
|
24
|
+
expect(disclosure?.getAttribute('aria-expanded')).toBe('false')
|
|
25
|
+
await act(async () => disclosure?.click())
|
|
26
|
+
expect(disclosure?.getAttribute('aria-expanded')).toBe('true')
|
|
27
|
+
const button = [...host.querySelectorAll('button')].find((b) => b.textContent === 'Check again')
|
|
28
|
+
expect(button).toBeDefined()
|
|
29
|
+
await act(async () => button?.click())
|
|
30
|
+
expect(retry).toHaveBeenCalledTimes(1)
|
|
31
|
+
await act(async () => root.render(render(true)))
|
|
32
|
+
expect(button?.disabled).toBe(true)
|
|
33
|
+
await act(async () => button?.click())
|
|
34
|
+
expect(retry).toHaveBeenCalledTimes(1)
|
|
35
|
+
await act(async () => disclosure?.click())
|
|
36
|
+
expect(disclosure?.getAttribute('aria-expanded')).toBe('false')
|
|
37
|
+
expect(host.querySelector('p')?.textContent).toBe("Helm releases couldn't be checked.")
|
|
38
|
+
} finally {
|
|
39
|
+
await act(async () => root.unmount())
|
|
40
|
+
host.remove()
|
|
41
|
+
}
|
|
42
|
+
})
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Disclosure } from '@skyhook-io/k8s-ui'
|
|
2
|
+
|
|
3
|
+
export function UncheckedSourceHelp({ onRetry, isRefreshing }: { onRetry: () => void; isRefreshing: boolean }) {
|
|
4
|
+
return (
|
|
5
|
+
<Disclosure
|
|
6
|
+
summary="Why is this shown?"
|
|
7
|
+
className="mt-2 text-left text-xs text-theme-text-secondary"
|
|
8
|
+
summaryClassName="min-h-9 text-accent-text hover:underline"
|
|
9
|
+
>
|
|
10
|
+
<div className="space-y-2 pt-2 leading-5">
|
|
11
|
+
<p>Some checks didn’t return a usable result. Issues found by other checks are still shown.</p>
|
|
12
|
+
<p>Radar checks again automatically. If this keeps happening, check Radar’s connection and access to Kubernetes.</p>
|
|
13
|
+
<button
|
|
14
|
+
type="button"
|
|
15
|
+
onClick={onRetry}
|
|
16
|
+
disabled={isRefreshing}
|
|
17
|
+
className="btn-secondary min-h-9 min-w-32 px-2.5 py-1 font-medium disabled:cursor-not-allowed"
|
|
18
|
+
>
|
|
19
|
+
{isRefreshing ? 'Checking again…' : 'Check again'}
|
|
20
|
+
</button>
|
|
21
|
+
</div>
|
|
22
|
+
</Disclosure>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { UNKNOWN_SOURCE_LINE, uncheckedSourceLines } from './uncheckedSources'
|
|
3
|
+
|
|
4
|
+
describe('uncheckedSourceLines', () => {
|
|
5
|
+
it('names the kinds still loading', () => {
|
|
6
|
+
expect(uncheckedSourceLines([{
|
|
7
|
+
source: 'resources', reason: 'kind_sync_pending',
|
|
8
|
+
kinds: [{ group: 'autoscaling', kind: 'HorizontalPodAutoscaler' }, { kind: 'PersistentVolumeClaim' }],
|
|
9
|
+
}])).toEqual(['Still loading HorizontalPodAutoscalers and PersistentVolumeClaims, so their issues may be missing.'])
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
it('caps a long kind list', () => {
|
|
13
|
+
const kinds = ['Pod', 'Node', 'Service', 'Secret', 'ConfigMap'].map((kind) => ({ kind }))
|
|
14
|
+
expect(uncheckedSourceLines([{ source: 'resources', reason: 'kind_sync_failed', kinds }]))
|
|
15
|
+
.toEqual(["Pods, Nodes and 3 more couldn't be loaded, so their issues may be missing."])
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('says custom resources are loading when no kind can be named', () => {
|
|
19
|
+
expect(uncheckedSourceLines([{ source: 'custom_resources', reason: 'kind_sync_pending' }]))
|
|
20
|
+
.toEqual(['Custom resources are still loading, so failing ones may be missing.'])
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('names the Helm namespaces that failed, so the rest reads as checked', () => {
|
|
24
|
+
expect(uncheckedSourceLines([{ source: 'helm', reason: 'read_failed', namespaces: ['payments'] }]))
|
|
25
|
+
.toEqual(["Helm releases in payments couldn't be checked, so failed or stuck releases there may be missing."])
|
|
26
|
+
expect(uncheckedSourceLines([{ source: 'helm', reason: 'read_failed', namespaces: ['a', 'b'] }]))
|
|
27
|
+
.toEqual(["Helm releases in 2 namespaces (a and b) couldn't be checked, so failed or stuck releases there may be missing."])
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it("says when Radar's own service account is the problem", () => {
|
|
31
|
+
expect(uncheckedSourceLines([{ source: 'helm', reason: 'collector_access_denied' }]))
|
|
32
|
+
.toEqual(["Helm releases couldn't be checked because Radar's service account isn't allowed to impersonate users, so failed or stuck releases may be missing."])
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('falls back to the source line for a reason this version does not know', () => {
|
|
36
|
+
expect(uncheckedSourceLines([{ source: 'karpenter', reason: 'something_new' }]))
|
|
37
|
+
.toEqual(["Karpenter resources couldn't be checked, so NodePool and NodeClaim issues may be missing."])
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('keeps the generic line for an unknown source', () => {
|
|
41
|
+
expect(uncheckedSourceLines([{ source: 'brand_new', reason: 'read_failed' }])).toEqual([UNKNOWN_SOURCE_LINE])
|
|
42
|
+
})
|
|
43
|
+
})
|
|
@@ -1,20 +1,73 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { englishPlural } from "@skyhook-io/k8s-ui/utils/pluralize";
|
|
2
|
+
import type { IssuesResponse, UncheckedSource } from "../../api/client";
|
|
2
3
|
|
|
3
|
-
// The issue
|
|
4
|
-
//
|
|
4
|
+
// The line each issue source gets wherever Radar's issues would otherwise read
|
|
5
|
+
// as complete, when nothing more specific can be said about the gap.
|
|
5
6
|
const SOURCE_LINES: Record<string, string> = {
|
|
6
7
|
helm: "Helm releases couldn't be checked, so failed or stuck releases may be missing.",
|
|
8
|
+
resources: "Some resources couldn't be checked, so their issues may be missing.",
|
|
9
|
+
custom_resources: "Custom resources couldn't be checked, so failing ones may be missing.",
|
|
10
|
+
karpenter: "Karpenter resources couldn't be checked, so NodePool and NodeClaim issues may be missing.",
|
|
7
11
|
};
|
|
8
12
|
|
|
9
13
|
// For a source this version doesn't know, sent by a newer Radar.
|
|
10
14
|
export const UNKNOWN_SOURCE_LINE = "Some issue checks couldn't run, so issues may be missing.";
|
|
11
15
|
|
|
16
|
+
const NAMED_LIMIT = 3;
|
|
17
|
+
|
|
18
|
+
/** "A", "A and B", "A, B and C", "A, B and 4 more". */
|
|
19
|
+
function nameList(names: string[]): string {
|
|
20
|
+
if (names.length <= NAMED_LIMIT) {
|
|
21
|
+
return names.length === 1 ? names[0] : `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}`;
|
|
22
|
+
}
|
|
23
|
+
return `${names.slice(0, NAMED_LIMIT - 1).join(", ")} and ${names.length - (NAMED_LIMIT - 1)} more`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function helmLine({ reason, namespaces }: UncheckedSource): string {
|
|
27
|
+
const where = namespaces?.length
|
|
28
|
+
? namespaces.length === 1
|
|
29
|
+
? `in ${namespaces[0]} `
|
|
30
|
+
: `in ${namespaces.length} namespaces (${nameList(namespaces)}) `
|
|
31
|
+
: "";
|
|
32
|
+
const missing = where ? "failed or stuck releases there may be missing" : "failed or stuck releases may be missing";
|
|
33
|
+
if (reason === "collector_access_denied") {
|
|
34
|
+
return `Helm releases ${where}couldn't be checked because Radar's service account isn't allowed to impersonate users, so ${missing}.`;
|
|
35
|
+
}
|
|
36
|
+
return `Helm releases ${where}couldn't be checked, so ${missing}.`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function kindsLine(source: UncheckedSource): string | undefined {
|
|
40
|
+
const kinds = [...new Set((source.kinds ?? []).map((k) => englishPlural(k.kind)))];
|
|
41
|
+
if (kinds.length === 0) {
|
|
42
|
+
if (source.source === "custom_resources" && source.reason === "kind_sync_pending") {
|
|
43
|
+
return "Custom resources are still loading, so failing ones may be missing.";
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
const names = nameList(kinds);
|
|
48
|
+
switch (source.reason) {
|
|
49
|
+
case "kind_sync_pending":
|
|
50
|
+
return `Still loading ${names}, so their issues may be missing.`;
|
|
51
|
+
case "kind_sync_failed":
|
|
52
|
+
return `${names} couldn't be loaded, so their issues may be missing.`;
|
|
53
|
+
default:
|
|
54
|
+
return `${names} couldn't be checked, so their issues may be missing.`;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function lineFor(source: UncheckedSource): string | undefined {
|
|
59
|
+
if (!Object.hasOwn(SOURCE_LINES, source.source)) return undefined;
|
|
60
|
+
if (source.source === "helm") return helmLine(source);
|
|
61
|
+
return kindsLine(source) ?? SOURCE_LINES[source.source];
|
|
62
|
+
}
|
|
63
|
+
|
|
12
64
|
/** One line per unchecked source, known sources first, without repeats. */
|
|
13
65
|
export function uncheckedSourceLines(sources: IssuesResponse["unchecked_sources"]): string[] {
|
|
14
66
|
const known = new Set<string>();
|
|
15
67
|
let unknown = false;
|
|
16
|
-
for (const
|
|
17
|
-
|
|
68
|
+
for (const source of sources ?? []) {
|
|
69
|
+
const line = lineFor(source);
|
|
70
|
+
if (line) known.add(line);
|
|
18
71
|
else unknown = true;
|
|
19
72
|
}
|
|
20
73
|
return unknown ? [...known, UNKNOWN_SOURCE_LINE] : [...known];
|
|
@@ -11,6 +11,8 @@ interface ScheduledWorkloadLogsViewerProps {
|
|
|
11
11
|
name: string
|
|
12
12
|
selectedRunKey?: string
|
|
13
13
|
onSelectRun?: (runKey: string) => void
|
|
14
|
+
/** The view's namespace selection; narrows a cluster-scoped template's runs. */
|
|
15
|
+
viewNamespaces?: string[]
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
const EMPTY_RUNS: WorkloadRun[] = []
|
|
@@ -19,7 +21,7 @@ export function ScheduledWorkloadLogsViewer(props: ScheduledWorkloadLogsViewerPr
|
|
|
19
21
|
return <ScheduledWorkloadLogsContent key={JSON.stringify([props.kind, props.namespace, props.name])} {...props} />
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
function ScheduledWorkloadLogsContent({ kind, namespace, name, selectedRunKey, onSelectRun }: ScheduledWorkloadLogsViewerProps) {
|
|
24
|
+
function ScheduledWorkloadLogsContent({ kind, namespace, name, selectedRunKey, onSelectRun, viewNamespaces }: ScheduledWorkloadLogsViewerProps) {
|
|
23
25
|
const clusterScoped = kind === 'ClusterWorkflowTemplate' || kind === 'clusterworkflowtemplates'
|
|
24
26
|
const jobSet = kind.toLowerCase() === 'jobset' || kind.toLowerCase() === 'jobsets'
|
|
25
27
|
const [localRunKey, setLocalRunKey] = useState('')
|
|
@@ -28,7 +30,7 @@ function ScheduledWorkloadLogsContent({ kind, namespace, name, selectedRunKey, o
|
|
|
28
30
|
const [scope, setScope] = useState('selected')
|
|
29
31
|
const [role, setRole] = useState('')
|
|
30
32
|
const rootQuery = useResource<any>('jobsets', namespace, name, 'jobset.x-k8s.io', { enabled: jobSet })
|
|
31
|
-
const runsQuery = useWorkloadRuns(kind, namespace, name, true, { clusterScoped, refetchActive: true, ...(jobSet ? { selected: effectiveRunKey } : {}) })
|
|
33
|
+
const runsQuery = useWorkloadRuns(kind, namespace, name, true, { clusterScoped, namespaces: viewNamespaces, refetchActive: true, ...(jobSet ? { selected: effectiveRunKey } : {}) })
|
|
32
34
|
const memberCollection = runsQuery.data?.collection === 'members'
|
|
33
35
|
const runs = runsQuery.data?.runs ?? EMPTY_RUNS
|
|
34
36
|
const selectedRunFromResponse = runsQuery.data?.selected
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { afterEach, expect, it, vi } from 'vitest'
|
|
5
|
+
import { ImageFilesystemModal } from './ImageFilesystemModal'
|
|
6
|
+
import { ApiError } from '../../api/client'
|
|
7
|
+
|
|
8
|
+
const state = vi.hoisted(() => ({ authEnabled: false, showMetadata: false }))
|
|
9
|
+
vi.mock('../../contexts/CapabilitiesContext', () => ({ useIsAuthEnabled: () => state.authEnabled }))
|
|
10
|
+
vi.mock('../../api/client', () => ({
|
|
11
|
+
ApiError: class extends Error {
|
|
12
|
+
status = 401
|
|
13
|
+
data = { registryType: 'google' }
|
|
14
|
+
},
|
|
15
|
+
useImageMetadata: () => state.showMetadata ? ({
|
|
16
|
+
data: { image: 'gcr.io/project/app:v1', digest: 'sha256:abc', platform: 'linux/amd64', totalSize: 1024, layerCount: 1, authMethod: 'google', cached: false },
|
|
17
|
+
refetch: vi.fn(),
|
|
18
|
+
}) : ({ error: new ApiError('Authentication required', 401), refetch: vi.fn() }),
|
|
19
|
+
}))
|
|
20
|
+
|
|
21
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
22
|
+
let root: ReturnType<typeof createRoot>
|
|
23
|
+
|
|
24
|
+
afterEach(async () => {
|
|
25
|
+
await act(async () => root.unmount())
|
|
26
|
+
state.showMetadata = false
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it.each([true, false])('shows private-image guidance for authEnabled=%s', async (authEnabled) => {
|
|
30
|
+
state.authEnabled = authEnabled
|
|
31
|
+
root = createRoot(document.createElement('div'))
|
|
32
|
+
await act(async () => {
|
|
33
|
+
root.render(<ImageFilesystemModal open onClose={() => {}} image="gcr.io/project/app:v1" namespace="team" podName="app" pullSecrets={[]} />)
|
|
34
|
+
})
|
|
35
|
+
const text = document.body.textContent || ''
|
|
36
|
+
expect(text).toContain('Authentication Required')
|
|
37
|
+
if (authEnabled) {
|
|
38
|
+
expect(text).toContain("Private images need exec access to the Pod, or read access to its imagePullSecrets. Exec access also lets Radar use its own registry credentials.")
|
|
39
|
+
expect(text).not.toContain('~/.docker/config.json')
|
|
40
|
+
expect(text).not.toContain('Run this command to authenticate')
|
|
41
|
+
expect(text).not.toContain('gcloud')
|
|
42
|
+
} else {
|
|
43
|
+
expect(text).toContain('~/.docker/config.json')
|
|
44
|
+
expect(text).toContain('Run this command to authenticate')
|
|
45
|
+
expect(text).toContain('gcloud')
|
|
46
|
+
expect(text).not.toContain("Private images are read with the Pod's imagePullSecrets")
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it.each([true, false])('shows download confirmation for authEnabled=%s', async (authEnabled) => {
|
|
51
|
+
state.authEnabled = authEnabled
|
|
52
|
+
state.showMetadata = true
|
|
53
|
+
root = createRoot(document.createElement('div'))
|
|
54
|
+
await act(async () => {
|
|
55
|
+
root.render(<ImageFilesystemModal open onClose={() => {}} image="gcr.io/project/app:v1" namespace="team" podName="app" pullSecrets={[]} />)
|
|
56
|
+
})
|
|
57
|
+
const text = document.body.textContent || ''
|
|
58
|
+
expect(text).toContain('Download Image Layers?')
|
|
59
|
+
expect(text).toContain('Download & View')
|
|
60
|
+
if (authEnabled) {
|
|
61
|
+
expect(text).not.toContain('Authentication Command')
|
|
62
|
+
expect(text).not.toContain('gcloud')
|
|
63
|
+
expect(text).not.toContain('Run this command')
|
|
64
|
+
} else {
|
|
65
|
+
expect(text).toContain('Authentication Command')
|
|
66
|
+
expect(text).toContain('gcloud')
|
|
67
|
+
}
|
|
68
|
+
})
|
|
@@ -12,6 +12,7 @@ import { Tooltip } from '../ui/Tooltip'
|
|
|
12
12
|
import { apiUrl, getAuthHeaders, getCredentialsMode } from '../../api/config'
|
|
13
13
|
import { readErrorBody } from '../../api/httpErrors'
|
|
14
14
|
import { Input } from '@skyhook-io/k8s-ui'
|
|
15
|
+
import { useIsAuthEnabled } from '../../contexts/CapabilitiesContext'
|
|
15
16
|
|
|
16
17
|
const radarLoadingIconUrl = assetUrl(radarLoadingIcon)
|
|
17
18
|
|
|
@@ -293,8 +294,9 @@ interface DownloadConfirmationProps {
|
|
|
293
294
|
}
|
|
294
295
|
|
|
295
296
|
function DownloadConfirmation({ metadata, onConfirm, onCancel }: DownloadConfirmationProps) {
|
|
297
|
+
const authEnabled = useIsAuthEnabled()
|
|
296
298
|
const isPublic = metadata.authMethod === 'anonymous'
|
|
297
|
-
const authCommand = !isPublic ? getAuthCommand(metadata.authMethod, metadata.image) : null
|
|
299
|
+
const authCommand = !authEnabled && !isPublic ? getAuthCommand(metadata.authMethod, metadata.image) : null
|
|
298
300
|
const [copied, setCopied] = useState(false)
|
|
299
301
|
|
|
300
302
|
const handleCopy = async () => {
|
|
@@ -417,11 +419,12 @@ interface AuthenticationHelpProps {
|
|
|
417
419
|
}
|
|
418
420
|
|
|
419
421
|
function AuthenticationHelp({ image, registryType, onRetry }: AuthenticationHelpProps) {
|
|
422
|
+
const authEnabled = useIsAuthEnabled()
|
|
420
423
|
const [copied, setCopied] = useState(false)
|
|
421
424
|
const [retrying, setRetrying] = useState(false)
|
|
422
425
|
const registry = getRegistryHost(image)
|
|
423
426
|
const authMethod = registryType || 'generic'
|
|
424
|
-
const authCommand = getAuthCommand(authMethod, image)
|
|
427
|
+
const authCommand = authEnabled ? null : getAuthCommand(authMethod, image)
|
|
425
428
|
|
|
426
429
|
const handleCopy = async () => {
|
|
427
430
|
if (!authCommand) return
|
|
@@ -489,8 +492,12 @@ function AuthenticationHelp({ image, registryType, onRetry }: AuthenticationHelp
|
|
|
489
492
|
|
|
490
493
|
{/* Explanation */}
|
|
491
494
|
<p className="text-xs text-theme-text-tertiary text-center max-w-md mb-6">
|
|
492
|
-
|
|
493
|
-
|
|
495
|
+
{authEnabled ? (
|
|
496
|
+
<>Private images need exec access to the Pod, or read access to its imagePullSecrets. Exec access also lets Radar use its own registry credentials.</>
|
|
497
|
+
) : (
|
|
498
|
+
<>Radar uses your local Docker credentials (<span className="font-mono">~/.docker/config.json</span>).
|
|
499
|
+
Run the command above in your terminal, then click Retry.</>
|
|
500
|
+
)}
|
|
494
501
|
</p>
|
|
495
502
|
|
|
496
503
|
{/* Retry button */}
|
|
@@ -127,7 +127,7 @@ interface PodFilesystemModalProps {
|
|
|
127
127
|
podName: string
|
|
128
128
|
containers: string[]
|
|
129
129
|
initialContainer?: string
|
|
130
|
-
onSwitchToImageFiles?: () => void
|
|
130
|
+
onSwitchToImageFiles?: (containerName: string) => void
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
export function PodFilesystemModal({
|
|
@@ -389,7 +389,7 @@ export function PodFilesystemModal({
|
|
|
389
389
|
)}
|
|
390
390
|
{onSwitchToImageFiles && (
|
|
391
391
|
<button
|
|
392
|
-
onClick={() => { onClose(); onSwitchToImageFiles() }}
|
|
392
|
+
onClick={() => { onClose(); onSwitchToImageFiles(selectedContainer) }}
|
|
393
393
|
className="ml-auto text-blue-400 hover:text-blue-300 hover:underline"
|
|
394
394
|
>
|
|
395
395
|
Browse static image from registry →
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { MemoryRouter } from 'react-router-dom'
|
|
5
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
6
|
+
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
|
7
|
+
import { ResourcesView } from './ResourcesView'
|
|
8
|
+
|
|
9
|
+
vi.mock('../../context/ConnectionContext', () => ({ useConnection: () => ({ connection: { state: 'connected', context: 'test' } }) }))
|
|
10
|
+
vi.mock('../dock', () => ({ useOpenLogs: () => () => {}, useOpenWorkloadLogs: () => () => {} }))
|
|
11
|
+
vi.mock('../../context/RadarUpgradeHost', () => ({ useRadarUpgradeHost: () => ({}) }))
|
|
12
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
13
|
+
|
|
14
|
+
const requested: URL[] = []
|
|
15
|
+
let root: ReturnType<typeof createRoot>
|
|
16
|
+
let client: QueryClient
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
requested.length = 0
|
|
20
|
+
vi.stubGlobal('matchMedia', () => ({ matches: false, addEventListener: () => {}, removeEventListener: () => {} }))
|
|
21
|
+
vi.stubGlobal('fetch', vi.fn((input: RequestInfo | URL) => {
|
|
22
|
+
requested.push(new URL(String(input), 'http://radar.invalid'))
|
|
23
|
+
return new Promise<Response>(() => {})
|
|
24
|
+
}))
|
|
25
|
+
root = createRoot(document.createElement('div'))
|
|
26
|
+
client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
afterEach(async () => {
|
|
30
|
+
await act(async () => root.unmount())
|
|
31
|
+
client.clear()
|
|
32
|
+
vi.unstubAllGlobals()
|
|
33
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
async function certExpiryScope(namespaces: string[]) {
|
|
37
|
+
await act(async () => {
|
|
38
|
+
root.render(
|
|
39
|
+
<QueryClientProvider client={client}>
|
|
40
|
+
<MemoryRouter initialEntries={['/resources/secrets']}>
|
|
41
|
+
<ResourcesView namespaces={namespaces} selectedResource={null} onResourceClick={() => {}} />
|
|
42
|
+
</MemoryRouter>
|
|
43
|
+
</QueryClientProvider>,
|
|
44
|
+
)
|
|
45
|
+
})
|
|
46
|
+
await act(async () => { await new Promise((resolve) => setTimeout(resolve, 0)) })
|
|
47
|
+
const certExpiry = requested.filter((url) => url.pathname.endsWith('/secrets/certificate-expiry'))
|
|
48
|
+
if (certExpiry.length === 0) throw new Error(`no certificate-expiry request: ${requested.map(String).join(', ')}`)
|
|
49
|
+
return certExpiry.map((url) => url.searchParams.get('namespaces'))
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
it('scopes certificate expiry to the namespaces in view', async () => {
|
|
53
|
+
expect(await certExpiryScope(['team-a', 'team-b'])).toEqual(['team-a,team-b'])
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('asks for every namespace when the view covers all', async () => {
|
|
57
|
+
expect(await certExpiryScope([])).toEqual([null])
|
|
58
|
+
})
|