@skyhook-io/radar-app 1.18.0 → 1.18.1
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/README.md +6 -0
- package/package.json +2 -3
- package/src/App.tsx +22 -6
- package/src/api/client.gitops-destination.test.tsx +55 -0
- package/src/api/client.resource-list.test.ts +76 -0
- package/src/api/client.ts +61 -20
- package/src/api/quotas.ts +9 -20
- package/src/api/radarFeatures.ts +2 -0
- package/src/api/resourceLists.test.ts +84 -0
- package/src/api/resourceLists.ts +71 -0
- package/src/components/cnpg/CNPGView.tsx +1 -0
- package/src/components/compare/CompareResourcePicker.test.tsx +58 -0
- package/src/components/compare/CompareViewRoute.tsx +5 -1
- package/src/components/compare/useCompareCandidates.ts +1 -1
- package/src/components/compare/useCompareLauncher.tsx +4 -2
- package/src/components/diagnose/StoryExcerpt.tsx +24 -5
- package/src/components/diagnose/investigationEvidence/adapters/listCoverage.test.ts +415 -0
- package/src/components/diagnose/investigationEvidence/adapters/resource.ts +107 -8
- package/src/components/diagnose/investigationEvidence/bodies/inventory.tsx +66 -16
- package/src/components/diagnose/investigationEvidence/builder.ts +13 -1
- package/src/components/diagnose/investigationEvidence/excerpt.ts +2 -0
- package/src/components/diagnose/investigationEvidence/observations.ts +1 -0
- package/src/components/diagnose/investigationEvidence/projection.test.ts +24 -1
- package/src/components/diagnose/investigationEvidence/types.ts +15 -0
- package/src/components/diagnose/toolCallLabel.test.ts +9 -0
- package/src/components/diagnose/toolCallLabel.ts +2 -0
- package/src/components/execution/BatchExecutionView.image-browse.test.tsx +46 -0
- package/src/components/execution/BatchExecutionView.tsx +6 -4
- package/src/components/gitops/GitOpsView.identity.test.tsx +113 -0
- package/src/components/gitops/GitOpsView.tsx +62 -40
- package/src/components/gitops/useDestinationCluster.ts +2 -1
- package/src/components/helm/ArtifactHubSourceSearch.test.tsx +124 -0
- package/src/components/helm/ArtifactHubSourceSearch.tsx +240 -0
- package/src/components/helm/ChartBrowser.tsx +5 -4
- package/src/components/helm/TrackChartSourceDialog.render.test.tsx +269 -96
- package/src/components/helm/TrackChartSourceDialog.tsx +607 -104
- package/src/components/home/mcpToolCatalog.ts +10 -0
- package/src/components/resource/PrometheusCharts.overlays.test.ts +45 -0
- package/src/components/resource/PrometheusCharts.tsx +2 -2
- package/src/components/resources/ResourcesView.tsx +29 -67
- package/src/components/resources/renderers/PodRenderer.tsx +4 -1
- package/src/components/settings/MyPermissionsDialog.tsx +12 -9
- package/src/components/traffic/TrafficSourcePill.test.tsx +110 -0
- package/src/components/traffic/TrafficSourcePill.tsx +111 -0
- package/src/components/traffic/TrafficView.tsx +9 -55
- package/src/components/ui/DiagnosticsOverlay.test.ts +25 -0
- package/src/components/ui/DiagnosticsOverlay.tsx +2 -1
- package/src/components/ui/Omnibar.note.test.tsx +141 -0
- package/src/components/ui/Omnibar.tsx +82 -18
- package/src/components/ui/RadarOmnibar.test.tsx +183 -0
- package/src/components/ui/RadarOmnibar.tsx +38 -4
- package/src/components/ui/UpdateNotification.manual.test.tsx +177 -0
- package/src/components/ui/UpdateNotification.test.tsx +2 -1
- package/src/components/ui/UpdateNotification.tsx +29 -5
- package/src/components/ui/omnibar-match.test.ts +15 -8
- package/src/components/ui/omnibar-match.ts +11 -6
- package/src/components/ui/searchCoverage.fixtures.ts +16 -0
- package/src/components/ui/searchCoverageNote.test.ts +245 -0
- package/src/components/ui/searchCoverageNote.ts +222 -0
- package/src/components/whats-new/WhatsNew.test.ts +10 -0
- package/src/components/whats-new/WhatsNew.tsx +5 -4
- package/src/components/whats-new/WhatsNewDialog.test.tsx +20 -0
- package/src/components/whats-new/releaseNotes.ts +57 -5
- package/src/components/workload/WorkloadView.tsx +8 -2
- package/src/hooks/useResourceCounts.ts +2 -0
- package/src/index.css +2 -4
- package/src/index.ts +7 -0
- package/src/utils/artifacthub.test.ts +18 -0
- package/src/utils/artifacthub.ts +9 -0
|
@@ -226,20 +226,94 @@ export function adaptListNamespaces(
|
|
|
226
226
|
);
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
+
// list_resources arrives as `{summary, coverage, items}`. summary says in
|
|
230
|
+
// words what the rows cover and what was not read; coverage.read names the
|
|
231
|
+
// namespaces Radar read when that is a namespace set. A bare array is an older
|
|
232
|
+
// Radar's list (or a run recorded from one): it carries no coverage, so
|
|
233
|
+
// nothing about it may read as complete.
|
|
234
|
+
type ListCoverage = {
|
|
235
|
+
partial: boolean;
|
|
236
|
+
narrowed: boolean;
|
|
237
|
+
/** Set when Radar read a finite namespace set: rows prove nothing outside it. */
|
|
238
|
+
namespacesRead?: string[];
|
|
239
|
+
namespacesReadOmitted: number;
|
|
240
|
+
summary: string;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
function listedRows(
|
|
244
|
+
payload: unknown,
|
|
245
|
+
): { rows: unknown[]; coverage?: ListCoverage } | undefined {
|
|
246
|
+
if (Array.isArray(payload)) return { rows: payload };
|
|
247
|
+
const value = record(payload);
|
|
248
|
+
const coverage = record(value?.coverage);
|
|
249
|
+
const status = coverage?.status;
|
|
250
|
+
if (
|
|
251
|
+
!value ||
|
|
252
|
+
!Array.isArray(value.items) ||
|
|
253
|
+
!nonEmptyString(value.summary) ||
|
|
254
|
+
(status !== "complete" && status !== "partial")
|
|
255
|
+
) {
|
|
256
|
+
return undefined;
|
|
257
|
+
}
|
|
258
|
+
const summary = value.summary;
|
|
259
|
+
const read = record(coverage?.read);
|
|
260
|
+
const narrowed =
|
|
261
|
+
Array.isArray(coverage?.narrowedBy) && coverage.narrowedBy.length > 0;
|
|
262
|
+
if (read?.type !== "namespaces") {
|
|
263
|
+
return {
|
|
264
|
+
rows: value.items,
|
|
265
|
+
coverage: {
|
|
266
|
+
partial: status === "partial",
|
|
267
|
+
narrowed,
|
|
268
|
+
namespacesReadOmitted: 0,
|
|
269
|
+
summary,
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
// A set lists every name or, when it is too large, none: then which
|
|
274
|
+
// namespaces were read is unknown and only the count is.
|
|
275
|
+
const set = record(read.namespaces);
|
|
276
|
+
const count = set?.count;
|
|
277
|
+
const names = set?.names === undefined ? [] : stringArray(set.names);
|
|
278
|
+
if (
|
|
279
|
+
!names ||
|
|
280
|
+
typeof count !== "number" ||
|
|
281
|
+
!Number.isInteger(count) ||
|
|
282
|
+
(set?.names !== undefined && names.length !== count)
|
|
283
|
+
) {
|
|
284
|
+
return undefined;
|
|
285
|
+
}
|
|
286
|
+
return {
|
|
287
|
+
rows: value.items,
|
|
288
|
+
coverage: {
|
|
289
|
+
partial: status === "partial",
|
|
290
|
+
narrowed,
|
|
291
|
+
namespacesRead: names,
|
|
292
|
+
namespacesReadOmitted: count - names.length,
|
|
293
|
+
summary,
|
|
294
|
+
},
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
|
|
229
298
|
export function adaptListResources(
|
|
230
299
|
builder: ProjectionBuilder,
|
|
231
300
|
source: InvestigationEvidenceSource,
|
|
232
301
|
payload: unknown,
|
|
233
302
|
options: { title?: string } = {},
|
|
234
303
|
): void {
|
|
235
|
-
|
|
304
|
+
const listed = listedRows(payload);
|
|
305
|
+
if (!listed) {
|
|
236
306
|
invalidPayload(builder, source);
|
|
237
307
|
return;
|
|
238
308
|
}
|
|
239
|
-
const
|
|
309
|
+
const { rows, coverage } = listed;
|
|
310
|
+
const namespacesRead = coverage?.namespacesRead;
|
|
311
|
+
const namespacesReadCount =
|
|
312
|
+
(namespacesRead?.length ?? 0) + (coverage?.namespacesReadOmitted ?? 0);
|
|
313
|
+
const resources = rows
|
|
240
314
|
.map(resourceSummary)
|
|
241
315
|
.filter((item): item is InvestigationResourceSummary => Boolean(item));
|
|
242
|
-
if (resources.length !==
|
|
316
|
+
if (resources.length !== rows.length) {
|
|
243
317
|
invalidPayload(builder, source);
|
|
244
318
|
return;
|
|
245
319
|
}
|
|
@@ -257,12 +331,16 @@ export function adaptListResources(
|
|
|
257
331
|
: undefined;
|
|
258
332
|
const title = options.title ?? (namespace ? `${noun} in ${namespace}` : noun);
|
|
259
333
|
if (resources.length === 0) {
|
|
260
|
-
//
|
|
261
|
-
//
|
|
334
|
+
// An older Radar returns [] for some RBAC-filtered reads, so a bare array
|
|
335
|
+
// cannot prove absence. Otherwise the copy is the server's summary: the
|
|
336
|
+
// requested kind may be an alias ("svc"), and the summary names the
|
|
337
|
+
// resource it resolved.
|
|
262
338
|
builder.limit(
|
|
263
339
|
source,
|
|
264
340
|
"Resource inventory",
|
|
265
|
-
|
|
341
|
+
!coverage
|
|
342
|
+
? `Radar found no matching resources for ${scope}. Anything you do not have permission to read was not searched.`
|
|
343
|
+
: coverage.summary,
|
|
266
344
|
"unknown",
|
|
267
345
|
);
|
|
268
346
|
return;
|
|
@@ -288,8 +366,29 @@ export function adaptListResources(
|
|
|
288
366
|
relevance: "broader",
|
|
289
367
|
tone: hasAdverseResource ? "warning" : "neutral",
|
|
290
368
|
title,
|
|
291
|
-
summary:
|
|
292
|
-
|
|
369
|
+
summary: [
|
|
370
|
+
`${resources.length} returned`,
|
|
371
|
+
nonEmptyString(args?.group) ? args.group : undefined,
|
|
372
|
+
namespacesRead && (coverage?.partial || coverage?.narrowed)
|
|
373
|
+
? `only ${namespacesReadCount > 2 ? `${namespacesReadCount} namespaces` : namespacesRead.join(", ")} read`
|
|
374
|
+
: undefined,
|
|
375
|
+
]
|
|
376
|
+
.filter(Boolean)
|
|
377
|
+
.join(" · "),
|
|
378
|
+
data: {
|
|
379
|
+
type: "inventory",
|
|
380
|
+
resources,
|
|
381
|
+
scope,
|
|
382
|
+
...(namespacesRead
|
|
383
|
+
? {
|
|
384
|
+
namespacesRead,
|
|
385
|
+
namespacesReadOmitted: coverage!.namespacesReadOmitted,
|
|
386
|
+
}
|
|
387
|
+
: {}),
|
|
388
|
+
...(coverage && (coverage.partial || coverage.narrowed)
|
|
389
|
+
? { coverageNote: coverage.summary }
|
|
390
|
+
: {}),
|
|
391
|
+
},
|
|
293
392
|
},
|
|
294
393
|
);
|
|
295
394
|
}
|
|
@@ -9,9 +9,6 @@ import {
|
|
|
9
9
|
import { listingRowNamesSubject, sameKind } from "../../investigationCase";
|
|
10
10
|
import type { EvidenceDataOf } from "../cardParts";
|
|
11
11
|
|
|
12
|
-
// The rows the citations on a card name, in citation order: one row when the
|
|
13
|
-
// name picks exactly one entry, otherwise a line saying the entry is absent
|
|
14
|
-
// or which entries the name could mean.
|
|
15
12
|
export function listingScopeNamespace(
|
|
16
13
|
source: InvestigationEvidenceSource,
|
|
17
14
|
): string | undefined {
|
|
@@ -19,24 +16,45 @@ export function listingScopeNamespace(
|
|
|
19
16
|
return typeof namespace === "string" && namespace ? namespace : undefined;
|
|
20
17
|
}
|
|
21
18
|
|
|
19
|
+
export interface NamedInventoryRow {
|
|
20
|
+
key: string;
|
|
21
|
+
label: string;
|
|
22
|
+
matches: number;
|
|
23
|
+
row?: InvestigationResourceSummary;
|
|
24
|
+
/** No row matches, and the subject's namespace is one the listing did not read. */
|
|
25
|
+
notRead?: string;
|
|
26
|
+
/**
|
|
27
|
+
* No row matches, on a listing that read `count` namespaces without naming
|
|
28
|
+
* them. With a `namespace`, the subject's namespace may not have been one
|
|
29
|
+
* of them; without, the subject is only known to be absent from those.
|
|
30
|
+
*/
|
|
31
|
+
readUnnamed?: { count: number; namespace?: string };
|
|
32
|
+
/**
|
|
33
|
+
* No row matches a subject that names no namespace, on a listing that read
|
|
34
|
+
* only these namespaces.
|
|
35
|
+
*/
|
|
36
|
+
readOnlyIn?: readonly string[];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// The rows the citations on a card name, in citation order: one row when the
|
|
40
|
+
// name picks exactly one entry, otherwise a line saying the entry is absent,
|
|
41
|
+
// that where it would be was not read, or which entries the name could mean.
|
|
22
42
|
export function namedInventoryRows(
|
|
23
43
|
resources: InvestigationResourceSummary[],
|
|
24
44
|
items: readonly { subject?: DiagnosisEvidenceSubject }[],
|
|
25
45
|
/** The namespace the listing call was scoped to; rows omit it then. */
|
|
26
46
|
scopeNamespace?: string,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
47
|
+
/** Set when Radar's collector read the listed kind only in these namespaces. */
|
|
48
|
+
namespacesRead?: readonly string[],
|
|
49
|
+
namespacesReadOmitted = 0,
|
|
50
|
+
): NamedInventoryRow[] {
|
|
51
|
+
const observedNamespaces = new Set(
|
|
52
|
+
resources
|
|
53
|
+
.map((resource) => resource.namespace ?? scopeNamespace)
|
|
54
|
+
.filter(Boolean),
|
|
55
|
+
);
|
|
33
56
|
const seen = new Set<string>();
|
|
34
|
-
const out:
|
|
35
|
-
key: string;
|
|
36
|
-
label: string;
|
|
37
|
-
matches: number;
|
|
38
|
-
row?: InvestigationResourceSummary;
|
|
39
|
-
}[] = [];
|
|
57
|
+
const out: NamedInventoryRow[] = [];
|
|
40
58
|
for (const item of items) {
|
|
41
59
|
const subject = item.subject;
|
|
42
60
|
if (!subject?.name) continue;
|
|
@@ -64,11 +82,36 @@ export function namedInventoryRows(
|
|
|
64
82
|
declaringObject(resource) ||
|
|
65
83
|
(resource.namespace ?? scopeNamespace) === namespace),
|
|
66
84
|
);
|
|
85
|
+
// A name the rows lack is absent only where the listing looked.
|
|
86
|
+
const unread = namespacesRead && matches.length === 0;
|
|
67
87
|
out.push({
|
|
68
88
|
key,
|
|
69
89
|
label: namespace ? `${namespace}/${subject.name}` : subject.name,
|
|
70
90
|
matches: matches.length,
|
|
71
91
|
row: matches.length === 1 ? matches[0] : undefined,
|
|
92
|
+
notRead:
|
|
93
|
+
unread &&
|
|
94
|
+
namespace &&
|
|
95
|
+
namespacesReadOmitted === 0 &&
|
|
96
|
+
!namespacesRead.includes(namespace) &&
|
|
97
|
+
!observedNamespaces.has(namespace)
|
|
98
|
+
? namespace
|
|
99
|
+
: undefined,
|
|
100
|
+
readOnlyIn:
|
|
101
|
+
unread && !namespace && namespacesReadOmitted === 0
|
|
102
|
+
? namespacesRead
|
|
103
|
+
: undefined,
|
|
104
|
+
readUnnamed:
|
|
105
|
+
unread &&
|
|
106
|
+
namespacesReadOmitted > 0 &&
|
|
107
|
+
(!namespace ||
|
|
108
|
+
(!namespacesRead.includes(namespace) &&
|
|
109
|
+
!observedNamespaces.has(namespace)))
|
|
110
|
+
? {
|
|
111
|
+
count: namespacesRead.length + namespacesReadOmitted,
|
|
112
|
+
namespace,
|
|
113
|
+
}
|
|
114
|
+
: undefined,
|
|
72
115
|
});
|
|
73
116
|
}
|
|
74
117
|
return out;
|
|
@@ -143,7 +186,7 @@ export function InventoryBody({
|
|
|
143
186
|
...lead,
|
|
144
187
|
...data.resources.filter((resource) => !lead.includes(resource)),
|
|
145
188
|
];
|
|
146
|
-
|
|
189
|
+
const list = (
|
|
147
190
|
<div className="max-h-72 overflow-y-auto rounded-md border border-theme-border">
|
|
148
191
|
{rows.map((resource, index) => (
|
|
149
192
|
<InventoryRow
|
|
@@ -155,4 +198,11 @@ export function InventoryBody({
|
|
|
155
198
|
))}
|
|
156
199
|
</div>
|
|
157
200
|
);
|
|
201
|
+
if (!data.coverageNote) return list;
|
|
202
|
+
return (
|
|
203
|
+
<div className="flex flex-col gap-2">
|
|
204
|
+
<p className="text-xs text-theme-text-secondary">{data.coverageNote}</p>
|
|
205
|
+
{list}
|
|
206
|
+
</div>
|
|
207
|
+
);
|
|
158
208
|
}
|
|
@@ -203,7 +203,7 @@ export function projectInvestigationEvidence(
|
|
|
203
203
|
builder.limit(
|
|
204
204
|
source,
|
|
205
205
|
investigationResultLabel(source),
|
|
206
|
-
item.result || "This investigation step failed.",
|
|
206
|
+
failedStepMessage(item.result) || "This investigation step failed.",
|
|
207
207
|
"error",
|
|
208
208
|
);
|
|
209
209
|
continue;
|
|
@@ -440,3 +440,15 @@ export function projectInvestigationEvidence(
|
|
|
440
440
|
},
|
|
441
441
|
};
|
|
442
442
|
}
|
|
443
|
+
|
|
444
|
+
// A resource read's failure arrives as its JSON body ({error, error_code,
|
|
445
|
+
// coverage?}); Findings shows the explanation, not the JSON.
|
|
446
|
+
export function failedStepMessage(
|
|
447
|
+
result: string | undefined,
|
|
448
|
+
): string | undefined {
|
|
449
|
+
if (!result) return result;
|
|
450
|
+
const body = record(parseJSON(result));
|
|
451
|
+
return nonEmptyString(body?.error) && typeof body.error_code === "string"
|
|
452
|
+
? body.error
|
|
453
|
+
: result;
|
|
454
|
+
}
|
|
@@ -190,6 +190,7 @@ const INVESTIGATION_RESULT_LABELS: Readonly<Record<string, string>> = {
|
|
|
190
190
|
top_resources: "Resource ranking",
|
|
191
191
|
get_cluster_audit: "Posture findings",
|
|
192
192
|
get_cluster_upgrade_readiness: "Upgrade readiness",
|
|
193
|
+
get_runtime_versions: "Runtime versions",
|
|
193
194
|
list_helm_releases: "Helm releases",
|
|
194
195
|
list_packages: "Installed packages",
|
|
195
196
|
search: "Search results",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
2
|
import { projectInvestigationEvidence } from "./index";
|
|
3
|
+
import { failedStepMessage } from "./builder";
|
|
3
4
|
import {
|
|
4
5
|
completeLogProof,
|
|
5
6
|
criticalIssue,
|
|
@@ -2265,7 +2266,7 @@ describe("honest zero and partial-result states", () => {
|
|
|
2265
2266
|
truncated: true,
|
|
2266
2267
|
narrowHint: "subgraph capped at 25 nodes",
|
|
2267
2268
|
omitted: [
|
|
2268
|
-
{ field: "uses.secrets", reason: "
|
|
2269
|
+
{ field: "uses.secrets", reason: "user_forbidden" },
|
|
2269
2270
|
{ field: "referencedBy", reason: "budget_exceeded" },
|
|
2270
2271
|
],
|
|
2271
2272
|
}),
|
|
@@ -2857,3 +2858,25 @@ describe("namespace listings", () => {
|
|
|
2857
2858
|
).toEqual(["capi-system", "shop"]);
|
|
2858
2859
|
});
|
|
2859
2860
|
});
|
|
2861
|
+
|
|
2862
|
+
describe("failedStepMessage", () => {
|
|
2863
|
+
it("shows a coded read failure's explanation, not its JSON body", () => {
|
|
2864
|
+
const body = JSON.stringify({
|
|
2865
|
+
error:
|
|
2866
|
+
'namespace "beta" is not among the namespaces you can see, or does not exist',
|
|
2867
|
+
error_code: "user_namespace_not_visible",
|
|
2868
|
+
coverage: { status: "partial", scope: { type: "namespaces" }, gaps: [] },
|
|
2869
|
+
});
|
|
2870
|
+
expect(failedStepMessage(body)).toBe(
|
|
2871
|
+
'namespace "beta" is not among the namespaces you can see, or does not exist',
|
|
2872
|
+
);
|
|
2873
|
+
});
|
|
2874
|
+
it("keeps any other failure text as it came", () => {
|
|
2875
|
+
expect(failedStepMessage("user_forbidden: your role cannot list pods")).toBe(
|
|
2876
|
+
"user_forbidden: your role cannot list pods",
|
|
2877
|
+
);
|
|
2878
|
+
expect(failedStepMessage('{"error":"no code"}')).toBe(
|
|
2879
|
+
'{"error":"no code"}',
|
|
2880
|
+
);
|
|
2881
|
+
});
|
|
2882
|
+
});
|
|
@@ -459,6 +459,21 @@ export type InvestigationEvidenceData =
|
|
|
459
459
|
type: "inventory";
|
|
460
460
|
resources: InvestigationResourceSummary[];
|
|
461
461
|
scope: string;
|
|
462
|
+
/**
|
|
463
|
+
* Set only when Radar's collector read the kind in just these
|
|
464
|
+
* namespaces: a name missing from the rows is unknown outside them.
|
|
465
|
+
*/
|
|
466
|
+
namespacesRead?: string[];
|
|
467
|
+
/**
|
|
468
|
+
* Namespaces read that the listing doesn't name, because there were too
|
|
469
|
+
* many to list; they were read, so they are not a gap.
|
|
470
|
+
*/
|
|
471
|
+
namespacesReadOmitted?: number;
|
|
472
|
+
/**
|
|
473
|
+
* Radar's own sentence for a partial or narrowed list: what it didn't
|
|
474
|
+
* read and why, shown with the rows so they never read as everything.
|
|
475
|
+
*/
|
|
476
|
+
coverageNote?: string;
|
|
462
477
|
}
|
|
463
478
|
| {
|
|
464
479
|
type: "ranking";
|
|
@@ -14,6 +14,15 @@ describe("describeToolCall", () => {
|
|
|
14
14
|
).toBe("Listing Ingresses");
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
+
it("scopes the runtime inventory to its namespace", () => {
|
|
18
|
+
expect(describeToolCall("get_runtime_versions", JSON.stringify({ runtime: "php" }))).toBe(
|
|
19
|
+
"Reading runtime versions of running images",
|
|
20
|
+
);
|
|
21
|
+
expect(
|
|
22
|
+
describeToolCall("get_runtime_versions", JSON.stringify({ namespace: "shop", runtime: "php" })),
|
|
23
|
+
).toBe("Reading runtime versions of running images in shop");
|
|
24
|
+
});
|
|
25
|
+
|
|
17
26
|
it("names the target from the call's arguments", () => {
|
|
18
27
|
expect(
|
|
19
28
|
describeToolCall(
|
|
@@ -68,6 +68,8 @@ export function describeToolCall(tool: string, args?: string): string {
|
|
|
68
68
|
return "Running the cluster audit";
|
|
69
69
|
case "get_cluster_upgrade_readiness":
|
|
70
70
|
return "Checking upgrade readiness";
|
|
71
|
+
case "get_runtime_versions":
|
|
72
|
+
return scoped("Reading runtime versions of running images");
|
|
71
73
|
case "apply_resource":
|
|
72
74
|
return "Applying the change";
|
|
73
75
|
case "patch_resource":
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
2
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
3
|
+
import { BatchExecutionFullscreen } from './BatchExecutionView'
|
|
4
|
+
|
|
5
|
+
const auth = vi.hoisted(() => ({ enabled: false }))
|
|
6
|
+
|
|
7
|
+
vi.mock('../../api/client', () => ({
|
|
8
|
+
useResource: () => ({}),
|
|
9
|
+
useWorkloadPods: () => ({}),
|
|
10
|
+
useJobSetResources: () => ({ data: undefined, isLoading: false }),
|
|
11
|
+
useWorkloadRuns: () => ({ isLoading: false, error: undefined, data: { collection: 'runs', runs: [], total: 0, truncated: false } }),
|
|
12
|
+
useImageMetadata: () => ({ data: undefined, isLoading: false, error: undefined }),
|
|
13
|
+
ApiError: class ApiError extends Error {},
|
|
14
|
+
}))
|
|
15
|
+
|
|
16
|
+
vi.mock('../../contexts/CapabilitiesContext', async (importOriginal) => ({
|
|
17
|
+
...(await importOriginal<typeof import('../../contexts/CapabilitiesContext')>()),
|
|
18
|
+
useIsAuthEnabled: () => auth.enabled,
|
|
19
|
+
}))
|
|
20
|
+
|
|
21
|
+
const image = 'trafex/php-nginx:3.6.0'
|
|
22
|
+
|
|
23
|
+
function render() {
|
|
24
|
+
return renderToStaticMarkup(
|
|
25
|
+
<BatchExecutionFullscreen
|
|
26
|
+
kind="CronJob" apiKind="cronjobs" namespace="legacy" name="nightly-invoice"
|
|
27
|
+
resource={{ spec: { schedule: '0 3 * * *', jobTemplate: { spec: { template: { spec: { containers: [{ name: 'invoice', image }] } } } } }, status: {} }}
|
|
28
|
+
/>,
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
describe('template image in the run view', () => {
|
|
33
|
+
it('opens the image browser when auth is off', () => {
|
|
34
|
+
auth.enabled = false
|
|
35
|
+
const html = render()
|
|
36
|
+
expect(html).toMatch(new RegExp(`<button[^>]*>${image}</button>`))
|
|
37
|
+
expect(html).not.toContain('decoration-dotted')
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('stays text and marks the explanation when auth is on, where a template has no Pod to browse through', () => {
|
|
41
|
+
auth.enabled = true
|
|
42
|
+
const html = render()
|
|
43
|
+
expect(html).not.toMatch(new RegExp(`<button[^>]*>${image}</button>`))
|
|
44
|
+
expect(html).toMatch(new RegExp(`<span class="[^"]*decoration-dotted[^"]*" tabindex="0">${image}<span class="sr-only">. With sign-in on, browse an image's files from one of its Pods.</span></span>`))
|
|
45
|
+
})
|
|
46
|
+
})
|
|
@@ -740,7 +740,7 @@ function ExecutionUnitDetails({ unit, namespace, pullSecrets, compact }: { unit:
|
|
|
740
740
|
<div className={clsx(!compact && 'rounded-md bg-theme-elevated/40 px-3 py-2')}>
|
|
741
741
|
{!compact && <div className="mb-1 flex items-center justify-between gap-3"><span className="truncate text-xs font-medium text-theme-text-primary">{unit.name}</span><span className="text-[10px] uppercase tracking-wide text-theme-text-tertiary">{unit.type}</span></div>}
|
|
742
742
|
<div className="space-y-1">
|
|
743
|
-
{unit.image && <DefinitionFact label="Image" value={unit.image} mono onClick={canBrowseImage ? () => setBrowseImage(true) : undefined} tooltip={canBrowseImage ? 'Browse image filesystem from registry' :
|
|
743
|
+
{unit.image && <DefinitionFact label="Image" value={unit.image} mono onClick={canBrowseImage ? () => setBrowseImage(true) : undefined} tooltip={canBrowseImage ? 'Browse image filesystem from registry' : IMAGE_BROWSE_VIA_POD} hint={!canBrowseImage} />}
|
|
744
744
|
{unit.command && <DefinitionFact label="Command" value={unit.command} mono />}
|
|
745
745
|
{!compact && unit.requests && <DefinitionFact label="Requests" value={unit.requests} />}
|
|
746
746
|
{!compact && unit.limits && <DefinitionFact label="Limits" value={unit.limits} />}
|
|
@@ -760,15 +760,17 @@ function ExecutionUnitDetails({ unit, namespace, pullSecrets, compact }: { unit:
|
|
|
760
760
|
)
|
|
761
761
|
}
|
|
762
762
|
|
|
763
|
-
|
|
764
|
-
|
|
763
|
+
const IMAGE_BROWSE_VIA_POD = "With sign-in on, browse an image's files from one of its Pods."
|
|
764
|
+
|
|
765
|
+
function DefinitionFact({ label, value, mono = false, onClick, tooltip, hint = false }: { label: string; value: string; mono?: boolean; onClick?: () => void; tooltip?: string; hint?: boolean }) {
|
|
766
|
+
const valueClassName = clsx('break-words text-theme-text-primary', mono && 'font-mono text-xs', onClick && 'text-accent-text hover:underline', hint && 'cursor-help underline decoration-dotted decoration-theme-text-tertiary underline-offset-2')
|
|
765
767
|
return (
|
|
766
768
|
<div className="flex items-start justify-between gap-3 text-sm">
|
|
767
769
|
<span className="shrink-0 text-theme-text-tertiary">{label}</span>
|
|
768
770
|
<Tooltip content={tooltip ?? value} delay={300} wrapperClassName="min-w-0 text-right">
|
|
769
771
|
{onClick
|
|
770
772
|
? <button type="button" onClick={onClick} className={clsx(valueClassName, 'text-right')}>{value}</button>
|
|
771
|
-
: <span className={valueClassName}>{value}</span>}
|
|
773
|
+
: <span className={valueClassName} tabIndex={hint ? 0 : undefined}>{value}{hint && tooltip && <span className="sr-only">. {tooltip}</span>}</span>}
|
|
772
774
|
</Tooltip>
|
|
773
775
|
</div>
|
|
774
776
|
)
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
2
|
+
import { renderToString } from 'react-dom/server'
|
|
3
|
+
import { MemoryRouter } from 'react-router-dom'
|
|
4
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
5
|
+
|
|
6
|
+
const destinationRequest = vi.hoisted(() => vi.fn())
|
|
7
|
+
const state = vi.hoisted(() => ({ apiVersion: 'app.k8s.io/v1beta1', loading: false, treeLoading: false, kind: 'Application', error: '', remote: false }))
|
|
8
|
+
vi.mock('../../api/client', async (importOriginal) => {
|
|
9
|
+
const actual = await importOriginal<typeof import('../../api/client')>()
|
|
10
|
+
return {
|
|
11
|
+
...actual,
|
|
12
|
+
useResource: () => ({ isLoading: state.loading, error: state.error ? new Error(state.error) : null, data: state.loading || state.error ? undefined : {
|
|
13
|
+
apiVersion: state.apiVersion, kind: state.kind, metadata: { name: 'wordpress', namespace: 'shop' },
|
|
14
|
+
spec: { project: 'default', destination: { server: 'https://kubernetes.default.svc' } },
|
|
15
|
+
status: { sync: { status: 'Synced' }, health: { status: 'Healthy' }, conditions: [{ type: 'Ready', status: 'True' }] },
|
|
16
|
+
} }),
|
|
17
|
+
useGitOpsTree: () => ({ isLoading: state.treeLoading, error: null, data: undefined }),
|
|
18
|
+
useGitOpsInsights: () => ({ isLoading: false, error: null, data: state.remote ? { summary: { tool: 'argocd', remoteDestination: true }, issues: [], changes: [], history: [], plan: [], capabilities: {} } : undefined }),
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
vi.mock('../ui/Toast', () => ({ useToast: () => ({ showError: vi.fn(), showSuccess: vi.fn(), showToast: vi.fn() }) }))
|
|
22
|
+
vi.mock('../useContextSwitchFlow', () => ({ useContextSwitchFlow: () => ({ confirmDialog: null }) }))
|
|
23
|
+
vi.mock('./useDestinationCluster', () => ({ useDestinationCluster: (...args: unknown[]) => { destinationRequest(...args); return {} } }))
|
|
24
|
+
vi.mock('../../hooks/useKeyboardShortcuts', () => ({ useRegisterShortcut: () => {} }))
|
|
25
|
+
vi.mock('../../hooks/usePreviousIntegrationSettings', () => ({ usePreviousIntegrationSettings: () => ({}), previousSettingsNote: () => undefined }))
|
|
26
|
+
|
|
27
|
+
import { GitOpsView } from './GitOpsView'
|
|
28
|
+
|
|
29
|
+
function render(group = 'argoproj.io', kind = 'applications') {
|
|
30
|
+
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
|
31
|
+
const html = renderToString(
|
|
32
|
+
<QueryClientProvider client={client}>
|
|
33
|
+
<MemoryRouter initialEntries={[`/gitops/detail/${kind}/shop/wordpress?apiGroup=${group}`]}>
|
|
34
|
+
<GitOpsView namespaces={[]} onOpenResource={() => {}} />
|
|
35
|
+
</MemoryRouter>
|
|
36
|
+
</QueryClientProvider>,
|
|
37
|
+
)
|
|
38
|
+
client.clear()
|
|
39
|
+
return html
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
describe('GitOps detail identity', () => {
|
|
43
|
+
it.each([false, true])('refuses a foreign Application even while tree loading is %s', (treeLoading) => {
|
|
44
|
+
Object.assign(state, { apiVersion: 'app.k8s.io/v1beta1', kind: 'Application', error: '', loading: false, treeLoading })
|
|
45
|
+
const html = render()
|
|
46
|
+
expect(html).toContain('Application.app.k8s.io shop/wordpress is not a supported Argo CD or Flux resource')
|
|
47
|
+
expect(html).not.toContain('ArgoCD')
|
|
48
|
+
expect(html).not.toContain('FluxCD')
|
|
49
|
+
expect(html).not.toContain('Sync…')
|
|
50
|
+
expect(html).not.toContain('Reconcile')
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('keeps actions hidden until the resource confirms its group', () => {
|
|
54
|
+
Object.assign(state, { loading: true, treeLoading: true })
|
|
55
|
+
const html = render()
|
|
56
|
+
expect(html).not.toContain('ArgoCD')
|
|
57
|
+
expect(html).not.toContain('Sync…')
|
|
58
|
+
expect(html).not.toContain('is not a supported Argo CD or Flux resource')
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('keeps the Argo CD header and actions for a real Application', () => {
|
|
62
|
+
Object.assign(state, { apiVersion: 'argoproj.io/v1alpha1', kind: 'Application', error: '', loading: false, treeLoading: true })
|
|
63
|
+
const html = render()
|
|
64
|
+
expect(html).toContain('ArgoCD')
|
|
65
|
+
expect(html).toContain('Sync…')
|
|
66
|
+
expect(html).toContain('Healthy')
|
|
67
|
+
expect(html).not.toContain('is not a supported Argo CD or Flux resource')
|
|
68
|
+
})
|
|
69
|
+
it('preserves Flux reconcile controls', () => {
|
|
70
|
+
Object.assign(state, { apiVersion: 'kustomize.toolkit.fluxcd.io/v1', kind: 'Kustomization', loading: false, treeLoading: true, error: '', remote: false })
|
|
71
|
+
const html = render('kustomize.toolkit.fluxcd.io', 'kustomizations')
|
|
72
|
+
expect(html).toContain('FluxCD')
|
|
73
|
+
expect(html).toContain('Reconcile')
|
|
74
|
+
expect(html).not.toContain('ArgoCD')
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('does not classify Argo Workflows as Argo CD', () => {
|
|
78
|
+
Object.assign(state, { apiVersion: 'argoproj.io/v1alpha1', kind: 'Workflow', loading: false, treeLoading: false, error: '', remote: false })
|
|
79
|
+
const html = render('argoproj.io', 'workflows')
|
|
80
|
+
expect(html).toContain('Workflow.argoproj.io shop/wordpress is not a supported Argo CD or Flux resource')
|
|
81
|
+
expect(html).not.toContain('ArgoCD')
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it('shows the resource read error without claiming an identity', () => {
|
|
85
|
+
Object.assign(state, { loading: false, error: 'access denied' })
|
|
86
|
+
const html = render()
|
|
87
|
+
expect(html).toContain('access denied')
|
|
88
|
+
expect(html).not.toContain('is not a supported Argo CD or Flux resource')
|
|
89
|
+
expect(html).not.toContain('ArgoCD')
|
|
90
|
+
expect(html).not.toContain('Sync…')
|
|
91
|
+
state.error = ''
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
it.each([
|
|
95
|
+
['applications', 'Application', 'source.toolkit.fluxcd.io'],
|
|
96
|
+
['kustomizations', 'Kustomization', 'source.toolkit.fluxcd.io'],
|
|
97
|
+
])('rejects %s in the wrong Flux group', (plural, kind, group) => {
|
|
98
|
+
Object.assign(state, { apiVersion: `${group}/v1`, kind, loading: false, treeLoading: false, error: '', remote: false })
|
|
99
|
+
const html = render(group, plural)
|
|
100
|
+
expect(html).toContain('is not a supported Argo CD or Flux resource')
|
|
101
|
+
expect(html).not.toContain('FluxCD')
|
|
102
|
+
expect(html).not.toContain('Reconcile')
|
|
103
|
+
expect(html).not.toContain('ArgoCD')
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
it('ignores a misleading remote destination from an older backend', () => {
|
|
107
|
+
Object.assign(state, { apiVersion: 'app.k8s.io/v1beta1', kind: 'Application', loading: false, error: '', remote: true })
|
|
108
|
+
render('app.k8s.io')
|
|
109
|
+
expect(destinationRequest).toHaveBeenLastCalledWith(false, 'applications', 'shop', 'wordpress', 'app.k8s.io')
|
|
110
|
+
state.remote = false
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
})
|