@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
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
5
|
+
import { CompareResourcePicker, type CompareResourceRef } from '@skyhook-io/k8s-ui'
|
|
6
|
+
|
|
7
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
8
|
+
|
|
9
|
+
const source: CompareResourceRef = { kind: 'configmaps', namespace: 'read-a', name: 'app' }
|
|
10
|
+
let root: Root
|
|
11
|
+
let element: HTMLDivElement
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
element = document.createElement('div')
|
|
15
|
+
document.body.appendChild(element)
|
|
16
|
+
root = createRoot(element)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
act(() => root.unmount())
|
|
21
|
+
element.remove()
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
function render(notes: { coverageNote?: string; scopeNote?: string } = {}) {
|
|
25
|
+
act(() => {
|
|
26
|
+
root.render(<CompareResourcePicker open onClose={() => {}} source={source} candidates={[source]} {...notes} onPick={() => {}} />)
|
|
27
|
+
})
|
|
28
|
+
return document.body.textContent ?? ''
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const note = (text: string) => [...document.querySelectorAll('[role="status"]')].find((el) => el.textContent === text)
|
|
32
|
+
|
|
33
|
+
describe('compare picker empty state', () => {
|
|
34
|
+
it('says nothing else exists only when the list was complete', () => {
|
|
35
|
+
expect(render()).toContain('No other configmaps available to compare against.')
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it("doesn't claim nothing else exists after a qualified read", () => {
|
|
39
|
+
const partial = 'Partial results. Radar read read-a; your permissions exclude configmaps in read-b.'
|
|
40
|
+
const text = render({ coverageNote: partial })
|
|
41
|
+
expect(text).toContain('No other configmaps found in what Radar could read.')
|
|
42
|
+
expect(text).not.toContain('available to compare against')
|
|
43
|
+
expect(note(partial)?.className).toContain('text-warning-text')
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('shows a collection-narrowed list as scope, not as a warning', () => {
|
|
47
|
+
const scope = 'Radar collects this kind only in 1 namespace: read-a.'
|
|
48
|
+
const text = render({ scopeNote: scope })
|
|
49
|
+
expect(text).toContain('No other configmaps found in the collected namespaces.')
|
|
50
|
+
expect(note(scope)?.className).not.toContain('text-warning-text')
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('lets the warning win when both notes are set', () => {
|
|
54
|
+
const text = render({ coverageNote: 'Partial results.', scopeNote: 'Radar collects this kind only in 1 namespace: read-a.' })
|
|
55
|
+
expect(text).toContain('Partial results.')
|
|
56
|
+
expect(text).not.toContain('Radar collects this kind')
|
|
57
|
+
})
|
|
58
|
+
})
|
|
@@ -4,6 +4,8 @@ import {
|
|
|
4
4
|
ResourceCompareView,
|
|
5
5
|
CompareResourcePicker,
|
|
6
6
|
parseRef,
|
|
7
|
+
resourceCoverageNotice,
|
|
8
|
+
resourceNarrowedNotice,
|
|
7
9
|
refToParam,
|
|
8
10
|
type CompareResourceRef,
|
|
9
11
|
type CompareSide,
|
|
@@ -42,7 +44,7 @@ export function CompareViewRoute() {
|
|
|
42
44
|
const aQuery = useResource<unknown>(a?.kind ?? '', a?.namespace ?? '', a?.name ?? '', a?.group)
|
|
43
45
|
const bQuery = useResource<unknown>(b?.kind ?? '', b?.namespace ?? '', b?.name ?? '', b?.group)
|
|
44
46
|
|
|
45
|
-
const { candidates, isPending: candidatesPending, error: candidatesError } = useCompareCandidates(kind, group, !!pickerOpen)
|
|
47
|
+
const { candidates, coverage: candidatesCoverage, isPending: candidatesPending, error: candidatesError } = useCompareCandidates(kind, group, !!pickerOpen)
|
|
46
48
|
|
|
47
49
|
const updateParam = useCallback(
|
|
48
50
|
(next: Record<string, string>) => {
|
|
@@ -114,6 +116,8 @@ export function CompareViewRoute() {
|
|
|
114
116
|
source={source}
|
|
115
117
|
sourceSide={pickerOpen}
|
|
116
118
|
candidates={candidates}
|
|
119
|
+
coverageNote={resourceCoverageNotice(candidatesCoverage)}
|
|
120
|
+
scopeNote={resourceNarrowedNotice(candidatesCoverage)}
|
|
117
121
|
loading={candidatesPending}
|
|
118
122
|
error={candidatesError}
|
|
119
123
|
onPick={handlePick}
|
|
@@ -23,5 +23,5 @@ export function useCompareCandidates(kind: string, group: string | undefined, en
|
|
|
23
23
|
group,
|
|
24
24
|
}))
|
|
25
25
|
}, [query.data, kind, group])
|
|
26
|
-
return { candidates, isPending: query.isPending, error: query.error }
|
|
26
|
+
return { candidates, coverage: query.coverage, isPending: query.isPending, error: query.error }
|
|
27
27
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useState } from 'react'
|
|
2
2
|
import { useNavigate } from 'react-router-dom'
|
|
3
|
-
import { CompareResourcePicker, refToParam, type CompareResourceRef } from '@skyhook-io/k8s-ui'
|
|
3
|
+
import { CompareResourcePicker, refToParam, resourceCoverageNotice, resourceNarrowedNotice, type CompareResourceRef } from '@skyhook-io/k8s-ui'
|
|
4
4
|
import { useCompareCandidates } from './useCompareCandidates'
|
|
5
5
|
import { useNavCustomization } from '../../context/NavCustomization'
|
|
6
6
|
|
|
@@ -30,7 +30,7 @@ export function useCompareLauncher({ kind, namespace, name, group }: UseCompareL
|
|
|
30
30
|
const navigate = useNavigate()
|
|
31
31
|
const [open, setOpen] = useState(false)
|
|
32
32
|
const kindLower = kind.toLowerCase()
|
|
33
|
-
const { candidates, isPending, error } = useCompareCandidates(kindLower, group, open)
|
|
33
|
+
const { candidates, coverage, isPending, error } = useCompareCandidates(kindLower, group, open)
|
|
34
34
|
const { crossClusterCompareHref, onHostNavigate } = useNavCustomization()
|
|
35
35
|
|
|
36
36
|
const onCompareTo = useCallback(() => setOpen(true), [])
|
|
@@ -65,6 +65,8 @@ export function useCompareLauncher({ kind, namespace, name, group }: UseCompareL
|
|
|
65
65
|
onClose={() => setOpen(false)}
|
|
66
66
|
source={source}
|
|
67
67
|
candidates={candidates}
|
|
68
|
+
coverageNote={resourceCoverageNotice(coverage)}
|
|
69
|
+
scopeNote={resourceNarrowedNotice(coverage)}
|
|
68
70
|
loading={open && isPending}
|
|
69
71
|
error={open ? error : null}
|
|
70
72
|
onPick={handlePick}
|
|
@@ -4,7 +4,10 @@ import {
|
|
|
4
4
|
TerminalBlock,
|
|
5
5
|
TerminalBlockLabel,
|
|
6
6
|
} from "@skyhook-io/k8s-ui";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
InventoryRow,
|
|
9
|
+
type NamedInventoryRow,
|
|
10
|
+
} from "./investigationEvidence/bodies/inventory";
|
|
8
11
|
import { RankingRow } from "./investigationEvidence/bodies/ranking";
|
|
9
12
|
import { PostureFindingRow } from "./investigationEvidence/bodies/posture";
|
|
10
13
|
import { MetricsBody } from "./investigationEvidence/bodies/metrics";
|
|
@@ -12,6 +15,13 @@ import type { StoryExcerpt as Excerpt } from "./investigationEvidence/excerpt";
|
|
|
12
15
|
import type { InvestigationEvidenceData } from "./investigationEvidence";
|
|
13
16
|
import type { MetricsChangeCoverage } from "./investigationMetrics";
|
|
14
17
|
|
|
18
|
+
// A name a partial listing lacks is unknown where the listing did not look,
|
|
19
|
+
// not absent.
|
|
20
|
+
const unread = (entry: NamedInventoryRow) =>
|
|
21
|
+
entry.notRead !== undefined ||
|
|
22
|
+
entry.readOnlyIn !== undefined ||
|
|
23
|
+
entry.readUnnamed !== undefined;
|
|
24
|
+
|
|
15
25
|
/** The inline slice of a placed card, rendered from Radar's record. */
|
|
16
26
|
export function StoryExcerpt({
|
|
17
27
|
excerpt,
|
|
@@ -64,16 +74,25 @@ export function StoryExcerpt({
|
|
|
64
74
|
<p
|
|
65
75
|
key={entry.key}
|
|
66
76
|
data-story-inventory-absent={
|
|
67
|
-
entry.matches === 0 ? "" : undefined
|
|
77
|
+
entry.matches === 0 && !unread(entry) ? "" : undefined
|
|
68
78
|
}
|
|
79
|
+
data-story-inventory-unread={unread(entry) ? "" : undefined}
|
|
69
80
|
className={clsx(
|
|
70
81
|
"px-2.5 py-1.5 font-mono text-xs text-theme-text-secondary",
|
|
71
82
|
index > 0 && "border-t border-theme-border/60",
|
|
72
83
|
)}
|
|
73
84
|
>
|
|
74
|
-
{entry.
|
|
75
|
-
?
|
|
76
|
-
|
|
85
|
+
{entry.readUnnamed
|
|
86
|
+
? entry.readUnnamed.namespace
|
|
87
|
+
? `${entry.label}: not in this listing, which read ${entry.readUnnamed.count} namespaces without naming them all; ${entry.readUnnamed.namespace} may not have been one`
|
|
88
|
+
: `${entry.label}: not in the ${entry.readUnnamed.count} namespaces read`
|
|
89
|
+
: entry.notRead
|
|
90
|
+
? `${entry.label}: ${entry.notRead} was not read`
|
|
91
|
+
: entry.readOnlyIn
|
|
92
|
+
? `${entry.label}: not in the namespaces read (${entry.readOnlyIn.slice(0, 3).join(", ")}${entry.readOnlyIn.length > 3 ? ` and ${entry.readOnlyIn.length - 3} more` : ""})`
|
|
93
|
+
: entry.matches === 0
|
|
94
|
+
? `Not in this listing: ${entry.label}`
|
|
95
|
+
: `${entry.label}: ${entry.matches} entries match in this listing`}
|
|
77
96
|
</p>
|
|
78
97
|
),
|
|
79
98
|
)}
|
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { createElement } from "react";
|
|
5
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
6
|
+
import { describe, expect, it } from "vitest";
|
|
7
|
+
import type {
|
|
8
|
+
Diagnosis,
|
|
9
|
+
DiagnosisEvidenceItem,
|
|
10
|
+
} from "../../../../api/diagnose";
|
|
11
|
+
import { ResultCard } from "../../AssessmentCard";
|
|
12
|
+
import { InvestigationEvidencePane } from "../../InvestigationEvidencePane";
|
|
13
|
+
import { resolveInvestigationCase } from "../../investigationCase";
|
|
14
|
+
import { investigationEvidenceCoverageLimited } from "../../investigationState";
|
|
15
|
+
import { StoryExcerpt } from "../../StoryExcerpt";
|
|
16
|
+
import { InventoryBody, namedInventoryRows } from "../bodies/inventory";
|
|
17
|
+
import type { InvestigationEvidenceTimelineItem } from "../types";
|
|
18
|
+
import { evidenceRef, groupsOf, project, tool } from "../evidenceFixtures";
|
|
19
|
+
|
|
20
|
+
// The list_resources results a partial read returns over MCP: narrowed to the
|
|
21
|
+
// namespaces Radar collects (alpha, gamma), with gamma still loading. internal/mcp
|
|
22
|
+
// pins them to the producer and internal/ai proves every agent backend hands
|
|
23
|
+
// their joined text blocks to Findings unchanged; this suite projects that
|
|
24
|
+
// text the way Findings does.
|
|
25
|
+
const FIXTURE = resolve(
|
|
26
|
+
dirname(fileURLToPath(import.meta.url)),
|
|
27
|
+
"../../../../../../testdata/mcp/list-resources-partial-coverage.json",
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
interface FixtureCase {
|
|
31
|
+
name: string;
|
|
32
|
+
arguments: Record<string, unknown>;
|
|
33
|
+
result: { content: { type: string; text: string }[] };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const cases: FixtureCase[] = JSON.parse(readFileSync(FIXTURE, "utf8")).cases;
|
|
37
|
+
|
|
38
|
+
function projectCase(
|
|
39
|
+
name: string,
|
|
40
|
+
ref?: string,
|
|
41
|
+
preceding: InvestigationEvidenceTimelineItem[] = [],
|
|
42
|
+
) {
|
|
43
|
+
const fixture = cases.find((item) => item.name === name);
|
|
44
|
+
if (!fixture) throw new Error(`no fixture case ${name}`);
|
|
45
|
+
return project([
|
|
46
|
+
...preceding,
|
|
47
|
+
tool(
|
|
48
|
+
"list",
|
|
49
|
+
"list_resources",
|
|
50
|
+
fixture.result.content.map((block) => block.text).join(""),
|
|
51
|
+
{ summary: JSON.stringify(fixture.arguments), evidenceRef: ref },
|
|
52
|
+
),
|
|
53
|
+
]);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
describe("a list Radar read only in some of the namespaces it collects", () => {
|
|
57
|
+
it("shows the rows it read with the namespaces they came from", () => {
|
|
58
|
+
const projection = projectCase("partial", undefined, [
|
|
59
|
+
tool("diagnose", "diagnose", {
|
|
60
|
+
resource: {
|
|
61
|
+
apiVersion: "apps/v1",
|
|
62
|
+
kind: "Deployment",
|
|
63
|
+
metadata: { name: "api", namespace: "shop" },
|
|
64
|
+
},
|
|
65
|
+
pods: 0,
|
|
66
|
+
events: [],
|
|
67
|
+
recentChanges: [],
|
|
68
|
+
}),
|
|
69
|
+
]);
|
|
70
|
+
const [inventory] = groupsOf(projection.groups, "inventory");
|
|
71
|
+
if (inventory?.latest.data.type !== "inventory") {
|
|
72
|
+
throw new Error("expected an inventory card");
|
|
73
|
+
}
|
|
74
|
+
expect(
|
|
75
|
+
inventory.latest.data.resources.map((row) => [row.namespace, row.name]),
|
|
76
|
+
).toEqual([["alpha", "alpha-object"]]);
|
|
77
|
+
expect(inventory.latest.summary).toBe("1 returned · only alpha read");
|
|
78
|
+
// The rows carry Radar's own sentence: why gamma is missing, and who can
|
|
79
|
+
// widen the read, not just which namespace was read.
|
|
80
|
+
expect(inventory.latest.data.coverageNote).toBe(
|
|
81
|
+
'Partial: 1 Service from namespace "alpha". Unknown: namespace "gamma", because Radar is still loading services there. Other namespaces are unknown: Radar collects services only in namespaces "alpha", "gamma". Whoever runs Radar can widen its collection.',
|
|
82
|
+
);
|
|
83
|
+
expect(
|
|
84
|
+
renderToStaticMarkup(
|
|
85
|
+
createElement(InventoryBody, { data: inventory.latest.data }),
|
|
86
|
+
),
|
|
87
|
+
).toContain("because Radar is still loading services there");
|
|
88
|
+
expect(inventory.latest.data.namespacesRead).toEqual(["alpha"]);
|
|
89
|
+
expect(projection.limitations).toEqual([]);
|
|
90
|
+
const coverageLimited = investigationEvidenceCoverageLimited(
|
|
91
|
+
projection,
|
|
92
|
+
"Deployment",
|
|
93
|
+
);
|
|
94
|
+
expect(coverageLimited).toBe(false);
|
|
95
|
+
const html = renderToStaticMarkup(
|
|
96
|
+
createElement(ResultCard, {
|
|
97
|
+
diagnosis: {
|
|
98
|
+
healthy: true,
|
|
99
|
+
rootCause: "",
|
|
100
|
+
report: "The workload appears healthy.",
|
|
101
|
+
remediation: [],
|
|
102
|
+
} as Diagnosis,
|
|
103
|
+
coverageLimited,
|
|
104
|
+
}),
|
|
105
|
+
);
|
|
106
|
+
expect(html).toContain("border-emerald-500/30");
|
|
107
|
+
expect(html).not.toContain("No problem identified in available evidence");
|
|
108
|
+
expect(html).not.toContain("Evidence coverage is limited");
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("does not present an empty partial read as an empty cluster", () => {
|
|
112
|
+
const projection = projectCase("partial and empty");
|
|
113
|
+
expect(groupsOf(projection.groups, "inventory")).toEqual([]);
|
|
114
|
+
expect(projection.limitations.map((item) => item.message)).toEqual([
|
|
115
|
+
'Partial: no services in namespace "alpha". Unknown: namespace "gamma", because Radar is still loading services there. Other namespaces are unknown: Radar collects services only in namespaces "alpha", "gamma". Whoever runs Radar can widen its collection.',
|
|
116
|
+
]);
|
|
117
|
+
expect(investigationEvidenceCoverageLimited(projection, "Service")).toBe(
|
|
118
|
+
true,
|
|
119
|
+
);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("says what a listing that read unnamed namespaces shows about a citation", () => {
|
|
123
|
+
const namespaces = Array.from(
|
|
124
|
+
{ length: 40 },
|
|
125
|
+
(_, index) => `team-${String(index + 1).padStart(2, "0")}`,
|
|
126
|
+
);
|
|
127
|
+
const coverage = {
|
|
128
|
+
status: "partial",
|
|
129
|
+
scope: { type: "all_namespaces" },
|
|
130
|
+
read: {
|
|
131
|
+
type: "namespaces",
|
|
132
|
+
namespaces: { count: 40 },
|
|
133
|
+
},
|
|
134
|
+
gaps: [{ code: "radar_namespace_not_collected" }],
|
|
135
|
+
};
|
|
136
|
+
const summary =
|
|
137
|
+
"These are the services in 40 namespaces only. Not read: part of the scope, because Radar doesn't collect services there. Services may exist there that this list doesn't show.";
|
|
138
|
+
const rows = [
|
|
139
|
+
{ kind: "Service", name: "present", namespace: namespaces[0] },
|
|
140
|
+
{ kind: "Service", name: "observed", namespace: "team-39" },
|
|
141
|
+
];
|
|
142
|
+
const projection = project([
|
|
143
|
+
tool(
|
|
144
|
+
"list",
|
|
145
|
+
"list_resources",
|
|
146
|
+
{ summary, coverage, items: rows },
|
|
147
|
+
{
|
|
148
|
+
summary: JSON.stringify({ kind: "services" }),
|
|
149
|
+
},
|
|
150
|
+
),
|
|
151
|
+
]);
|
|
152
|
+
const [inventory] = groupsOf(projection.groups, "inventory");
|
|
153
|
+
if (inventory.latest.data.type !== "inventory") {
|
|
154
|
+
throw new Error("expected an inventory card");
|
|
155
|
+
}
|
|
156
|
+
const data = inventory.latest.data;
|
|
157
|
+
expect(data.namespacesRead).toEqual([]);
|
|
158
|
+
expect(data.namespacesReadOmitted).toBe(40);
|
|
159
|
+
expect(inventory.latest.summary).toBe(
|
|
160
|
+
"2 returned · only 40 namespaces read",
|
|
161
|
+
);
|
|
162
|
+
const entries = namedInventoryRows(
|
|
163
|
+
data.resources,
|
|
164
|
+
[
|
|
165
|
+
{ subject: { kind: "Service", name: "api" } },
|
|
166
|
+
{ subject: { kind: "Service", name: "api", namespace: "team-40" } },
|
|
167
|
+
{ subject: { kind: "Service", name: "api", namespace: "unread" } },
|
|
168
|
+
{ subject: { kind: "Service", name: "api", namespace: "team-39" } },
|
|
169
|
+
],
|
|
170
|
+
undefined,
|
|
171
|
+
data.namespacesRead,
|
|
172
|
+
data.namespacesReadOmitted,
|
|
173
|
+
);
|
|
174
|
+
expect(entries[0].readUnnamed).toEqual({ count: 40, namespace: undefined });
|
|
175
|
+
expect(entries[1].readUnnamed).toEqual({ count: 40, namespace: "team-40" });
|
|
176
|
+
expect(entries[2].readUnnamed).toEqual({ count: 40, namespace: "unread" });
|
|
177
|
+
expect(entries[2].notRead).toBeUndefined();
|
|
178
|
+
expect(entries[3].readUnnamed).toBeUndefined();
|
|
179
|
+
expect(entries[3].notRead).toBeUndefined();
|
|
180
|
+
const html = renderToStaticMarkup(
|
|
181
|
+
createElement(StoryExcerpt, {
|
|
182
|
+
excerpt: { kind: "rows", entries },
|
|
183
|
+
data,
|
|
184
|
+
prominence: "primary",
|
|
185
|
+
open: false,
|
|
186
|
+
canExpand: false,
|
|
187
|
+
}),
|
|
188
|
+
);
|
|
189
|
+
expect(html).toContain("api: not in the 40 namespaces read");
|
|
190
|
+
expect(html).toContain(
|
|
191
|
+
"team-40/api: not in this listing, which read 40 namespaces without naming them all; team-40 may not have been one",
|
|
192
|
+
);
|
|
193
|
+
expect(html).not.toContain("team-04");
|
|
194
|
+
expect(html).not.toContain("Not in this listing: team-40/api");
|
|
195
|
+
expect(html).toContain("Not in this listing: team-39/api");
|
|
196
|
+
expect(html).not.toContain("unread/api: unread was not read");
|
|
197
|
+
expect(html).toContain(
|
|
198
|
+
"unread/api: not in this listing, which read 40 namespaces without naming them all; unread may not have been one",
|
|
199
|
+
);
|
|
200
|
+
const empty = project([
|
|
201
|
+
tool("empty", "list_resources", { summary, coverage, items: [] }),
|
|
202
|
+
]);
|
|
203
|
+
expect(empty.limitations.map((item) => item.message)).toEqual([summary]);
|
|
204
|
+
expect(empty.limitations[0].message).not.toContain("team-09");
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it("names the resource Radar read, not the alias the agent asked for", () => {
|
|
208
|
+
const projection = projectCase("partial and empty, kind by alias");
|
|
209
|
+
const [message] = projection.limitations.map((item) => item.message);
|
|
210
|
+
expect(message).toContain("no services in namespace");
|
|
211
|
+
expect(message).not.toMatch(/svcs/i);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it("says a cited name's namespace was not read instead of calling it absent", () => {
|
|
215
|
+
const ref = evidenceRef("a", "b");
|
|
216
|
+
const projection = projectCase("partial", ref);
|
|
217
|
+
const evidence: DiagnosisEvidenceItem[] = [
|
|
218
|
+
{ namespace: "beta", claim: "Service api is missing from beta." },
|
|
219
|
+
{ namespace: "alpha", claim: "Service api is missing from alpha." },
|
|
220
|
+
{ namespace: undefined, claim: "No Service api exists." },
|
|
221
|
+
].map(({ namespace, claim }) => ({
|
|
222
|
+
status: "linked",
|
|
223
|
+
ref,
|
|
224
|
+
role: "cause",
|
|
225
|
+
claim,
|
|
226
|
+
subject: { kind: "Service", namespace, name: "api" },
|
|
227
|
+
}));
|
|
228
|
+
const investigationCase = resolveInvestigationCase(
|
|
229
|
+
projection,
|
|
230
|
+
{ evidence },
|
|
231
|
+
0,
|
|
232
|
+
);
|
|
233
|
+
expect(investigationCase.items.map((item) => item.placement)).toEqual([
|
|
234
|
+
"card",
|
|
235
|
+
"card",
|
|
236
|
+
"card",
|
|
237
|
+
]);
|
|
238
|
+
const html = renderToStaticMarkup(
|
|
239
|
+
createElement(InvestigationEvidencePane, {
|
|
240
|
+
projection,
|
|
241
|
+
investigationCase,
|
|
242
|
+
story: {
|
|
243
|
+
report: "The Ingress has no backend.\n\n[[radar:evidence=0]]",
|
|
244
|
+
evidence,
|
|
245
|
+
},
|
|
246
|
+
collecting: false,
|
|
247
|
+
animateGroupIds: new Set<string>(),
|
|
248
|
+
onViewSource: () => {},
|
|
249
|
+
onViewActivity: () => {},
|
|
250
|
+
}),
|
|
251
|
+
);
|
|
252
|
+
const start = html.indexOf("data-story-inventory-rows");
|
|
253
|
+
expect(start).toBeGreaterThan(-1);
|
|
254
|
+
const block = html.slice(start, html.indexOf('-body"', start));
|
|
255
|
+
// beta was never read, so the listing cannot say api is missing there.
|
|
256
|
+
expect(block).toContain("beta/api: beta was not read");
|
|
257
|
+
expect(block).not.toContain("Not in this listing: beta/api");
|
|
258
|
+
// alpha was read and has no api: there the listing does show absence.
|
|
259
|
+
expect(block).toContain("Not in this listing: alpha/api");
|
|
260
|
+
// An unqualified name was looked for only where the listing read.
|
|
261
|
+
expect(block).toContain("api: not in the namespaces read (alpha)");
|
|
262
|
+
expect(block).not.toContain("Not in this listing: api<");
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
it("keeps a complete list's rows and copy unchanged", () => {
|
|
266
|
+
const complete = project([
|
|
267
|
+
tool(
|
|
268
|
+
"list",
|
|
269
|
+
"list_resources",
|
|
270
|
+
[{ kind: "Service", name: "alpha-object", namespace: "alpha" }],
|
|
271
|
+
{ summary: JSON.stringify({ kind: "services" }) },
|
|
272
|
+
),
|
|
273
|
+
]);
|
|
274
|
+
const [inventory] = groupsOf(complete.groups, "inventory");
|
|
275
|
+
expect(inventory.latest.summary).toBe("1 returned");
|
|
276
|
+
expect(inventory.latest.data).not.toHaveProperty("namespacesRead");
|
|
277
|
+
expect(complete.limitations).toEqual([]);
|
|
278
|
+
const empty = project([
|
|
279
|
+
tool("list", "list_resources", [], {
|
|
280
|
+
summary: JSON.stringify({ kind: "services" }),
|
|
281
|
+
}),
|
|
282
|
+
]);
|
|
283
|
+
expect(empty.limitations.map((item) => item.message)).toEqual([
|
|
284
|
+
"Radar found no matching resources for services resources. Anything you do not have permission to read was not searched.",
|
|
285
|
+
]);
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
it("does not guess at a coverage object it cannot read", () => {
|
|
289
|
+
for (const payload of [
|
|
290
|
+
{ items: [], coverage: { complete: false } },
|
|
291
|
+
{ items: [], coverage: { complete: true, namespaces: ["alpha"] } },
|
|
292
|
+
{ items: {}, coverage: { complete: false, namespaces: ["alpha"] } },
|
|
293
|
+
]) {
|
|
294
|
+
const projection = project([
|
|
295
|
+
tool("list", "list_resources", payload, {
|
|
296
|
+
summary: JSON.stringify({ kind: "services" }),
|
|
297
|
+
}),
|
|
298
|
+
]);
|
|
299
|
+
expect(projection.groups).toEqual([]);
|
|
300
|
+
expect(projection.limitations.map((item) => item.message)).toEqual([
|
|
301
|
+
"Radar couldn't summarize this investigation step. Review it in Activity.",
|
|
302
|
+
]);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
describe("a list Radar read all of", () => {
|
|
308
|
+
const rows = [{ kind: "Service", name: "api", namespace: "alpha" }];
|
|
309
|
+
|
|
310
|
+
it("shows rows without a coverage caveat when nothing narrowed the scope", () => {
|
|
311
|
+
const coverage = {
|
|
312
|
+
status: "complete",
|
|
313
|
+
scope: { type: "all_namespaces" },
|
|
314
|
+
read: { type: "all_namespaces" },
|
|
315
|
+
gaps: [],
|
|
316
|
+
};
|
|
317
|
+
const projection = project([
|
|
318
|
+
tool(
|
|
319
|
+
"list",
|
|
320
|
+
"list_resources",
|
|
321
|
+
{
|
|
322
|
+
summary: "These are all the services in every namespace.",
|
|
323
|
+
coverage,
|
|
324
|
+
items: rows,
|
|
325
|
+
},
|
|
326
|
+
{ summary: JSON.stringify({ kind: "services" }) },
|
|
327
|
+
),
|
|
328
|
+
]);
|
|
329
|
+
const [inventory] = groupsOf(projection.groups, "inventory");
|
|
330
|
+
expect(inventory.latest.summary).toBe("1 returned");
|
|
331
|
+
expect(projection.limitations).toEqual([]);
|
|
332
|
+
const empty = project([
|
|
333
|
+
tool(
|
|
334
|
+
"empty",
|
|
335
|
+
"list_resources",
|
|
336
|
+
{
|
|
337
|
+
summary: "There are no services in any namespace.",
|
|
338
|
+
coverage,
|
|
339
|
+
items: [],
|
|
340
|
+
},
|
|
341
|
+
{ summary: JSON.stringify({ kind: "services" }) },
|
|
342
|
+
),
|
|
343
|
+
]);
|
|
344
|
+
expect(empty.limitations.map((item) => item.message)).toEqual([
|
|
345
|
+
"There are no services in any namespace.",
|
|
346
|
+
]);
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
it("keeps a narrowed scope from reading as the cluster", () => {
|
|
350
|
+
const coverage = {
|
|
351
|
+
status: "complete",
|
|
352
|
+
scope: {
|
|
353
|
+
type: "namespaces",
|
|
354
|
+
namespaces: { count: 2, names: ["alpha", "beta"] },
|
|
355
|
+
},
|
|
356
|
+
narrowedBy: ["user_access"],
|
|
357
|
+
read: {
|
|
358
|
+
type: "namespaces",
|
|
359
|
+
namespaces: { count: 2, names: ["alpha", "beta"] },
|
|
360
|
+
},
|
|
361
|
+
gaps: [],
|
|
362
|
+
};
|
|
363
|
+
const summary =
|
|
364
|
+
'These are the services in namespaces "alpha", "beta" only: your access covers only those namespaces. Other namespaces may have services this list doesn\'t show.';
|
|
365
|
+
const emptySummary =
|
|
366
|
+
'There are no services in namespaces "alpha", "beta": your access covers only those namespaces. Other namespaces may have services this list doesn\'t show.';
|
|
367
|
+
const projection = project([
|
|
368
|
+
tool(
|
|
369
|
+
"list",
|
|
370
|
+
"list_resources",
|
|
371
|
+
{ summary, coverage, items: rows },
|
|
372
|
+
{ summary: JSON.stringify({ kind: "services" }) },
|
|
373
|
+
),
|
|
374
|
+
]);
|
|
375
|
+
const [inventory] = groupsOf(projection.groups, "inventory");
|
|
376
|
+
expect(inventory.latest.summary).toBe("1 returned · only alpha, beta read");
|
|
377
|
+
const empty = project([
|
|
378
|
+
tool(
|
|
379
|
+
"empty",
|
|
380
|
+
"list_resources",
|
|
381
|
+
{ summary: emptySummary, coverage, items: [] },
|
|
382
|
+
{ summary: JSON.stringify({ kind: "services" }) },
|
|
383
|
+
),
|
|
384
|
+
]);
|
|
385
|
+
expect(empty.limitations.map((item) => item.message)).toEqual([
|
|
386
|
+
emptySummary,
|
|
387
|
+
]);
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
it("never reads an older Radar's bare array as complete", () => {
|
|
391
|
+
const empty = project([
|
|
392
|
+
tool("empty", "list_resources", [], {
|
|
393
|
+
summary: JSON.stringify({ kind: "services" }),
|
|
394
|
+
}),
|
|
395
|
+
]);
|
|
396
|
+
expect(empty.limitations[0].message).toContain(
|
|
397
|
+
"Anything you do not have permission to read was not searched.",
|
|
398
|
+
);
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
it("rejects a list that does not explain itself in words", () => {
|
|
402
|
+
const projection = project([
|
|
403
|
+
tool("list", "list_resources", {
|
|
404
|
+
coverage: {
|
|
405
|
+
status: "partial",
|
|
406
|
+
scope: { type: "all_namespaces" },
|
|
407
|
+
read: { type: "all_namespaces" },
|
|
408
|
+
gaps: [{ code: "kind_sync_pending" }],
|
|
409
|
+
},
|
|
410
|
+
items: rows,
|
|
411
|
+
}),
|
|
412
|
+
]);
|
|
413
|
+
expect(groupsOf(projection.groups, "inventory")).toEqual([]);
|
|
414
|
+
});
|
|
415
|
+
});
|