@skyhook-io/radar-app 1.20.3 → 1.21.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/package.json +10 -9
- package/src/App.tsx +67 -15
- package/src/api/client.audit-gating.test.tsx +105 -5
- package/src/api/client.auditBadgesSync.test.tsx +118 -0
- package/src/api/client.capabilitiesPoll.test.ts +61 -0
- package/src/api/client.ts +129 -5
- package/src/api/namespaceScopeRetry.test.ts +14 -0
- package/src/api/radarFeatures.ts +11 -0
- package/src/api/substrateHealth.ts +134 -0
- package/src/api/velero.test.ts +60 -0
- package/src/api/velero.ts +377 -0
- package/src/api/vulnerabilities.ts +313 -0
- package/src/components/NamespaceSwitcher.tsx +3 -1
- package/src/components/audit/AuditView.tsx +4 -0
- package/src/components/audit/ChecksViewTabs.test.tsx +35 -5
- package/src/components/audit/ChecksViewTabs.tsx +12 -1
- package/src/components/audit/Java4ShellPanel.test.tsx +31 -0
- package/src/components/audit/Java4ShellPanel.tsx +313 -0
- package/src/components/audit/UpgradeReadinessView.test.ts +35 -1
- package/src/components/audit/UpgradeReadinessView.tsx +60 -2
- package/src/components/audit/VulnerabilitiesView.tsx +944 -0
- package/src/components/cnpg/CNPGClusterTabs.tsx +3 -1
- package/src/components/cnpg/CNPGDrawerTrail.tsx +5 -26
- package/src/components/cnpg/CNPGInvestigationAction.test.tsx +27 -6
- package/src/components/cnpg/CNPGView.tsx +43 -117
- package/src/components/cnpg/CNPGWorkspace.compatibility.test.tsx +30 -0
- package/src/components/cnpg/host.tsx +2 -2
- package/src/components/cnpg/routes.ts +3 -1
- package/src/components/cnpg/shared.tsx +5 -53
- package/src/components/cnpg/useCNPGNavigate.ts +1 -21
- package/src/components/cnpg/useCNPGSidebarWorkspace.ts +16 -13
- package/src/components/community.tsx +42 -0
- package/src/components/diagnose/diagnoseEvidenceTypes.ts +2 -0
- package/src/components/diagnose/investigationMetrics.test.ts +20 -0
- package/src/components/diagnose/investigationMetrics.ts +2 -1
- package/src/components/dock/BottomDock.tsx +1 -0
- package/src/components/dock/LogsTab.tsx +3 -0
- package/src/components/gitops/FluxOperatorCard.test.tsx +37 -0
- package/src/components/gitops/FluxOperatorCard.tsx +27 -0
- package/src/components/gitops/GitOpsView.rowsSummary.test.tsx +59 -0
- package/src/components/gitops/GitOpsView.tsx +8 -5
- package/src/components/gitops/gitopsRowEvents.test.ts +48 -0
- package/src/components/gitops/gitopsRowEvents.ts +31 -0
- package/src/components/helm/HelmDrawerFrame.tsx +1 -1
- package/src/components/helm/HelmView.tsx +20 -16
- package/src/components/helm/OwnedResources.tsx +4 -3
- package/src/components/home/ClusterHealthCard.tsx +3 -1
- package/src/components/home/HomeAgentBlock.tsx +3 -0
- package/src/components/home/HomeView.tsx +7 -0
- package/src/components/home/MCPSetupDialog.test.tsx +19 -12
- package/src/components/home/MCPSetupDialog.tsx +4 -2
- package/src/components/home/mcpToolCatalog.ts +15 -2
- package/src/components/home/useVulnerabilitiesRow.test.ts +26 -0
- package/src/components/home/useVulnerabilitiesRow.ts +50 -0
- package/src/components/logs/LogsViewer.tsx +3 -1
- package/src/components/logs/MultiPodLogsTab.test.tsx +24 -4
- package/src/components/logs/MultiPodLogsTab.tsx +9 -5
- package/src/components/nav/PrimaryNavRail.test.tsx +17 -0
- package/src/components/nav/PrimaryNavRail.tsx +174 -29
- package/src/components/resource/PrometheusChartsGrid.tsx +5 -1
- package/src/components/resource/SubstrateHealthCharts.test.tsx +143 -0
- package/src/components/resource/SubstrateHealthCharts.tsx +254 -0
- package/src/components/resource/SubstrateVerdictLine.test.tsx +131 -0
- package/src/components/resource/SubstrateVerdictLine.tsx +180 -0
- package/src/components/resources/ResourcesView.tsx +12 -6
- package/src/components/resources/renderers/UpgradePlanRenderer.test.tsx +20 -0
- package/src/components/resources/renderers/UpgradePlanRenderer.tsx +22 -0
- package/src/components/resources/renderers/VeleroBackupRenderer.tsx +16 -36
- package/src/components/resources/renderers/VeleroRestoreRenderer.tsx +6 -19
- package/src/components/resources/renderers/WorkloadRenderer.tsx +8 -0
- package/src/components/rightsizing/RightsizingScanView.tsx +3 -2
- package/src/components/shared/LargeClusterNamespacePicker.test.tsx +27 -0
- package/src/components/shared/LargeClusterNamespacePicker.tsx +8 -2
- package/src/components/timeline/TimelineView.tsx +3 -1
- package/src/components/traffic/TrafficConnectionsTable.test.tsx +94 -0
- package/src/components/traffic/TrafficConnectionsTable.tsx +21 -5
- package/src/components/traffic/TrafficData.test.tsx +37 -0
- package/src/components/traffic/TrafficData.tsx +27 -0
- package/src/components/traffic/TrafficFlowList.tsx +9 -7
- package/src/components/traffic/TrafficGraph.layoutEngine.test.tsx +193 -0
- package/src/components/traffic/TrafficGraph.test.tsx +269 -0
- package/src/components/traffic/TrafficGraph.tsx +135 -64
- package/src/components/traffic/TrafficGraphUnavailable.tsx +57 -0
- package/src/components/traffic/TrafficView.layoutUnavailable.test.tsx +211 -0
- package/src/components/traffic/TrafficView.tsx +46 -129
- package/src/components/traffic/trafficFilters.test.ts +172 -1
- package/src/components/traffic/trafficFilters.ts +139 -0
- package/src/components/ui/DiagnosticsOverlay.tsx +14 -1
- package/src/components/ui/UpdateNotification.manual.test.tsx +5 -2
- package/src/components/ui/UpdateNotification.test.tsx +31 -2
- package/src/components/ui/UpdateNotification.tsx +34 -17
- package/src/components/ui/command-items.ts +24 -1
- package/src/components/velero/VeleroBackupNow.test.tsx +165 -0
- package/src/components/velero/VeleroBackupNow.tsx +143 -0
- package/src/components/velero/VeleroDeleteBackup.test.tsx +364 -0
- package/src/components/velero/VeleroDeleteBackup.tsx +306 -0
- package/src/components/velero/VeleroDetailPage.tsx +158 -0
- package/src/components/velero/VeleroKindLists.test.tsx +48 -0
- package/src/components/velero/VeleroKindLists.tsx +43 -0
- package/src/components/velero/VeleroLocations.expand.test.tsx +27 -0
- package/src/components/velero/VeleroLocations.test.tsx +86 -0
- package/src/components/velero/VeleroLocations.tsx +240 -0
- package/src/components/velero/VeleroOverview.test.tsx +311 -0
- package/src/components/velero/VeleroOverview.tsx +485 -0
- package/src/components/velero/VeleroPages.test.tsx +516 -0
- package/src/components/velero/VeleroPages.tsx +1056 -0
- package/src/components/velero/VeleroRunArtifacts.test.tsx +241 -0
- package/src/components/velero/VeleroRunArtifacts.tsx +112 -0
- package/src/components/velero/VeleroRunLists.tsx +309 -0
- package/src/components/velero/VeleroRunMessagesHost.test.tsx +25 -0
- package/src/components/velero/VeleroRunMessagesHost.tsx +54 -0
- package/src/components/velero/VeleroRunVolumes.test.tsx +247 -0
- package/src/components/velero/VeleroRunVolumes.tsx +122 -0
- package/src/components/velero/VeleroSchedulePause.test.tsx +211 -0
- package/src/components/velero/VeleroSchedulePause.tsx +191 -0
- package/src/components/velero/VeleroScheduleStatusBadge.test.tsx +28 -0
- package/src/components/velero/VeleroScheduleStatusBadge.tsx +21 -0
- package/src/components/velero/VeleroSchedules.tsx +255 -0
- package/src/components/velero/VeleroView.tsx +59 -0
- package/src/components/velero/VeleroWorkspace.gate.test.tsx +97 -0
- package/src/components/velero/attention.test.ts +178 -0
- package/src/components/velero/attention.ts +281 -0
- package/src/components/velero/backupDelete.test.tsx +91 -0
- package/src/components/velero/backupDelete.tsx +182 -0
- package/src/components/velero/coverage.test.ts +87 -0
- package/src/components/velero/coverage.ts +150 -0
- package/src/components/velero/host.tsx +92 -0
- package/src/components/velero/routes.ts +78 -0
- package/src/components/velero/runs.tsx +121 -0
- package/src/components/velero/shared.test.ts +84 -0
- package/src/components/velero/shared.tsx +423 -0
- package/src/components/velero/useVeleroSidebarWorkspace.test.tsx +28 -0
- package/src/components/velero/useVeleroSidebarWorkspace.ts +71 -0
- package/src/components/velero/velero.fixtures.ts +61 -0
- package/src/components/velero/workspaceRoute.ts +21 -0
- package/src/components/vulnerabilities/WorkloadVulnerabilitiesSection.tsx +179 -0
- package/src/components/vulnerabilities/parts.test.ts +72 -0
- package/src/components/vulnerabilities/parts.tsx +291 -0
- package/src/components/whats-new/WhatsNewDialog.test.tsx +6 -4
- package/src/components/whats-new/releaseNotes.ts +67 -1
- package/src/components/workload/WorkloadView.tsx +64 -27
- package/src/components/workspace/DrawerTrailBack.tsx +32 -0
- package/src/components/workspace/WorkspaceFrame.tsx +71 -0
- package/src/components/workspace/coverage.ts +61 -0
- package/src/components/workspace/layout.test.tsx +29 -1
- package/src/components/workspace/layout.tsx +15 -5
- package/src/components/workspace/sidebar.ts +9 -0
- package/src/components/workspace/useWorkspaceDrawer.ts +63 -0
- package/src/components/workspace/useWorkspaceNavigate.ts +21 -0
- package/src/desktop/AboutDialog.test.ts +12 -0
- package/src/desktop/AboutDialog.tsx +151 -0
- package/src/desktop/WindowsTitleBar.tsx +359 -0
- package/src/desktop/titleBar.test.ts +61 -0
- package/src/desktop/titleBar.ts +45 -0
- package/src/index.css +19 -0
- package/src/integrations/resourceHost.ts +5 -1
- package/src/integrations/resourceHosts.test.tsx +14 -2
- package/src/integrations/resourceHosts.tsx +22 -6
- package/src/integrations/workspaceRoute.ts +1 -1
- package/src/integrations/workspaceRoutes.test.ts +11 -0
- package/src/integrations/workspaceRoutes.ts +3 -1
- package/src/integrations/workspaceScreens.tsx +2 -0
- package/src/main.tsx +8 -0
- package/src/utils/desktop-zoom.test.ts +53 -0
- package/src/utils/desktop-zoom.ts +30 -0
- package/src/utils/staleAssetPrompt.test.tsx +76 -0
- package/src/utils/staleAssetPrompt.tsx +32 -0
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
import { useEffect, useState, type ReactNode } from 'react'
|
|
2
|
+
import type { UseQueryResult } from '@tanstack/react-query'
|
|
3
|
+
import { Archive } from 'lucide-react'
|
|
4
|
+
import {
|
|
5
|
+
PaneLoader,
|
|
6
|
+
RadarUpgradeAction,
|
|
7
|
+
Tooltip,
|
|
8
|
+
getRadarUpgradeRequirement,
|
|
9
|
+
hasLabelSelectorTerms,
|
|
10
|
+
issueTitle,
|
|
11
|
+
radarUpgradeDetail,
|
|
12
|
+
radarUpgradeHeadline,
|
|
13
|
+
veleroPlainReason,
|
|
14
|
+
veleroReasonNextStep,
|
|
15
|
+
type VeleroIssue,
|
|
16
|
+
type VeleroWorkspaceKey,
|
|
17
|
+
type VeleroWorkspaceResponse,
|
|
18
|
+
type WorkspaceProblem,
|
|
19
|
+
} from '@skyhook-io/k8s-ui'
|
|
20
|
+
import type { SelectedResource } from '../../types'
|
|
21
|
+
import { useConnection } from '../../context/ConnectionContext'
|
|
22
|
+
import { refToSelectedResource } from '../../utils/navigation'
|
|
23
|
+
import { Notice, RefreshFailedNotice, ScreenEmptyState, Segments } from '../workspace/layout'
|
|
24
|
+
import { INCOMPLETE_COVERAGE_STATES, coverageLabel } from '../workspace/coverage'
|
|
25
|
+
import { VELERO_GROUP } from './routes'
|
|
26
|
+
|
|
27
|
+
export interface VeleroScreenProps {
|
|
28
|
+
data: VeleroWorkspaceResponse
|
|
29
|
+
/** The installation namespace the screen is narrowed to; null for all of them. */
|
|
30
|
+
installation: string | null
|
|
31
|
+
onInstallation: (namespace: string | null) => void
|
|
32
|
+
onInspect: (resource: SelectedResource) => void
|
|
33
|
+
inspected: SelectedResource | null
|
|
34
|
+
/** Create one of the screen's kind, where the screen is a kind's list. */
|
|
35
|
+
onCreate?: () => void
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const KIND_LABEL: Record<VeleroWorkspaceKey, string> = {
|
|
39
|
+
schedules: 'Schedule',
|
|
40
|
+
backups: 'Backup',
|
|
41
|
+
backupStorageLocations: 'BackupStorageLocation',
|
|
42
|
+
restores: 'Restore',
|
|
43
|
+
backupRepositories: 'BackupRepository',
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function list(values: unknown): string[] {
|
|
47
|
+
return Array.isArray(values) ? values.filter((v): v is string => typeof v === 'string') : []
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Exclusions Velero writes into every spec it processes (v1.18 backup and
|
|
51
|
+
// restore controllers), so they say nothing about what the user chose. A
|
|
52
|
+
// backup gets the CSI snapshot kinds: both in excludedResources with the old
|
|
53
|
+
// filters, else split across the scoped lists. A restore gets the kinds
|
|
54
|
+
// Velero never restores.
|
|
55
|
+
const VELERO_SNAPSHOT = 'volumesnapshots.snapshot.storage.k8s.io'
|
|
56
|
+
const VELERO_SNAPSHOT_CONTENT = 'volumesnapshotcontents.snapshot.storage.k8s.io'
|
|
57
|
+
const VELERO_BACKUP_EXCLUSIONS: Record<string, readonly string[]> = {
|
|
58
|
+
excludedResources: [VELERO_SNAPSHOT, VELERO_SNAPSHOT_CONTENT],
|
|
59
|
+
excludedClusterScopedResources: [VELERO_SNAPSHOT_CONTENT],
|
|
60
|
+
excludedNamespaceScopedResources: [VELERO_SNAPSHOT],
|
|
61
|
+
}
|
|
62
|
+
const VELERO_NON_RESTORABLE = [
|
|
63
|
+
'nodes',
|
|
64
|
+
'events',
|
|
65
|
+
'events.events.k8s.io',
|
|
66
|
+
'backups.velero.io',
|
|
67
|
+
'restores.velero.io',
|
|
68
|
+
'resticrepositories.velero.io',
|
|
69
|
+
'csinodes.storage.k8s.io',
|
|
70
|
+
'volumeattachments.storage.k8s.io',
|
|
71
|
+
'backuprepositories.velero.io',
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
const RESOURCE_FILTERS = [
|
|
75
|
+
'includedResources',
|
|
76
|
+
'excludedResources',
|
|
77
|
+
'includedClusterScopedResources',
|
|
78
|
+
'excludedClusterScopedResources',
|
|
79
|
+
'includedNamespaceScopedResources',
|
|
80
|
+
'excludedNamespaceScopedResources',
|
|
81
|
+
] as const
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* A run's or template's namespace selection as declared, and whether resource
|
|
85
|
+
* or label filters narrow it. `kind` says which exclusions Velero adds on its
|
|
86
|
+
* own (a schedule's template becomes a backup's spec), so they are not counted.
|
|
87
|
+
*/
|
|
88
|
+
export function selectionText(spec: any, emptyMeans: string, kind: 'backup' | 'restore' = 'backup'): { text: string; narrowed: boolean } {
|
|
89
|
+
const included = list(spec?.includedNamespaces)
|
|
90
|
+
const excluded = list(spec?.excludedNamespaces)
|
|
91
|
+
const base = included.length === 0 || included.includes('*') ? emptyMeans : included.join(', ')
|
|
92
|
+
const text = excluded.length ? `${base}, except ${excluded.join(', ')}` : base
|
|
93
|
+
const injected = (field: string): readonly string[] =>
|
|
94
|
+
kind === 'restore' ? (field === 'excludedResources' ? VELERO_NON_RESTORABLE : []) : (VELERO_BACKUP_EXCLUSIONS[field] ?? [])
|
|
95
|
+
// `*` in an include list is everything; in an exclude list it drops the whole scope, which narrows.
|
|
96
|
+
const narrowed =
|
|
97
|
+
RESOURCE_FILTERS.some((field) => list(spec?.[field]).some((v) => (field.startsWith('included') ? v !== '*' : !injected(field).includes(v)))) ||
|
|
98
|
+
hasLabelSelectorTerms(spec?.labelSelector) ||
|
|
99
|
+
(Array.isArray(spec?.orLabelSelectors) && spec.orLabelSelectors.length > 0 && spec.orLabelSelectors.every(hasLabelSelectorTerms))
|
|
100
|
+
return { text, narrowed }
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** A restore's namespace selection: its spec, or a run row's copy of it. */
|
|
104
|
+
export interface RestoreSelection {
|
|
105
|
+
includedNamespaces?: unknown
|
|
106
|
+
excludedNamespaces?: unknown
|
|
107
|
+
namespaceMapping?: Record<string, string>
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Where a restore puts things: every namespace in the backup or the ones it
|
|
112
|
+
* includes, each mapped one with its destination, and what it excludes. A
|
|
113
|
+
* mapping for an excluded namespace does nothing, since Velero restores
|
|
114
|
+
* nothing from it.
|
|
115
|
+
*/
|
|
116
|
+
export function restoreTargets(spec: RestoreSelection | undefined): { every: boolean; entries: { from: string; to?: string }[]; excluded: string[] } {
|
|
117
|
+
const included = list(spec?.includedNamespaces)
|
|
118
|
+
const excluded = list(spec?.excludedNamespaces)
|
|
119
|
+
const mapping = spec?.namespaceMapping ?? {}
|
|
120
|
+
const every = included.length === 0 || included.includes('*')
|
|
121
|
+
const entries = every
|
|
122
|
+
? Object.entries(mapping).filter(([from]) => !excluded.includes(from)).map(([from, to]) => ({ from, to }))
|
|
123
|
+
: included.map((from) => ({ from, to: mapping[from] }))
|
|
124
|
+
return { every, entries, excluded }
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** "Every namespace in the backup, with a → b, except c", or "a → b, shop". */
|
|
128
|
+
export function restoredIntoText(spec: RestoreSelection | undefined): string {
|
|
129
|
+
const { every, entries, excluded } = restoreTargets(spec)
|
|
130
|
+
const named = entries.map((e) => (e.to ? `${e.from} → ${e.to}` : e.from)).join(', ')
|
|
131
|
+
const base = every ? `Every namespace in the backup${entries.length ? `, with ${named}` : ''}` : named
|
|
132
|
+
return excluded.length ? `${base}, except ${excluded.join(', ')}` : base
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Characters a run's name keeps after the cut: the end of its timestamp, which tells runs apart.
|
|
136
|
+
const RUN_NAME_TAIL = 6
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* An object's name in a table: mono, one line, cut with an ellipsis and whole
|
|
140
|
+
* on hover. `middle` cuts a run's name in the middle, keeping its end
|
|
141
|
+
* (`nightly-2026…41210`), since runs of one schedule differ only there.
|
|
142
|
+
*/
|
|
143
|
+
export function VeleroName({ name, middle }: { name: string; middle?: boolean }) {
|
|
144
|
+
if (middle && name.length > RUN_NAME_TAIL * 2) {
|
|
145
|
+
return (
|
|
146
|
+
<Tooltip content={name} wrapperClassName="min-w-0">
|
|
147
|
+
<span className="flex min-w-0 font-mono text-sm">
|
|
148
|
+
<span className="min-w-0 truncate">{name.slice(0, -RUN_NAME_TAIL)}</span>
|
|
149
|
+
<span className="shrink-0">{name.slice(-RUN_NAME_TAIL)}</span>
|
|
150
|
+
</span>
|
|
151
|
+
</Tooltip>
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
return (
|
|
155
|
+
<Tooltip content={name}>
|
|
156
|
+
<span className="block min-w-0 truncate font-mono text-sm">{name}</span>
|
|
157
|
+
</Tooltip>
|
|
158
|
+
)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Text that names objects, wrapped only between words: a browser would
|
|
163
|
+
* otherwise break a name at its hyphen ("dr-" / "replica"). A name wider than
|
|
164
|
+
* its column is cut with an ellipsis; callers keep the whole text in a tooltip.
|
|
165
|
+
*/
|
|
166
|
+
export function WholeNames({ text }: { text: string }) {
|
|
167
|
+
return (
|
|
168
|
+
<>
|
|
169
|
+
{text.split(/(\s+)/).map((part, i) =>
|
|
170
|
+
part.includes('-') ? (
|
|
171
|
+
<span key={i} className="inline-block max-w-full truncate align-bottom">
|
|
172
|
+
{part}
|
|
173
|
+
</span>
|
|
174
|
+
) : (
|
|
175
|
+
part
|
|
176
|
+
),
|
|
177
|
+
)}
|
|
178
|
+
</>
|
|
179
|
+
)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* The width the Velero tables show every column at. Below it each table folds
|
|
184
|
+
* its secondary columns into the cell they qualify, so nothing is clipped at
|
|
185
|
+
* the right edge.
|
|
186
|
+
*/
|
|
187
|
+
export const VELERO_WIDE = '(min-width: 1280px)'
|
|
188
|
+
|
|
189
|
+
/** Opens a Velero object in the drawer. */
|
|
190
|
+
export function veleroResource(kind: string, namespace: string, name: string): SelectedResource {
|
|
191
|
+
return refToSelectedResource({ kind, group: VELERO_GROUP, namespace, name })
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** Narrows rows to the selected installation. */
|
|
195
|
+
export function inInstallation<T extends { namespace: string }>(rows: T[], installation: string | null): T[] {
|
|
196
|
+
return installation === null ? rows : rows.filter((r) => r.namespace === installation)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* The title line, a note when Radar is limited to one namespace and, with
|
|
201
|
+
* more than one installation, the installation picker. The namespace picker
|
|
202
|
+
* says the filter does not apply (VELERO_NAMESPACE_FILTER_TOOLTIP). The picker narrows what was already read; it never
|
|
203
|
+
* changes what the server reads.
|
|
204
|
+
*/
|
|
205
|
+
export function VeleroWorkspaceHeader({ title, data, installation, onInstallation }: { title: string } & Pick<VeleroScreenProps, 'data' | 'installation' | 'onInstallation'>) {
|
|
206
|
+
const namespaces = data.installations.map((i) => i.namespace)
|
|
207
|
+
return (
|
|
208
|
+
<div className="px-5 pt-4 xl:px-7">
|
|
209
|
+
<div className="flex flex-wrap items-center gap-x-2">
|
|
210
|
+
<span className="flex items-center gap-1.5 text-sm text-theme-text-tertiary">
|
|
211
|
+
<Archive className="h-3.5 w-3.5" />
|
|
212
|
+
Velero
|
|
213
|
+
<span>/</span>
|
|
214
|
+
</span>
|
|
215
|
+
<h1 className="text-lg font-semibold text-theme-text-primary">{title}</h1>
|
|
216
|
+
</div>
|
|
217
|
+
{data.forcedNamespace && (
|
|
218
|
+
<div className="mt-0.5 text-sm text-theme-text-secondary">
|
|
219
|
+
Radar is limited to namespace {data.forcedNamespace}, so only a Velero installation there is shown.
|
|
220
|
+
</div>
|
|
221
|
+
)}
|
|
222
|
+
{namespaces.length > 1 && (
|
|
223
|
+
<div className="mt-2.5">
|
|
224
|
+
<Segments
|
|
225
|
+
label="Velero installation"
|
|
226
|
+
value={installation ?? ''}
|
|
227
|
+
options={[{ id: '', label: 'All installations' }, ...namespaces.map((ns) => ({ id: ns, label: ns }))]}
|
|
228
|
+
onChange={(id) => onInstallation(id === '' ? null : id)}
|
|
229
|
+
/>
|
|
230
|
+
</div>
|
|
231
|
+
)}
|
|
232
|
+
</div>
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/** Says which kinds this screen reads were not read in full, and why. */
|
|
237
|
+
export function VeleroCoverageNotice({ data, kinds }: { data: VeleroWorkspaceResponse; kinds: readonly VeleroWorkspaceKey[] }) {
|
|
238
|
+
const byLabel = new Map<string, string[]>()
|
|
239
|
+
for (const k of kinds) {
|
|
240
|
+
const cov = data.coverage[k]
|
|
241
|
+
if (cov && !INCOMPLETE_COVERAGE_STATES.has(cov.state)) continue
|
|
242
|
+
const label = coverageLabel(cov)
|
|
243
|
+
byLabel.set(label, [...(byLabel.get(label) ?? []), KIND_LABEL[k]])
|
|
244
|
+
}
|
|
245
|
+
if (byLabel.size === 0) return null
|
|
246
|
+
const text = [...byLabel].map(([label, names]) => `${names.join(', ')} (${label})`).join('; ')
|
|
247
|
+
return (
|
|
248
|
+
<Notice>Radar couldn’t read some of the Velero data on this screen: {text}. What it couldn’t read shows as unknown.</Notice>
|
|
249
|
+
)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** "Name, name and 3 more": a few names, then a count. */
|
|
253
|
+
export function namesAndMore(names: string[], shown = 3): string {
|
|
254
|
+
const head = names.slice(0, shown)
|
|
255
|
+
const rest = names.length - head.length
|
|
256
|
+
if (rest > 0) return `${head.join(', ')} and ${rest} more`
|
|
257
|
+
return head.length > 1 ? `${head.slice(0, -1).join(', ')} and ${head.at(-1)}` : (head[0] ?? '')
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Velero's own messages often end without a full stop; a sentence after one needs it.
|
|
261
|
+
function sentence(text: string | undefined): string {
|
|
262
|
+
const trimmed = (text ?? '').replace(/[\s:;,]+$/, '')
|
|
263
|
+
return trimmed && !/[.!?…)]$/.test(trimmed) ? `${trimmed}.` : trimmed
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/** The runs Velero rejected because of the issue's fault, each a link. */
|
|
267
|
+
function rejectedRuns(issue: VeleroIssue): WorkspaceProblem['related'] {
|
|
268
|
+
const runs = issue.affected ?? []
|
|
269
|
+
if (runs.length === 0) return undefined
|
|
270
|
+
return {
|
|
271
|
+
lead: `Velero rejected ${runs.length === 1 ? '1 run' : `${runs.length} runs`} because of it:`,
|
|
272
|
+
refs: runs.map((r) => ({ kind: r.kind, group: VELERO_GROUP, namespace: r.namespace ?? issue.namespace ?? '', name: r.name })),
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export const VELERO_START_SERVER = 'Start the Velero server Deployment, or find out why its pods don’t run'
|
|
277
|
+
export const VELERO_CHECK_SERVER = 'Check that the Velero server is running, and read its logs'
|
|
278
|
+
export const VELERO_SHORTEN_NAME = 'Recreate the schedule with a name of 63 characters or fewer'
|
|
279
|
+
export const VELERO_WRITABLE_LOCATION = 'Point the schedule at a writable storage location, or set its location back to ReadWrite'
|
|
280
|
+
/** A Velero header delete (Delete backup, Delete object): the generic Delete's hover treatment, on a labelled button like the other header actions. */
|
|
281
|
+
export const VELERO_DELETE_BUTTON =
|
|
282
|
+
'btn-secondary inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap px-2.5 py-1.5 text-xs font-medium hover:text-red-400 hover:border-red-400/50 hover:bg-red-500/10 disabled:cursor-not-allowed disabled:opacity-50'
|
|
283
|
+
|
|
284
|
+
/** The name of the action offered for a Backup Velero never stored (backupDelete.tsx), wherever it is named. */
|
|
285
|
+
export const VELERO_DELETE_OBJECT = 'Delete object'
|
|
286
|
+
export const VELERO_CHECK_HELD_BACKUP = 'Check that the Velero server is running with its backup controller enabled, and inspect its logs for the queued backup.'
|
|
287
|
+
|
|
288
|
+
// The next step for each Velero Issue whose message Radar doesn't recognise.
|
|
289
|
+
const ISSUE_NEXT_STEP: Record<string, string> = {
|
|
290
|
+
BackupFailed: 'Show its errors, fix the cause, and run the backup again',
|
|
291
|
+
BackupPartiallyFailed: 'Show its errors to see what was not backed up, and run the backup again once fixed',
|
|
292
|
+
BackupValidationFailed: 'Fix what Velero rejected, and create the backup again',
|
|
293
|
+
RestoreFailed: 'Show its errors, fix the cause, and run the restore again',
|
|
294
|
+
RestorePartiallyFailed: 'Show its errors to see what was not restored',
|
|
295
|
+
RestoreValidationFailed: 'Fix what Velero rejected, and create the restore again',
|
|
296
|
+
ScheduleValidationFailed: 'Fix what Velero rejected in the schedule; Velero validates it again when it changes',
|
|
297
|
+
BackupStorageLocationUnavailable: 'Check the storage location’s bucket, credentials and endpoint',
|
|
298
|
+
BackupRepositoryNotReady: 'Read the repository’s message and the Velero server’s logs',
|
|
299
|
+
BackupRepositoryMaintenanceFailed: 'Read the maintenance job’s logs',
|
|
300
|
+
VeleroRunStalled: VELERO_CHECK_SERVER,
|
|
301
|
+
VeleroServerNotRunning: VELERO_START_SERVER,
|
|
302
|
+
VeleroScheduleLate: 'Check that the Velero server is running with its schedule controller, and read its logs',
|
|
303
|
+
VeleroScheduleHeld: VELERO_CHECK_HELD_BACKUP,
|
|
304
|
+
VeleroScheduleNotValidated: VELERO_CHECK_SERVER,
|
|
305
|
+
VeleroLocationValidationOverdue: VELERO_CHECK_SERVER,
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* What to do about a Velero Issue, in one plain line: the Issue's own action,
|
|
310
|
+
* else what its message means, else the step for its kind of fault.
|
|
311
|
+
*/
|
|
312
|
+
export function veleroIssueNextStep(issue: Pick<VeleroIssue, 'action' | 'message' | 'reason'>): string | undefined {
|
|
313
|
+
const action = issue.action?.trim()
|
|
314
|
+
if (action) return action
|
|
315
|
+
if (issue.reason === 'VeleroScheduleCannotRun') {
|
|
316
|
+
if (/63 characters/.test(issue.message ?? '')) return VELERO_SHORTEN_NAME
|
|
317
|
+
if (/is read-only/.test(issue.message ?? '')) return VELERO_WRITABLE_LOCATION
|
|
318
|
+
}
|
|
319
|
+
const fromMessage = veleroReasonNextStep(issue.message)
|
|
320
|
+
if (fromMessage) return fromMessage
|
|
321
|
+
if (issue.reason === 'VeleroScheduleCannotRun') return 'Change the cron expression to one with a future time'
|
|
322
|
+
return issue.reason ? ISSUE_NEXT_STEP[issue.reason] : undefined
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* An Issues row as a workspace problem. A message Radar recognises reads as
|
|
327
|
+
* one plain line, with Velero's own text folded under it. `withNextStep` adds
|
|
328
|
+
* what to do, for a banner with room for it.
|
|
329
|
+
*/
|
|
330
|
+
export function veleroIssueProblem(issue: VeleroIssue, opts?: { withNextStep?: boolean }): WorkspaceProblem {
|
|
331
|
+
const message = issue.message?.trim()
|
|
332
|
+
const plain = veleroPlainReason(message)
|
|
333
|
+
return {
|
|
334
|
+
id: issue.id,
|
|
335
|
+
category: issue.category,
|
|
336
|
+
// The title the Issues page gives the same row.
|
|
337
|
+
title: issueTitle(issue),
|
|
338
|
+
detail: [plain ?? message, issue.cause?.trim()].filter(Boolean).map(sentence).join(' ') || undefined,
|
|
339
|
+
related: rejectedRuns(issue),
|
|
340
|
+
rawDetail: plain ? message : undefined,
|
|
341
|
+
rawDetailLabel: plain ? VELERO_MESSAGE_LABEL : undefined,
|
|
342
|
+
nextStep: opts?.withNextStep ? veleroIssueNextStep(issue) : undefined,
|
|
343
|
+
subject: { kind: issue.kind, group: issue.group ?? VELERO_GROUP, namespace: issue.namespace ?? '', name: issue.name },
|
|
344
|
+
source: 'issue',
|
|
345
|
+
tone: issue.severity === 'critical' ? 'unhealthy' : 'degraded',
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/** The label of a raw Velero message folded under its plain reading. */
|
|
350
|
+
export const VELERO_MESSAGE_LABEL = 'Velero’s message'
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Loading, error, needs-newer-Radar and not-installed states both Velero
|
|
354
|
+
* screens share. Renders the screen only once there is workspace data.
|
|
355
|
+
*/
|
|
356
|
+
export function VeleroScreenGate({
|
|
357
|
+
query,
|
|
358
|
+
discoveryPending,
|
|
359
|
+
discovered,
|
|
360
|
+
children,
|
|
361
|
+
}: {
|
|
362
|
+
query: Pick<UseQueryResult<VeleroWorkspaceResponse>, 'data' | 'error' | 'isLoading' | 'isFetching' | 'refetch' | 'isRefetchError' | 'dataUpdatedAt'>
|
|
363
|
+
/** API discovery has not answered yet, so whether Velero is served is not known. */
|
|
364
|
+
discoveryPending: boolean
|
|
365
|
+
/** Discovery answered and serves velero.io, or could not be read (the server is asked then). */
|
|
366
|
+
discovered: boolean
|
|
367
|
+
children: (data: VeleroWorkspaceResponse) => ReactNode
|
|
368
|
+
}) {
|
|
369
|
+
const { connection } = useConnection()
|
|
370
|
+
const data = query.data
|
|
371
|
+
const notInstalled = (
|
|
372
|
+
<ScreenEmptyState
|
|
373
|
+
icon={Archive}
|
|
374
|
+
title="Velero is not installed"
|
|
375
|
+
detail={`No velero.io resources are served in ${connection.context || 'this cluster'}.`}
|
|
376
|
+
/>
|
|
377
|
+
)
|
|
378
|
+
if (!data && (query.isLoading || discoveryPending)) return <PaneLoader label="Loading Velero…" className="flex-1" />
|
|
379
|
+
if (!data && !discovered) return notInstalled
|
|
380
|
+
if (!data) {
|
|
381
|
+
const upgrade = getRadarUpgradeRequirement(query.error)
|
|
382
|
+
if (upgrade) {
|
|
383
|
+
return (
|
|
384
|
+
<ScreenEmptyState
|
|
385
|
+
icon={Archive}
|
|
386
|
+
title={radarUpgradeHeadline('Velero')}
|
|
387
|
+
detail={radarUpgradeDetail(upgrade)}
|
|
388
|
+
action={
|
|
389
|
+
<div className="mt-3 text-sm">
|
|
390
|
+
<RadarUpgradeAction requirement={upgrade} />
|
|
391
|
+
</div>
|
|
392
|
+
}
|
|
393
|
+
/>
|
|
394
|
+
)
|
|
395
|
+
}
|
|
396
|
+
return (
|
|
397
|
+
<ScreenEmptyState
|
|
398
|
+
icon={Archive}
|
|
399
|
+
title="Velero data unavailable"
|
|
400
|
+
detail={query.error instanceof Error ? query.error.message : 'Radar could not load the Velero data.'}
|
|
401
|
+
action={
|
|
402
|
+
<button type="button" onClick={() => void query.refetch()} disabled={query.isFetching} className="btn-secondary mt-3 px-3 py-1.5 text-sm">
|
|
403
|
+
{query.isFetching ? 'Retrying…' : 'Retry'}
|
|
404
|
+
</button>
|
|
405
|
+
}
|
|
406
|
+
/>
|
|
407
|
+
)
|
|
408
|
+
}
|
|
409
|
+
if (!data.installed) return notInstalled
|
|
410
|
+
return <><RefreshFailedNotice queries={[query]} className="px-5 pt-3 xl:px-7" />{children(data)}</>
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* The installation chips' selection. They narrow what was read; a namespace
|
|
415
|
+
* that is no longer read drops the narrowing rather than showing an empty screen.
|
|
416
|
+
*/
|
|
417
|
+
export function useVeleroInstallation(installations: VeleroWorkspaceResponse['installations'] | undefined) {
|
|
418
|
+
const [installation, setInstallation] = useState<string | null>(null)
|
|
419
|
+
useEffect(() => {
|
|
420
|
+
if (installation !== null && installations && !installations.some((i) => i.namespace === installation)) setInstallation(null)
|
|
421
|
+
}, [installation, installations])
|
|
422
|
+
return [installation, setInstallation] as const
|
|
423
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
2
|
+
import { expect, it, vi } from 'vitest'
|
|
3
|
+
import { ResourcesSidebar } from '@skyhook-io/k8s-ui'
|
|
4
|
+
import { useVeleroSidebarWorkspace } from './useVeleroSidebarWorkspace'
|
|
5
|
+
|
|
6
|
+
vi.mock('../../api/client', () => ({ useRadarFeature: () => ({ support: 'supported' }) }))
|
|
7
|
+
vi.mock('../../api/velero', async () => {
|
|
8
|
+
const { workspace: build } = await import('./velero.fixtures')
|
|
9
|
+
return { useVeleroWorkspace: () => ({ data: build() }) }
|
|
10
|
+
})
|
|
11
|
+
vi.mock('../workspace/useWorkspaceNavigate', () => ({ useWorkspaceNavigate: () => vi.fn() }))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
it('names the integration for its job, with Velero beneath, and lists its destinations by the names their pages use', () => {
|
|
15
|
+
const crd = (kind: string, name: string) => ({ group: 'velero.io', version: 'v1', kind, name, namespaced: true, isCrd: true, verbs: ['list'] })
|
|
16
|
+
const apiResources = [crd('Backup', 'backups'), crd('Schedule', 'schedules'), crd('Restore', 'restores'), crd('BackupStorageLocation', 'backupstoragelocations'), crd('DeleteBackupRequest', 'deletebackuprequests')] as any
|
|
17
|
+
const result = { value: undefined as ReturnType<typeof useVeleroSidebarWorkspace> }
|
|
18
|
+
function Sidebar() {
|
|
19
|
+
result.value = useVeleroSidebarWorkspace({ apiResources })
|
|
20
|
+
return <ResourcesSidebar selectedKind={{ name: 'backupstoragelocations', kind: 'BackupStorageLocation', group: 'velero.io' }} onSelectedKindChange={() => {}} apiResources={apiResources} categoryWorkspaces={result.value} />
|
|
21
|
+
}
|
|
22
|
+
const html = renderToStaticMarkup(<Sidebar />)
|
|
23
|
+
expect(result.value?.Velero.label).toBe('Backup & restore')
|
|
24
|
+
expect(result.value?.Velero.destinations.map((d) => d.label)).toEqual(['Overview', 'Backups', 'Schedules', 'Restores', 'Storage locations'])
|
|
25
|
+
expect(html).toMatch(/>Backup & restore<\/span><span[^>]*>Velero</)
|
|
26
|
+
expect(html).toMatch(/aria-current="page"[^>]*>(?:(?!<\/button>).)*Storage locations/)
|
|
27
|
+
expect(html).toMatch(/Other kinds \((<!-- -->)?1(<!-- -->)?\)/)
|
|
28
|
+
})
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { useMemo } from 'react'
|
|
2
|
+
import { Archive } from 'lucide-react'
|
|
3
|
+
import type { SidebarCategoryWorkspace } from '@skyhook-io/k8s-ui'
|
|
4
|
+
import type { APIResource } from '../../types'
|
|
5
|
+
import { useRadarFeature } from '../../api/client'
|
|
6
|
+
import { useVeleroWorkspace } from '../../api/velero'
|
|
7
|
+
import { useWorkspaceNavigate } from '../workspace/useWorkspaceNavigate'
|
|
8
|
+
import { VELERO_BACKUP_KIND, VELERO_DETAIL_KINDS, VELERO_GROUP, VELERO_LOCATION_KIND, VELERO_OVERVIEW, VELERO_RESTORE_KIND, VELERO_SCHEDULE_KIND } from './routes'
|
|
9
|
+
import { veleroAttentionCount, veleroScreenCounts, type VeleroScreen } from './attention'
|
|
10
|
+
|
|
11
|
+
/** The Resources sidebar category Velero kinds are listed under (api-resources.ts). */
|
|
12
|
+
export const VELERO_SIDEBAR_CATEGORY = 'Velero'
|
|
13
|
+
|
|
14
|
+
/** The job Velero does, its name in the sidebar's Integrations; "Velero" sits beneath it. */
|
|
15
|
+
export const VELERO_SIDEBAR_LABEL = 'Backup & restore'
|
|
16
|
+
|
|
17
|
+
export function veleroDiscovered(apiResources: APIResource[] | undefined): boolean {
|
|
18
|
+
return !!apiResources?.some((r) => r.group === VELERO_GROUP)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Each list is named as its objects' pages name it ("Velero / Storage locations /").
|
|
22
|
+
const SCREENS = [VELERO_BACKUP_KIND, VELERO_SCHEDULE_KIND, VELERO_RESTORE_KIND, VELERO_LOCATION_KIND].map((kind) => ({ kind, label: VELERO_DETAIL_KINDS[kind.name].label }))
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Velero in the sidebar's Integrations: one row with what needs attention
|
|
26
|
+
* across every installation, opening to the Overview and Radar's four tables
|
|
27
|
+
* (each with what needs attention there), with Velero's other kinds folded
|
|
28
|
+
* beneath. Undefined when Velero is not discovered, or the connected Radar is
|
|
29
|
+
* known to predate the views. The namespace filter does not apply to Velero.
|
|
30
|
+
*/
|
|
31
|
+
export function useVeleroSidebarWorkspace({
|
|
32
|
+
apiResources,
|
|
33
|
+
active,
|
|
34
|
+
}: {
|
|
35
|
+
apiResources: APIResource[] | undefined
|
|
36
|
+
/** The Overview is on screen. */
|
|
37
|
+
active?: boolean
|
|
38
|
+
}): Record<string, SidebarCategoryWorkspace> | undefined {
|
|
39
|
+
const navigate = useWorkspaceNavigate()
|
|
40
|
+
const { support } = useRadarFeature('veleroWorkspace')
|
|
41
|
+
const available = veleroDiscovered(apiResources) && support !== 'unsupported'
|
|
42
|
+
const { data } = useVeleroWorkspace({ enabled: available })
|
|
43
|
+
const counts = useMemo(() => (data?.installed ? { total: veleroAttentionCount(data), screens: veleroScreenCounts(data) } : undefined), [data])
|
|
44
|
+
return useMemo(() => {
|
|
45
|
+
if (!available) return undefined
|
|
46
|
+
return {
|
|
47
|
+
[VELERO_SIDEBAR_CATEGORY]: {
|
|
48
|
+
label: VELERO_SIDEBAR_LABEL,
|
|
49
|
+
icon: Archive,
|
|
50
|
+
count: counts?.total.count,
|
|
51
|
+
countLowerBound: counts?.total.lowerBound,
|
|
52
|
+
countTitle: counts?.total.title,
|
|
53
|
+
destinations: [
|
|
54
|
+
{ id: 'overview', label: VELERO_OVERVIEW.label, active: !!active, onSelect: () => navigate(VELERO_OVERVIEW.path) },
|
|
55
|
+
...SCREENS.map(({ kind, label }) => {
|
|
56
|
+
const c = counts?.screens[kind.name as VeleroScreen]
|
|
57
|
+
return {
|
|
58
|
+
id: kind.name,
|
|
59
|
+
label,
|
|
60
|
+
kind,
|
|
61
|
+
count: c?.count,
|
|
62
|
+
countLowerBound: c?.lowerBound,
|
|
63
|
+
countTitle: c?.title,
|
|
64
|
+
onSelect: () => navigate(VELERO_DETAIL_KINDS[kind.name].listPath),
|
|
65
|
+
}
|
|
66
|
+
}),
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
}
|
|
70
|
+
}, [available, active, navigate, counts])
|
|
71
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { VeleroLocationReading, VeleroScheduleReading, VeleroWorkspaceResponse } from '@skyhook-io/k8s-ui'
|
|
2
|
+
|
|
3
|
+
const hoursAgo = (h: number) => new Date(Date.now() - h * 3_600_000).toISOString()
|
|
4
|
+
const hoursAhead = (h: number) => new Date(Date.now() + h * 3_600_000).toISOString()
|
|
5
|
+
|
|
6
|
+
export function schedule(overrides: Partial<VeleroScheduleReading> = {}): VeleroScheduleReading {
|
|
7
|
+
return {
|
|
8
|
+
namespace: 'velero',
|
|
9
|
+
name: 'nightly',
|
|
10
|
+
created: hoursAgo(720),
|
|
11
|
+
cron: '0 2 * * *',
|
|
12
|
+
zone: { name: 'UTC', source: 'serverDefault' },
|
|
13
|
+
state: 'onSchedule',
|
|
14
|
+
attention: false,
|
|
15
|
+
lastSubmitted: hoursAgo(2),
|
|
16
|
+
nextRun: hoursAhead(22),
|
|
17
|
+
nextRunCertain: true,
|
|
18
|
+
runs: { read: 'full', kept: 1, newest: { name: 'nightly-1', phase: 'Completed', created: hoursAgo(2), ranAt: hoursAgo(2) }, newestCompleted: { name: 'nightly-1', phase: 'Completed', created: hoursAgo(2), ranAt: hoursAgo(2) } },
|
|
19
|
+
location: { name: 'default' },
|
|
20
|
+
ttl: '',
|
|
21
|
+
includedNamespaces: [],
|
|
22
|
+
excludedNamespaces: [],
|
|
23
|
+
...overrides,
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function location(overrides: Partial<VeleroLocationReading> = {}): VeleroLocationReading {
|
|
28
|
+
return {
|
|
29
|
+
namespace: 'velero',
|
|
30
|
+
name: 'default',
|
|
31
|
+
phase: 'Available',
|
|
32
|
+
provider: 'aws',
|
|
33
|
+
bucket: 'backups',
|
|
34
|
+
lastValidation: hoursAgo(0.01),
|
|
35
|
+
frequency: { seconds: 60, source: 'server' },
|
|
36
|
+
default: true,
|
|
37
|
+
defaultSource: 'spec',
|
|
38
|
+
backups: { targeting: 3, completedNotExpired: 2, expired: 1 },
|
|
39
|
+
schedules: [{ name: 'nightly' }],
|
|
40
|
+
attention: false,
|
|
41
|
+
...overrides,
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function workspace(overrides: Partial<VeleroWorkspaceResponse> = {}): VeleroWorkspaceResponse {
|
|
46
|
+
const full = { state: 'full' as const }
|
|
47
|
+
return {
|
|
48
|
+
observedAt: new Date().toISOString(),
|
|
49
|
+
installed: true,
|
|
50
|
+
context: 'kind-radar-velero-demo',
|
|
51
|
+
coverage: { schedules: full, backups: full, backupStorageLocations: full, restores: full, backupRepositories: full },
|
|
52
|
+
installations: [{ namespace: 'velero', server: { source: 'deployment', timeZone: 'UTC', defaultLocation: 'default', validationFrequencySeconds: 60 }, defaultLocation: 'default', defaultSource: 'spec' }],
|
|
53
|
+
schedules: [schedule()],
|
|
54
|
+
locations: [location()],
|
|
55
|
+
issues: [],
|
|
56
|
+
issueTotals: {},
|
|
57
|
+
...overrides,
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export { hoursAgo, hoursAhead }
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { WorkspaceRoute } from '../../integrations/workspaceRoute'
|
|
2
|
+
import { VELERO_NAMESPACE_FILTER_TOOLTIP, VELERO_OVERVIEW, parseVeleroRoute } from './routes'
|
|
3
|
+
|
|
4
|
+
export const veleroWorkspaceRoute: WorkspaceRoute = {
|
|
5
|
+
id: 'velero',
|
|
6
|
+
path: '/velero',
|
|
7
|
+
label: 'Velero',
|
|
8
|
+
navView: 'resources',
|
|
9
|
+
namespaceScope: 'cluster',
|
|
10
|
+
namespaceFilterTooltip: VELERO_NAMESPACE_FILTER_TOOLTIP,
|
|
11
|
+
pageTitle(pathname) {
|
|
12
|
+
return parseVeleroRoute(pathname).detail?.name ?? VELERO_OVERVIEW.title
|
|
13
|
+
},
|
|
14
|
+
contextSwitchSearch(pathname, search) {
|
|
15
|
+
// A page's context pin keeps a same-named object from another cluster from opening.
|
|
16
|
+
const next = new URLSearchParams()
|
|
17
|
+
const context = search.get('ctx')
|
|
18
|
+
if (context && pathname.startsWith('/velero/')) next.set('ctx', context)
|
|
19
|
+
return next
|
|
20
|
+
},
|
|
21
|
+
}
|