@skyhook-io/radar-app 1.18.2 → 1.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +7 -7
- package/src/App.tsx +31 -6
- package/src/api/application-evidence.ts +63 -0
- package/src/api/argoSync.test.ts +22 -0
- package/src/api/client.audit-gating.test.tsx +48 -0
- package/src/api/client.kueuePosition.test.ts +32 -0
- package/src/api/client.kueueQueueWorkloads.test.tsx +71 -0
- package/src/api/client.resource-identity.test.ts +3 -0
- package/src/api/client.resourceIssues.test.tsx +239 -0
- package/src/api/client.resourcePath.test.ts +3 -0
- package/src/api/client.ts +285 -55
- package/src/api/config.ts +21 -0
- package/src/api/diagnose.test.ts +33 -2
- package/src/api/diagnose.ts +97 -3
- package/src/api/radarFeatures.render.test.tsx +33 -1
- package/src/api/radarFeatures.test.ts +47 -0
- package/src/api/radarFeatures.ts +41 -1
- package/src/api/rbac.settled.test.tsx +42 -0
- package/src/api/rbac.test.ts +18 -0
- package/src/api/rbac.ts +37 -7
- package/src/api/traffic.ts +9 -4
- package/src/api/usage-data.fixtures.ts +3 -1
- package/src/api/usage-data.test.tsx +134 -0
- package/src/api/usage-data.ts +35 -7
- package/src/api/workloadPodsPolling.test.ts +26 -0
- package/src/components/CloudConnectFlow.test.tsx +86 -0
- package/src/components/CloudConnectFlow.tsx +65 -27
- package/src/components/CloudFunnelButton.test.tsx +140 -5
- package/src/components/CloudFunnelButton.tsx +50 -9
- package/src/components/ConnectionErrorView.test.tsx +34 -0
- package/src/components/ConnectionErrorView.tsx +35 -11
- package/src/components/ContextSwitcher.tsx +5 -2
- package/src/components/SwitchAwareConnectionError.test.tsx +43 -0
- package/src/components/SwitchAwareConnectionError.tsx +85 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.flow.test.tsx +234 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.test.tsx +144 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.tsx +218 -0
- package/src/components/capacity/CapacityDemand.tsx +3 -2
- package/src/components/capacity/demandSummary.test.ts +38 -0
- package/src/components/capacity/shared.tsx +12 -1
- package/src/components/cost/ApplicationCostTab.tsx +4 -0
- package/src/components/cost/CostTrendChart.tsx +2 -0
- package/src/components/cost/WorkloadCostTab.tsx +4 -0
- package/src/components/cost/source.test.ts +5 -0
- package/src/components/cost/source.ts +11 -0
- package/src/components/diagnose/AIMarkdown.tsx +4 -1
- package/src/components/diagnose/ActivityTurn.tsx +34 -14
- package/src/components/diagnose/AgentControls.tsx +53 -6
- package/src/components/diagnose/AgentSetupNotice.test.tsx +17 -0
- package/src/components/diagnose/AgentSetupNotice.tsx +22 -4
- package/src/components/diagnose/AgentSigninNotice.test.tsx +98 -0
- package/src/components/diagnose/AgentSigninNotice.tsx +61 -0
- package/src/components/diagnose/AnalysisStory.test.tsx +22 -0
- package/src/components/diagnose/AnalysisStory.tsx +17 -4
- package/src/components/diagnose/AssessmentCard.tsx +39 -8
- package/src/components/diagnose/ContinueInAgentButton.mounted.test.tsx +182 -0
- package/src/components/diagnose/ContinueInAgentButton.test.tsx +128 -0
- package/src/components/diagnose/ContinueInAgentButton.tsx +303 -0
- package/src/components/diagnose/DiagnoseContext.capacity.test.tsx +113 -0
- package/src/components/diagnose/DiagnoseContext.question.test.tsx +245 -0
- package/src/components/diagnose/DiagnoseContext.tsx +272 -10
- package/src/components/diagnose/DiagnoseSurface.test.tsx +54 -0
- package/src/components/diagnose/DiagnoseSurface.tsx +151 -134
- package/src/components/diagnose/EvidenceCard.tsx +67 -14
- package/src/components/diagnose/ExampleInvestigationLink.tsx +20 -0
- package/src/components/diagnose/Home.test.tsx +208 -5
- package/src/components/diagnose/Home.tsx +187 -36
- package/src/components/diagnose/InvestigationCapacityNotice.test.tsx +246 -0
- package/src/components/diagnose/InvestigationCapacityNotice.tsx +241 -0
- package/src/components/diagnose/InvestigationEvidencePane.story.test.tsx +97 -6
- package/src/components/diagnose/InvestigationEvidencePane.test.tsx +57 -0
- package/src/components/diagnose/InvestigationEvidencePane.tsx +59 -11
- package/src/components/diagnose/InvestigationEvidenceSections.tsx +50 -23
- package/src/components/diagnose/InvestigationView.tsx +249 -54
- package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +450 -0
- package/src/components/diagnose/LocalDiagnoseAction.tsx +365 -39
- package/src/components/diagnose/NextStepJump.test.tsx +92 -0
- package/src/components/diagnose/NextStepJump.tsx +75 -0
- package/src/components/diagnose/QuestionComposer.test.tsx +553 -0
- package/src/components/diagnose/QuestionComposer.tsx +495 -0
- package/src/components/diagnose/QuestionFocus.test.tsx +38 -0
- package/src/components/diagnose/QuestionFocus.tsx +123 -0
- package/src/components/diagnose/ResourcePicker.tsx +206 -0
- package/src/components/diagnose/StoryExcerpt.tsx +12 -3
- package/src/components/diagnose/assessmentCopy.ts +5 -0
- package/src/components/diagnose/exampleInvestigation.events.json +191 -0
- package/src/components/diagnose/exampleInvestigation.loadFailure.test.tsx +94 -0
- package/src/components/diagnose/exampleInvestigation.test.tsx +248 -0
- package/src/components/diagnose/exampleInvestigation.ts +121 -0
- package/src/components/diagnose/investigationCase.runs.test.tsx +328 -0
- package/src/components/diagnose/investigationCase.test.tsx +9 -1
- package/src/components/diagnose/investigationCase.ts +33 -1
- package/src/components/diagnose/investigationEvidence/adapters/applicationFindings.test.ts +739 -0
- package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +46 -0
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +58 -2
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +9 -0
- package/src/components/diagnose/investigationEvidence/adapters/posture.ts +29 -1
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.test.ts +40 -0
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +27 -1
- package/src/components/diagnose/investigationEvidence/bodies/metrics.test.tsx +111 -0
- package/src/components/diagnose/investigationEvidence/bodies/metrics.tsx +67 -16
- package/src/components/diagnose/investigationEvidence/builder.ts +30 -0
- package/src/components/diagnose/investigationEvidence/excerpt.test.ts +18 -5
- package/src/components/diagnose/investigationEvidence/excerpt.ts +22 -11
- package/src/components/diagnose/investigationEvidence/index.ts +1 -1
- package/src/components/diagnose/investigationEvidence/navigation.tsx +2 -0
- package/src/components/diagnose/investigationEvidence/observations.ts +121 -2
- package/src/components/diagnose/investigationEvidence/projection.test.ts +85 -3
- package/src/components/diagnose/investigationEvidence/types.ts +7 -0
- package/src/components/diagnose/investigationEvidencePartition.ts +6 -1
- package/src/components/diagnose/investigationFocus.test.ts +271 -0
- package/src/components/diagnose/investigationFocus.ts +132 -0
- package/src/components/diagnose/investigationState.ts +28 -0
- package/src/components/diagnose/lastInvestigation.test.ts +95 -0
- package/src/components/diagnose/lastInvestigation.ts +58 -0
- package/src/components/diagnose/launch.test.ts +125 -1
- package/src/components/diagnose/launch.ts +57 -10
- package/src/components/diagnose/parts.test.tsx +20 -0
- package/src/components/diagnose/questionSuggestions.test.ts +111 -0
- package/src/components/diagnose/questionSuggestions.ts +150 -0
- package/src/components/diagnose/storyParts.test.tsx +13 -0
- package/src/components/diagnose/target.test.ts +143 -2
- package/src/components/diagnose/target.ts +109 -7
- package/src/components/diagnose/testdata/story-runs.json +474 -0
- package/src/components/diagnose/toolCallLabel.test.ts +10 -4
- package/src/components/diagnose/verdictText.test.tsx +87 -0
- package/src/components/diagnose/verdictText.ts +68 -0
- package/src/components/execution/BatchExecutionView.tsx +24 -11
- package/src/components/execution/JobSetAdmission.test.tsx +42 -0
- package/src/components/execution/JobSetAdmission.tsx +18 -3
- package/src/components/execution/JobSetMemberComparison.tsx +2 -1
- package/src/components/execution/runState.test.ts +14 -0
- package/src/components/execution/runState.ts +8 -0
- package/src/components/gitops/GitOpsView.rollbackGate.test.tsx +202 -0
- package/src/components/gitops/GitOpsView.syncRequest.test.tsx +369 -0
- package/src/components/gitops/GitOpsView.tsx +86 -17
- package/src/components/gitops/RemoteDestinationCloudHint.tsx +2 -3
- package/src/components/gitops/destination-toast.test.ts +1 -1
- package/src/components/gitops/destination-toast.ts +2 -2
- package/src/components/home/ClusterHealthCard.tsx +13 -39
- package/src/components/home/HomeAgentBlock.test.tsx +141 -0
- package/src/components/home/HomeAgentBlock.tsx +103 -0
- package/src/components/home/HomeDiagramCard.tsx +47 -0
- package/src/components/home/HomeView.tsx +86 -47
- package/src/components/home/MCPSetupDialog.test.tsx +95 -5
- package/src/components/home/MCPSetupDialog.tsx +30 -5
- package/src/components/home/ProblemsPanel.investigate.test.tsx +171 -0
- package/src/components/home/ProblemsPanel.test.tsx +3 -1
- package/src/components/home/RadarVersionLine.test.tsx +0 -14
- package/src/components/home/RadarVersionLine.tsx +3 -28
- package/src/components/home/TopologyPreview.test.tsx +73 -0
- package/src/components/home/TopologyPreview.tsx +120 -233
- package/src/components/home/TrafficSummary.test.tsx +63 -0
- package/src/components/home/TrafficSummary.tsx +135 -138
- package/src/components/home/mcpToolCatalog.ts +23 -10
- package/src/components/issues/IssuesPane.test.ts +11 -0
- package/src/components/issues/IssuesPane.tsx +15 -5
- package/src/components/issues/uncheckedSources.test.ts +20 -1
- package/src/components/issues/uncheckedSources.ts +18 -0
- package/src/components/kueue/KueuePendingPosition.tsx +35 -0
- package/src/components/kueue/useRelatedObjects.test.tsx +219 -0
- package/src/components/kueue/useRelatedReads.test.ts +56 -0
- package/src/components/kueue/useRelatedReads.ts +205 -0
- package/src/components/logs/MultiPodLogsTab.test.tsx +93 -0
- package/src/components/logs/MultiPodLogsTab.tsx +120 -0
- package/src/components/logs/PodLogsUnavailable.test.tsx +18 -0
- package/src/components/logs/PodLogsUnavailable.tsx +21 -0
- package/src/components/logs/RayClusterLogsTab.reselect.test.tsx +67 -0
- package/src/components/logs/RayClusterLogsTab.test.tsx +167 -0
- package/src/components/logs/RayClusterLogsTab.tsx +109 -0
- package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +3 -2
- package/src/components/logs/rayClusterPods.ts +32 -0
- package/src/components/outageSince.test.ts +21 -0
- package/src/components/outageSince.ts +10 -0
- package/src/components/resource/PrometheusCharts.overlays.test.ts +12 -0
- package/src/components/resource/PrometheusCharts.tsx +3 -40
- package/src/components/resources/crd/CRDSchemaTab.test.tsx +28 -0
- package/src/components/resources/crd/CRDSchemaTab.tsx +13 -0
- package/src/components/resources/crd/host.tsx +14 -0
- package/src/components/resources/renderers/CustomResourceDefinitionRenderer.test.tsx +27 -0
- package/src/components/resources/renderers/CustomResourceDefinitionRenderer.tsx +12 -0
- package/src/components/resources/renderers/JobAdmissionRenderers.test.tsx +4 -1
- package/src/components/resources/renderers/JobAdmissionRenderers.tsx +4 -3
- package/src/components/resources/renderers/KueueHostRenderers.test.tsx +117 -0
- package/src/components/resources/renderers/KueueQueueRenderers.test.tsx +97 -0
- package/src/components/resources/renderers/KueueQueueRenderers.tsx +139 -0
- package/src/components/resources/renderers/KueueWorkloadRenderer.test.tsx +7 -1
- package/src/components/resources/renderers/KueueWorkloadRenderer.tsx +47 -7
- package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.test.tsx +67 -0
- package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.tsx +31 -0
- package/src/components/resources/renderers/RayClusterRenderer.test.tsx +81 -3
- package/src/components/resources/renderers/RayClusterRenderer.tsx +19 -4
- package/src/components/traffic/TrafficView.tsx +3 -3
- package/src/components/ui/Omnibar.investigate.test.tsx +105 -0
- package/src/components/ui/Omnibar.tsx +47 -3
- package/src/components/ui/RadarOmnibar.test.tsx +1 -0
- package/src/components/ui/RadarOmnibar.tsx +11 -0
- package/src/components/ui/command-items-crd.test.tsx +23 -0
- package/src/components/ui/command-items.ts +2 -1
- package/src/components/useContextSwitchFlow.test.tsx +61 -0
- package/src/components/useContextSwitchFlow.tsx +21 -4
- package/src/components/whats-new/WhatsNew.test.ts +10 -3
- package/src/components/whats-new/WhatsNew.tsx +5 -1
- package/src/components/whats-new/WhatsNewDialog.test.tsx +18 -4
- package/src/components/whats-new/releaseNotes.ts +136 -4
- package/src/components/workload/RelatedFindingsSection.test.tsx +126 -0
- package/src/components/workload/RelatedFindingsSection.tsx +80 -0
- package/src/components/workload/WorkloadView.test.ts +10 -1
- package/src/components/workload/WorkloadView.tsx +85 -98
- package/src/components/workload/issueResourceOpener.test.ts +20 -0
- package/src/components/workload/issueResourceOpener.ts +17 -0
- package/src/context/ConnectionContext.tsx +133 -60
- package/src/context/ConnectionProvider.retry.test.tsx +176 -0
- package/src/context/ContextSwitchContext.tsx +14 -1
- package/src/context/DiagnoseCustomization.tsx +3 -0
- package/src/context/clusterConnected.ts +10 -0
- package/src/contexts/CapabilitiesContext.tsx +6 -4
- package/src/hooks/useAgentSignin.test.tsx +190 -0
- package/src/hooks/useAgentSignin.ts +160 -0
- package/src/hooks/useApproveAfterSignin.test.tsx +108 -0
- package/src/hooks/useElementSize.ts +30 -0
- package/src/integrations/resourceHost.test.tsx +1 -0
- package/src/integrations/resourceHost.ts +5 -1
- package/src/integrations/resourceHosts.test.tsx +21 -4
- package/src/integrations/resourceHosts.tsx +12 -0
- package/src/main.tsx +5 -0
- package/src/utils/related-findings.ts +46 -0
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { MemoryRouter } from 'react-router-dom'
|
|
5
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
6
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
7
|
+
import { normalizeArgoApplication } from '@skyhook-io/k8s-ui'
|
|
8
|
+
import type { ArgoActionHandlers, GitOpsInsight, GitOpsInsightRef, GitOpsRow, GitOpsRowAction } from '@skyhook-io/k8s-ui'
|
|
9
|
+
import { GitOpsView } from './GitOpsView'
|
|
10
|
+
|
|
11
|
+
// The requests the Sync dialog builds, sent by the real useArgoSync and
|
|
12
|
+
// useArgoResourceValidation: only a Radar advertising argoSyncInheritance is
|
|
13
|
+
// trusted to read an omitted syncOptions as the Application's own.
|
|
14
|
+
|
|
15
|
+
const APP_OPTIONS = ['CreateNamespace=true', 'ServerSideApply=true']
|
|
16
|
+
const app = {
|
|
17
|
+
apiVersion: 'argoproj.io/v1alpha1',
|
|
18
|
+
kind: 'Application',
|
|
19
|
+
metadata: { name: 'guestbook', namespace: 'argocd' },
|
|
20
|
+
spec: { project: 'default', source: {} as Record<string, unknown>, sources: undefined as Array<{ repoURL: string; targetRevision: string }> | undefined, destination: {}, syncPolicy: { syncOptions: APP_OPTIONS } },
|
|
21
|
+
status: { sync: { status: 'OutOfSync', revision: undefined as string | undefined, revisions: undefined as string[] | undefined, comparedTo: undefined as Record<string, unknown> | undefined }, health: { status: 'Healthy' } },
|
|
22
|
+
}
|
|
23
|
+
const insight = {
|
|
24
|
+
summary: { tool: 'argocd', kind: 'Application', namespace: 'argocd', name: 'guestbook', autoSyncMode: 'Manual' },
|
|
25
|
+
} as unknown as GitOpsInsight
|
|
26
|
+
const deployment: GitOpsInsightRef = { kind: 'Deployment', group: 'apps', namespace: 'guestbook', name: 'web' }
|
|
27
|
+
|
|
28
|
+
vi.mock('@skyhook-io/k8s-ui', async (importOriginal) => {
|
|
29
|
+
const actual = await importOriginal<typeof import('@skyhook-io/k8s-ui')>()
|
|
30
|
+
return {
|
|
31
|
+
...actual,
|
|
32
|
+
useToast: () => ({ showError: vi.fn(), showSuccess: vi.fn(), showToast: vi.fn() }),
|
|
33
|
+
GitOpsTableView: (props: { rows: GitOpsRow[]; onRowAction: (row: GitOpsRow, action: GitOpsRowAction) => void }) => (
|
|
34
|
+
<button type="button" onClick={() => props.onRowAction(props.rows[0], 'sync')}>Open sync</button>
|
|
35
|
+
),
|
|
36
|
+
GitOpsDetailLayout: (props: { argo?: ArgoActionHandlers; renderTabBody: (ctx: { tab: 'changes'; fullscreen: boolean }) => React.ReactNode; children?: React.ReactNode }) => (
|
|
37
|
+
<div data-resume-settings={JSON.stringify(props.argo?.resumeSettings ?? null)}>
|
|
38
|
+
<button type="button" onClick={() => props.argo?.onSyncRequested()}>Open sync</button>
|
|
39
|
+
{props.renderTabBody({ tab: 'changes', fullscreen: false })}
|
|
40
|
+
{props.children}
|
|
41
|
+
</div>
|
|
42
|
+
),
|
|
43
|
+
GitOpsChangesView: (props: { onSyncResource?: (ref: GitOpsInsightRef) => void }) => (
|
|
44
|
+
<button type="button" onClick={() => props.onSyncResource?.(deployment)}>Open resource sync</button>
|
|
45
|
+
),
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
const toast = vi.hoisted(() => ({ success: vi.fn() }))
|
|
49
|
+
vi.mock('../ui/Toast', async (importOriginal) => ({
|
|
50
|
+
...(await importOriginal<typeof import('../ui/Toast')>()),
|
|
51
|
+
showApiSuccess: toast.success,
|
|
52
|
+
}))
|
|
53
|
+
vi.mock('../../api/client', async (importOriginal) => {
|
|
54
|
+
const actual = await importOriginal<typeof import('../../api/client')>()
|
|
55
|
+
const idle = () => ({ mutate: vi.fn(), reset: vi.fn(), isPending: false })
|
|
56
|
+
return {
|
|
57
|
+
...actual,
|
|
58
|
+
useResource: () => ({ data: app, isLoading: false, error: null }),
|
|
59
|
+
useGitOpsTree: () => ({ data: undefined, isLoading: false, error: null }),
|
|
60
|
+
useGitOpsInsights: () => ({ data: insight, isLoading: false, error: null }),
|
|
61
|
+
useArgoRollback: idle, useArgoRefresh: idle, useArgoTerminate: idle,
|
|
62
|
+
useArgoSuspend: idle, useArgoResume: idle, useApplyResource: idle,
|
|
63
|
+
useFluxReconcile: idle, useFluxSyncWithSource: idle, useFluxSuspend: idle, useFluxResume: idle,
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
vi.mock('../../api/apiResources', async (importOriginal) => ({
|
|
67
|
+
...(await importOriginal<typeof import('../../api/apiResources')>()),
|
|
68
|
+
useAPIResources: () => ({ data: [], isLoading: false }),
|
|
69
|
+
}))
|
|
70
|
+
vi.mock('../../context/ConnectionContext', () => ({ useConnection: () => ({ connection: { state: 'connected' } }) }))
|
|
71
|
+
vi.mock('../../context/RadarUpgradeHost', () => ({ useRadarUpgradeHost: () => ({}) }))
|
|
72
|
+
vi.mock('../useContextSwitchFlow', () => ({ useContextSwitchFlow: () => ({ confirmDialog: null, requestSwitch: vi.fn() }) }))
|
|
73
|
+
vi.mock('./useDestinationCluster', () => ({ useDestinationCluster: () => ({}) }))
|
|
74
|
+
vi.mock('../../hooks/useKeyboardShortcuts', () => ({ useRegisterShortcut: () => {} }))
|
|
75
|
+
vi.mock('../../hooks/usePreviousIntegrationSettings', () => ({ usePreviousIntegrationSettings: () => ({}), previousSettingsNote: () => undefined }))
|
|
76
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
77
|
+
|
|
78
|
+
let client: QueryClient
|
|
79
|
+
let host: HTMLDivElement
|
|
80
|
+
let root: ReturnType<typeof createRoot>
|
|
81
|
+
let requests: Array<{ path: string; body: Record<string, unknown> }>
|
|
82
|
+
|
|
83
|
+
beforeEach(async () => {
|
|
84
|
+
requests = []
|
|
85
|
+
vi.stubGlobal('fetch', vi.fn((input: RequestInfo | URL, init?: RequestInit) => {
|
|
86
|
+
const path = String(input)
|
|
87
|
+
if (init?.method === 'POST') {
|
|
88
|
+
requests.push({ path, body: JSON.parse(String(init.body)) })
|
|
89
|
+
const answer = path.endsWith('/validate-resource') ? { outcome: 'succeeded', message: 'ok' } : { message: 'Sync initiated' }
|
|
90
|
+
return Promise.resolve(new Response(JSON.stringify(answer), { status: 200, headers: { 'Content-Type': 'application/json' } }))
|
|
91
|
+
}
|
|
92
|
+
// /api/capabilities and /version-check stay pending; tests set capabilities.
|
|
93
|
+
return new Promise<Response>(() => {})
|
|
94
|
+
}))
|
|
95
|
+
client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
|
96
|
+
host = document.createElement('div')
|
|
97
|
+
document.body.append(host)
|
|
98
|
+
root = createRoot(host)
|
|
99
|
+
await renderView('/gitops/detail/applications/argocd/guestbook?apiGroup=argoproj.io')
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
afterEach(async () => {
|
|
103
|
+
await act(async () => root.unmount())
|
|
104
|
+
client.clear()
|
|
105
|
+
host.remove()
|
|
106
|
+
document.body.innerHTML = ''
|
|
107
|
+
app.spec.source = {}
|
|
108
|
+
app.spec.sources = undefined
|
|
109
|
+
app.status.sync.revision = undefined
|
|
110
|
+
app.status.sync.revisions = undefined
|
|
111
|
+
app.status.sync.comparedTo = undefined
|
|
112
|
+
vi.unstubAllGlobals()
|
|
113
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
async function renderView(path: string) {
|
|
117
|
+
if (path === '/gitops') {
|
|
118
|
+
client.setQueryData(['gitops-rows-main', [], 0], { coverageStatus: 'complete', rows: [normalizeArgoApplication(app)] })
|
|
119
|
+
}
|
|
120
|
+
await act(async () => root.render(
|
|
121
|
+
<MemoryRouter key={path} initialEntries={[path]}>
|
|
122
|
+
<QueryClientProvider client={client}><GitOpsView namespaces={[]} onOpenResource={() => {}} /></QueryClientProvider>
|
|
123
|
+
</MemoryRouter>,
|
|
124
|
+
))
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const settle = async () => { await act(async () => { await new Promise((resolve) => setTimeout(resolve, 0)) }) }
|
|
128
|
+
// A sync using Replace or Force is labelled "Sync with replace" etc.
|
|
129
|
+
const button = (label: string) => [...document.querySelectorAll('button')].find((b) => {
|
|
130
|
+
const text = b.textContent?.trim() ?? ''
|
|
131
|
+
return text === label || text.startsWith(`${label === 'Sync now' ? 'Sync' : label} with `)
|
|
132
|
+
})!
|
|
133
|
+
const toggle = (label: string) => [...document.querySelectorAll('label')].find((l) => l.textContent?.startsWith(label))!.querySelector('input')!
|
|
134
|
+
const click = async (el: HTMLElement) => { await act(async () => el.click()); await settle() }
|
|
135
|
+
const advertise = async (features: Record<string, boolean>) => {
|
|
136
|
+
await act(async () => { client.setQueryData(['capabilities'], { features }) })
|
|
137
|
+
await settle()
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
describe('a Radar that advertises argoSyncInheritance', () => {
|
|
141
|
+
beforeEach(async () => { await advertise({ argoRollbackSync: true, argoSyncInheritance: true }) })
|
|
142
|
+
|
|
143
|
+
it("omits the options for an unchanged sync and always sends prune", async () => {
|
|
144
|
+
await click(button('Open sync'))
|
|
145
|
+
await click(button('Sync now'))
|
|
146
|
+
expect(requests).toHaveLength(1)
|
|
147
|
+
expect(requests[0].path).toBe('/api/argo/applications/argocd/guestbook/sync')
|
|
148
|
+
expect(requests[0].body.prune).toBe(false)
|
|
149
|
+
expect(requests[0].body).not.toHaveProperty('syncOptions')
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
it('sends an edited list when a toggle changes', async () => {
|
|
153
|
+
await click(button('Open sync'))
|
|
154
|
+
await click(toggle('Server-side apply'))
|
|
155
|
+
await click(button('Sync now'))
|
|
156
|
+
expect(requests[0].body).toMatchObject({ prune: false, syncOptions: ['CreateNamespace=true'] })
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
it.each([
|
|
160
|
+
{ change: 'the compared revision', apply: () => { app.status.sync.revision = 'new-sha' } },
|
|
161
|
+
{ change: 'the source', apply: () => { app.spec.source = { repoURL: 'https://example.com/other', targetRevision: 'main' } } },
|
|
162
|
+
{ change: 'the comparison', apply: () => { app.status.sync.comparedTo = { source: app.spec.source } } },
|
|
163
|
+
])('drops a dry-run pass once $change changes', async ({ apply }) => {
|
|
164
|
+
await click(button('Open resource sync'))
|
|
165
|
+
await click(button('Dry-run'))
|
|
166
|
+
expect(document.body.textContent).toContain('Dry-run passed')
|
|
167
|
+
apply()
|
|
168
|
+
await renderView('/gitops/detail/applications/argocd/guestbook?apiGroup=argoproj.io')
|
|
169
|
+
await settle()
|
|
170
|
+
expect(document.body.textContent).toContain('Sync resource')
|
|
171
|
+
expect(document.body.textContent).not.toContain('Dry-run passed')
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
it('keeps a dry-run pass while what it checked is unchanged', async () => {
|
|
175
|
+
await click(button('Open resource sync'))
|
|
176
|
+
await click(button('Dry-run'))
|
|
177
|
+
await renderView('/gitops/detail/applications/argocd/guestbook?apiGroup=argoproj.io')
|
|
178
|
+
await settle()
|
|
179
|
+
expect(document.body.textContent).toContain('Dry-run passed')
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
it('validates and syncs one resource with the inherited options', async () => {
|
|
183
|
+
await click(button('Open resource sync'))
|
|
184
|
+
await click(button('Dry-run'))
|
|
185
|
+
await click(button('Sync resource'))
|
|
186
|
+
expect(requests.map((r) => r.path)).toEqual([
|
|
187
|
+
'/api/argo/applications/argocd/guestbook/validate-resource',
|
|
188
|
+
'/api/argo/applications/argocd/guestbook/sync',
|
|
189
|
+
])
|
|
190
|
+
expect(requests[0].body).not.toHaveProperty('syncOptions')
|
|
191
|
+
expect(requests[1].body).toMatchObject({ prune: false, resources: [{ group: 'apps', kind: 'Deployment', namespace: 'guestbook', name: 'web' }] })
|
|
192
|
+
expect(requests[1].body).not.toHaveProperty('syncOptions')
|
|
193
|
+
})
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
describe('an older Radar, without argoSyncInheritance', () => {
|
|
197
|
+
beforeEach(async () => { await advertise({ argoRollbackSync: true }) })
|
|
198
|
+
|
|
199
|
+
it("sends the Application's options, which it would otherwise drop, and prune false, which it would otherwise default to true", async () => {
|
|
200
|
+
await click(button('Open sync'))
|
|
201
|
+
await click(button('Sync now'))
|
|
202
|
+
expect(requests[0].body).toMatchObject({ prune: false, syncOptions: APP_OPTIONS })
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
it('sends an edited list the same way', async () => {
|
|
206
|
+
await click(button('Open sync'))
|
|
207
|
+
await click(toggle('Server-side apply'))
|
|
208
|
+
await click(button('Sync now'))
|
|
209
|
+
expect(requests[0].body).toMatchObject({ prune: false, syncOptions: ['CreateNamespace=true'] })
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
it("validates and syncs one resource with the Application's options", async () => {
|
|
213
|
+
await click(button('Open resource sync'))
|
|
214
|
+
await click(button('Dry-run'))
|
|
215
|
+
await click(button('Sync resource'))
|
|
216
|
+
expect(requests[0].body.syncOptions).toEqual(APP_OPTIONS)
|
|
217
|
+
expect(requests[1].body).toMatchObject({ prune: false, syncOptions: APP_OPTIONS })
|
|
218
|
+
})
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
it.each([
|
|
222
|
+
{ dryRun: false, message: 'Sync initiated' },
|
|
223
|
+
{ dryRun: true, message: 'Dry run started' },
|
|
224
|
+
])('confirms a sync with dryRun $dryRun as "$message"', async ({ dryRun, message }) => {
|
|
225
|
+
toast.success.mockClear()
|
|
226
|
+
await click(button('Open sync'))
|
|
227
|
+
if (dryRun) {
|
|
228
|
+
const label = [...document.querySelectorAll('label')].find((l) => l.textContent?.startsWith('Dry run'))!
|
|
229
|
+
await click(label.querySelector('input')!)
|
|
230
|
+
}
|
|
231
|
+
await click(button(dryRun ? 'Run dry-run' : 'Sync now'))
|
|
232
|
+
expect(requests[0].body).toMatchObject({ dryRun })
|
|
233
|
+
expect(toast.success).toHaveBeenCalledWith(message)
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
it('treats a Radar whose capabilities have not loaded as older', async () => {
|
|
237
|
+
await click(button('Open sync'))
|
|
238
|
+
await click(button('Sync now'))
|
|
239
|
+
expect(requests[0].body).toMatchObject({ prune: false, syncOptions: APP_OPTIONS })
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
it.each([
|
|
243
|
+
'/gitops',
|
|
244
|
+
'/gitops/detail/applications/argocd/guestbook?apiGroup=argoproj.io',
|
|
245
|
+
])('explains compared revisions for multi-source sync from %s', async (path) => {
|
|
246
|
+
app.spec.sources = [
|
|
247
|
+
{ repoURL: 'https://example.com/app', targetRevision: 'main' },
|
|
248
|
+
{ repoURL: 'https://example.com/values', targetRevision: 'v1' },
|
|
249
|
+
]
|
|
250
|
+
app.status.sync.revisions = ['app-sha', 'values-sha']
|
|
251
|
+
app.status.sync.comparedTo = { sources: app.spec.sources }
|
|
252
|
+
await advertise({ argoRollbackSync: true, argoSyncInheritance: true })
|
|
253
|
+
await renderView(path)
|
|
254
|
+
await click(button('Open sync'))
|
|
255
|
+
expect(document.body.textContent).not.toContain('Revision (optional)')
|
|
256
|
+
expect(document.body.textContent).toContain('Syncs each source at the revision Argo last compared.')
|
|
257
|
+
await click(button('Sync now'))
|
|
258
|
+
expect(requests).toHaveLength(1)
|
|
259
|
+
expect(requests[0].body).not.toHaveProperty('revision')
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
it.each([
|
|
263
|
+
'/gitops',
|
|
264
|
+
'/gitops/detail/applications/argocd/guestbook?apiGroup=argoproj.io',
|
|
265
|
+
])('shows the compared revision in the sync dialog from %s', async (path) => {
|
|
266
|
+
app.spec.source = { repoURL: 'https://example.com/app', targetRevision: 'main' }
|
|
267
|
+
app.status.sync.revision = 'abcdef0123456789abcdef0123456789abcdef01'
|
|
268
|
+
app.status.sync.comparedTo = { source: { targetRevision: 'main', repoURL: 'https://example.com/app' } }
|
|
269
|
+
await advertise({ argoRollbackSync: true, argoSyncInheritance: true })
|
|
270
|
+
await renderView(path)
|
|
271
|
+
await click(button('Open sync'))
|
|
272
|
+
expect(document.body.textContent).toContain('Leave empty for the revision Argo last compared (abcdef0).')
|
|
273
|
+
await click(button('Sync now'))
|
|
274
|
+
expect(requests[0].body).not.toHaveProperty('revision')
|
|
275
|
+
})
|
|
276
|
+
|
|
277
|
+
// A comparison made for an earlier source won't be pinned, so it isn't promised.
|
|
278
|
+
it('promises no compared revision when the source changed since the comparison', async () => {
|
|
279
|
+
app.spec.source = { repoURL: 'https://example.com/app', targetRevision: 'release' }
|
|
280
|
+
app.status.sync.revision = 'abcdef0123456789abcdef0123456789abcdef01'
|
|
281
|
+
app.status.sync.comparedTo = { source: { repoURL: 'https://example.com/app', targetRevision: 'main' } }
|
|
282
|
+
await advertise({ argoRollbackSync: true, argoSyncInheritance: true })
|
|
283
|
+
await renderView('/gitops')
|
|
284
|
+
await click(button('Open sync'))
|
|
285
|
+
expect(document.body.textContent).toContain('Leave empty for the target revision, resolved when the sync runs.')
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
// An older Radar resolves an omitted revision when the sync runs.
|
|
289
|
+
it.each([
|
|
290
|
+
'/gitops',
|
|
291
|
+
'/gitops/detail/applications/argocd/guestbook?apiGroup=argoproj.io',
|
|
292
|
+
])('promises no compared revision to an older Radar from %s', async (path) => {
|
|
293
|
+
app.status.sync.revision = 'abcdef0123456789abcdef0123456789abcdef01'
|
|
294
|
+
await advertise({ argoRollbackSync: true })
|
|
295
|
+
await renderView(path)
|
|
296
|
+
await click(button('Open sync'))
|
|
297
|
+
expect(document.body.textContent).toContain('Leave empty for the target revision, resolved when the sync runs.')
|
|
298
|
+
expect(document.body.textContent).not.toContain('last compared')
|
|
299
|
+
})
|
|
300
|
+
|
|
301
|
+
const STALE_OPTIONS_NOTICE = "The Application's sync options changed while this dialog was open. This sync uses the options shown here. Cancel and reopen to load the latest."
|
|
302
|
+
|
|
303
|
+
async function replaceTableApplication(syncOptions: string[], automated = false) {
|
|
304
|
+
const replacement = {
|
|
305
|
+
...app,
|
|
306
|
+
spec: { ...app.spec, syncPolicy: { syncOptions, ...(automated ? { automated: {} } : {}) } },
|
|
307
|
+
}
|
|
308
|
+
await act(async () => {
|
|
309
|
+
client.setQueryData(['gitops-rows-main', [], 0], { coverageStatus: 'complete', rows: [normalizeArgoApplication(replacement)] })
|
|
310
|
+
})
|
|
311
|
+
await settle()
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
it('uses replacement table rows for untouched sync policy and request context after refetch', async () => {
|
|
315
|
+
await advertise({ argoRollbackSync: true })
|
|
316
|
+
await renderView('/gitops')
|
|
317
|
+
await click(button('Open sync'))
|
|
318
|
+
await replaceTableApplication(['Replace=true', 'FailOnSharedResource=true'])
|
|
319
|
+
expect(toggle('Replace').checked).toBe(true)
|
|
320
|
+
expect(toggle('Server-side apply').checked).toBe(false)
|
|
321
|
+
expect(document.body.textContent).not.toContain(STALE_OPTIONS_NOTICE)
|
|
322
|
+
await click(button('Sync now'))
|
|
323
|
+
expect(requests[0].body.syncOptions).toEqual(['Replace=true', 'FailOnSharedResource=true'])
|
|
324
|
+
})
|
|
325
|
+
|
|
326
|
+
it('shows the stale-options notice for edited sync options after replacement-row refetch', async () => {
|
|
327
|
+
await advertise({ argoRollbackSync: true, argoSyncInheritance: true })
|
|
328
|
+
await renderView('/gitops')
|
|
329
|
+
await click(button('Open sync'))
|
|
330
|
+
await click(toggle('Replace'))
|
|
331
|
+
await replaceTableApplication(['PruneLast=true'])
|
|
332
|
+
expect(document.body.textContent).toContain(STALE_OPTIONS_NOTICE)
|
|
333
|
+
expect(toggle('Server-side apply').checked).toBe(true)
|
|
334
|
+
await click(button('Sync now'))
|
|
335
|
+
expect(requests[0].body.syncOptions).toEqual(['CreateNamespace=true', 'Replace=true', 'ServerSideApply=true'])
|
|
336
|
+
})
|
|
337
|
+
|
|
338
|
+
it('closes the table sync dialog when its selected row disappears and keeps it closed if the row returns', async () => {
|
|
339
|
+
await renderView('/gitops')
|
|
340
|
+
await click(button('Open sync'))
|
|
341
|
+
expect(document.querySelector('[role="dialog"]')).not.toBeNull()
|
|
342
|
+
await act(async () => {
|
|
343
|
+
client.setQueryData(['gitops-rows-main', [], 0], { coverageStatus: 'complete', rows: [] })
|
|
344
|
+
})
|
|
345
|
+
await settle()
|
|
346
|
+
await replaceTableApplication(APP_OPTIONS)
|
|
347
|
+
await act(async () => { await new Promise((resolve) => setTimeout(resolve, 250)) })
|
|
348
|
+
expect(document.querySelector('[role="dialog"]')).toBeNull()
|
|
349
|
+
expect(requests).toHaveLength(0)
|
|
350
|
+
})
|
|
351
|
+
|
|
352
|
+
it('refreshes auto-sync status in the table sync dialog', async () => {
|
|
353
|
+
await renderView('/gitops')
|
|
354
|
+
await click(button('Open sync'))
|
|
355
|
+
const revision = document.querySelector('input:not([type="checkbox"])') as HTMLInputElement
|
|
356
|
+
expect(revision.disabled).toBe(false)
|
|
357
|
+
await replaceTableApplication(APP_OPTIONS, true)
|
|
358
|
+
expect(revision.disabled).toBe(true)
|
|
359
|
+
expect(document.body.textContent).toContain('Turn off auto-sync to deploy another revision')
|
|
360
|
+
})
|
|
361
|
+
|
|
362
|
+
it.each([
|
|
363
|
+
{ label: 'starts self-heal off', features: { argoRollbackSync: true, argoSyncInheritance: true, argoEnableSelfHealOff: true }, expected: { prune: false, selfHeal: false } },
|
|
364
|
+
{ label: 'still starts self-heal on', features: { argoRollbackSync: true, argoSyncInheritance: true, argoEnableSelfHealOff: false }, expected: { prune: false, selfHeal: true } },
|
|
365
|
+
])('predicts what a first-time Enable auto-sync turns on for a Radar that $label', async ({ features, expected }) => {
|
|
366
|
+
await advertise(features)
|
|
367
|
+
const settings = document.querySelector('[data-resume-settings]')!.getAttribute('data-resume-settings')!
|
|
368
|
+
expect(JSON.parse(settings)).toEqual(expected)
|
|
369
|
+
})
|
|
@@ -15,6 +15,9 @@ import {
|
|
|
15
15
|
GitOpsTreeGraph,
|
|
16
16
|
RollbackDialog,
|
|
17
17
|
SyncOptionsDialog,
|
|
18
|
+
argoApplicationSyncOptions,
|
|
19
|
+
argoComparedRevisionCurrent,
|
|
20
|
+
isArgoMultiSource,
|
|
18
21
|
buildFluxSourceUrlMap,
|
|
19
22
|
buildTreeFacets,
|
|
20
23
|
describeGitOpsTerminating,
|
|
@@ -24,6 +27,10 @@ import {
|
|
|
24
27
|
getGitOpsTool,
|
|
25
28
|
gitOpsDetailGroup,
|
|
26
29
|
isDestinationRef,
|
|
30
|
+
isArgoAutoSyncEnabled,
|
|
31
|
+
isArgoAutoSyncSwitchedOff,
|
|
32
|
+
argoAutoSyncController,
|
|
33
|
+
argoResumeSettings,
|
|
27
34
|
isArgoOperationInProgress,
|
|
28
35
|
isArgoSuspendedByRadar,
|
|
29
36
|
gitOpsInsightChangeKey,
|
|
@@ -33,6 +40,7 @@ import {
|
|
|
33
40
|
normalizeFluxHelmRelease,
|
|
34
41
|
normalizeFluxKustomization,
|
|
35
42
|
parseArgoRollbackID,
|
|
43
|
+
radarUpgradeNoteText,
|
|
36
44
|
toggleSet,
|
|
37
45
|
type APIResource,
|
|
38
46
|
type ArgoActionHandlers,
|
|
@@ -73,6 +81,7 @@ import {
|
|
|
73
81
|
useFluxSyncWithSource,
|
|
74
82
|
useGitOpsInsights,
|
|
75
83
|
useGitOpsTree,
|
|
84
|
+
useRadarFeature,
|
|
76
85
|
useResource,
|
|
77
86
|
} from '../../api/client'
|
|
78
87
|
import { useAPIResources, GITOPS_KINDS } from '../../api/apiResources'
|
|
@@ -138,8 +147,10 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
138
147
|
const fluxSyncWithSource = useFluxSyncWithSource()
|
|
139
148
|
const fluxSuspend = useFluxSuspend()
|
|
140
149
|
const fluxResume = useFluxResume()
|
|
150
|
+
const { upgrade: argoResumeUpgrade, blockedReason: argoResumeBlockedReason } = useRadarFeature('argoAutoSyncEnable')
|
|
151
|
+
const { support: argoInheritanceSupport } = useRadarFeature('argoSyncInheritance')
|
|
141
152
|
|
|
142
|
-
const [
|
|
153
|
+
const [syncDialogRowId, setSyncDialogRowId] = useState<string | null>(null)
|
|
143
154
|
const [pendingActions, setPendingActions] = useState<Map<string, Set<GitOpsRowAction>>>(new Map())
|
|
144
155
|
|
|
145
156
|
// Mark an action as in-flight (or done) for a given row. Cloning the
|
|
@@ -236,6 +247,11 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
236
247
|
refetchInterval: GITOPS_ROWS_REFRESH_INTERVAL_MS,
|
|
237
248
|
})
|
|
238
249
|
|
|
250
|
+
const syncDialogRow = rowsQuery.data?.rows.find((row) => row.id === syncDialogRowId)
|
|
251
|
+
useEffect(() => {
|
|
252
|
+
if (syncDialogRowId && !syncDialogRow) setSyncDialogRowId(null)
|
|
253
|
+
}, [syncDialogRowId, syncDialogRow])
|
|
254
|
+
|
|
239
255
|
// Row mutations invalidate granular keys (['resource', …], ['gitops-tree', …])
|
|
240
256
|
// that don't match the table's aggregate gitops-rows-main / counts queries,
|
|
241
257
|
// so refetch those explicitly — otherwise a row keeps showing the pre-action
|
|
@@ -286,7 +302,7 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
286
302
|
// detail page uses. The mutation fires from onConfirm; clear the
|
|
287
303
|
// in-flight flag here since the dialog now owns the lifecycle.
|
|
288
304
|
markAction(id, action, false)
|
|
289
|
-
|
|
305
|
+
setSyncDialogRowId(id)
|
|
290
306
|
return
|
|
291
307
|
case 'refresh':
|
|
292
308
|
argoRefresh.mutate({ namespace, name, hard: false }, settle)
|
|
@@ -302,6 +318,10 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
302
318
|
else fluxSuspend.mutate({ kind, namespace, name }, settle)
|
|
303
319
|
return
|
|
304
320
|
case 'resume':
|
|
321
|
+
if (row.tool === 'argo' && isArgoAutoSyncSwitchedOff(row.raw) && (argoResumeUpgrade || argoResumeBlockedReason)) {
|
|
322
|
+
markAction(id, action, false)
|
|
323
|
+
return
|
|
324
|
+
}
|
|
305
325
|
if (row.tool === 'argo') argoResume.mutate({ namespace, name }, settle)
|
|
306
326
|
else fluxResume.mutate({ kind, namespace, name }, settle)
|
|
307
327
|
return
|
|
@@ -340,6 +360,8 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
340
360
|
}}
|
|
341
361
|
onRowAction={handleRowAction}
|
|
342
362
|
pendingRowActions={pendingActions}
|
|
363
|
+
argoResumeUpgrade={argoResumeUpgrade}
|
|
364
|
+
argoResumeBlockedReason={argoResumeBlockedReason}
|
|
343
365
|
searchHotkey
|
|
344
366
|
globalNamespaces={namespaces}
|
|
345
367
|
onClearNamespaces={onClearNamespaces}
|
|
@@ -347,17 +369,22 @@ function GitOpsTableView({ namespaces, onClearNamespaces }: { namespaces: string
|
|
|
347
369
|
<SyncOptionsDialog
|
|
348
370
|
open={!!syncDialogRow}
|
|
349
371
|
appLabel={syncDialogRow ? `${syncDialogRow.namespace}/${syncDialogRow.name}` : ''}
|
|
372
|
+
multiSource={isArgoMultiSource(syncDialogRow?.raw)}
|
|
373
|
+
comparedRevision={syncDialogRow?.raw?.status?.sync?.revision}
|
|
374
|
+
pinsComparedRevision={argoInheritanceSupport === 'supported' && argoComparedRevisionCurrent(syncDialogRow?.raw)}
|
|
375
|
+
applicationSyncOptions={argoApplicationSyncOptions(syncDialogRow?.raw)}
|
|
376
|
+
autoSyncEnabled={!!syncDialogRow && isArgoAutoSyncEnabled(syncDialogRow.raw)}
|
|
350
377
|
pending={argoSync.isPending}
|
|
351
|
-
onCancel={() =>
|
|
378
|
+
onCancel={() => setSyncDialogRowId(null)}
|
|
352
379
|
onConfirm={(opts) => {
|
|
353
380
|
if (!syncDialogRow) return
|
|
354
381
|
const { namespace, name } = syncDialogRow
|
|
355
382
|
argoSync.mutate(
|
|
356
|
-
{ namespace, name, ...opts },
|
|
383
|
+
{ namespace, name, ...opts, applicationSyncOptions: argoApplicationSyncOptions(syncDialogRow.raw) },
|
|
357
384
|
// onSettled so the dialog closes on both success and error —
|
|
358
385
|
// otherwise the error toast surfaces behind the still-open
|
|
359
386
|
// modal and the user can't read it.
|
|
360
|
-
{ onSuccess: refetchTableAfterMutation, onSettled: () =>
|
|
387
|
+
{ onSuccess: refetchTableAfterMutation, onSettled: () => setSyncDialogRowId(null) },
|
|
361
388
|
)
|
|
362
389
|
}}
|
|
363
390
|
/>
|
|
@@ -401,11 +428,22 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
401
428
|
const tool = resourceQ.data ? getGitOpsTool(kind, effectiveGroup) : null
|
|
402
429
|
const isArgoApp = tool === 'argo' && kind === 'applications'
|
|
403
430
|
const status = tool && resourceQ.data ? getGitOpsResourceStatus(kind, resourceQ.data) : null
|
|
404
|
-
// Argo "auto-sync ON" is
|
|
405
|
-
// not
|
|
431
|
+
// Argo "auto-sync ON" is read from spec.syncPolicy.automated (honoring
|
|
432
|
+
// `enabled: false`), not from health.status === Suspended (which is Argo's
|
|
433
|
+
// CronJob-style suspend).
|
|
406
434
|
// The toggle button reads from this so the label flips correctly when an
|
|
407
435
|
// app is in Manual mode or suspended via Radar's annotations.
|
|
408
|
-
const argoAutoSyncEnabled = isArgoApp &&
|
|
436
|
+
const argoAutoSyncEnabled = isArgoApp && isArgoAutoSyncEnabled(resourceQ.data)
|
|
437
|
+
const appSyncOptions = argoApplicationSyncOptions(resourceQ.data)
|
|
438
|
+
// What a sync of this Application would deploy: its source(s), and the
|
|
439
|
+
// revision(s) Argo last compared with the source(s) compared, which decide
|
|
440
|
+
// whether the sync pins them. A dry-run result describes the value it was
|
|
441
|
+
// run against.
|
|
442
|
+
const deployTargetKey = JSON.stringify([
|
|
443
|
+
kind, namespace, name,
|
|
444
|
+
resourceQ.data?.spec?.source, resourceQ.data?.spec?.sources, resourceQ.data?.spec?.sourceHydrator,
|
|
445
|
+
resourceQ.data?.status?.sync?.revision, resourceQ.data?.status?.sync?.revisions, resourceQ.data?.status?.sync?.comparedTo,
|
|
446
|
+
])
|
|
409
447
|
// Radar-driven Argo suspension is signaled by annotations that record the
|
|
410
448
|
// pre-suspend prune/selfHeal state for restoration on resume. When present,
|
|
411
449
|
// the app is in a deliberately-paused state (vs. Manual mode, which is a
|
|
@@ -456,6 +494,10 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
456
494
|
const argoSuspend = useArgoSuspend()
|
|
457
495
|
const argoResume = useArgoResume()
|
|
458
496
|
const argoRollback = useArgoRollback()
|
|
497
|
+
const { upgrade: argoRollbackUpgrade, blockedReason: argoRollbackBlockedReason } = useRadarFeature('argoRollback')
|
|
498
|
+
const { upgrade: argoResumeUpgrade, blockedReason: argoResumeBlockedReason } = useRadarFeature('argoAutoSyncEnable')
|
|
499
|
+
const { support: argoInheritanceSupport } = useRadarFeature('argoSyncInheritance')
|
|
500
|
+
const { support: argoSelfHealOffSupport } = useRadarFeature('argoEnableSelfHealOff')
|
|
459
501
|
const applyResource = useApplyResource()
|
|
460
502
|
const fluxReconcile = useFluxReconcile()
|
|
461
503
|
const fluxSyncWithSource = useFluxSyncWithSource()
|
|
@@ -463,6 +505,8 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
463
505
|
const fluxResume = useFluxResume()
|
|
464
506
|
|
|
465
507
|
const [syncDialogTarget, setSyncDialogTarget] = useState<ArgoSyncDialogTarget | null>(null)
|
|
508
|
+
const [validatedTargetKey, setValidatedTargetKey] = useState<string | null>(null)
|
|
509
|
+
const validationStale = validatedTargetKey !== null && validatedTargetKey !== deployTargetKey
|
|
466
510
|
// Doubles as the "open" flag (truthy = dialog open) and the data carrier
|
|
467
511
|
// for which history entry to roll back to.
|
|
468
512
|
const [rollbackTarget, setRollbackTarget] = useState<GitOpsHistoryItem | null>(null)
|
|
@@ -656,7 +700,10 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
656
700
|
},
|
|
657
701
|
onTerminate: () => argoTerminate.mutate({ namespace, name }),
|
|
658
702
|
onSuspend: () => argoSuspend.mutate({ namespace, name }),
|
|
659
|
-
onResume: () =>
|
|
703
|
+
onResume: () => {
|
|
704
|
+
if (isArgoAutoSyncSwitchedOff(resourceQ.data) && (argoResumeUpgrade || argoResumeBlockedReason)) return
|
|
705
|
+
argoResume.mutate({ namespace, name })
|
|
706
|
+
},
|
|
660
707
|
syncing: argoSync.isPending,
|
|
661
708
|
refreshing: argoRefresh.isPending,
|
|
662
709
|
refreshingKind: refreshKind,
|
|
@@ -666,6 +713,12 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
666
713
|
autoSyncEnabled: argoAutoSyncEnabled,
|
|
667
714
|
isRunning,
|
|
668
715
|
operationInProgress,
|
|
716
|
+
resumeUpgrade: isArgoAutoSyncSwitchedOff(resourceQ.data) ? argoResumeUpgrade : null,
|
|
717
|
+
autoSyncController: argoAutoSyncController(resourceQ.relationships, { namespace, name }),
|
|
718
|
+
resumeSettings: argoInheritanceSupport === 'unknown' || argoSelfHealOffSupport === 'unknown'
|
|
719
|
+
? argoResumeSettings(resourceQ.data, undefined)
|
|
720
|
+
: argoResumeSettings(resourceQ.data, argoInheritanceSupport === 'supported', argoSelfHealOffSupport === 'supported'),
|
|
721
|
+
resumeBlockedReason: isArgoAutoSyncSwitchedOff(resourceQ.data) ? argoResumeBlockedReason : undefined,
|
|
669
722
|
} : undefined
|
|
670
723
|
|
|
671
724
|
const fluxHandlers: FluxActionHandlers | undefined = isFlux ? {
|
|
@@ -696,6 +749,7 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
696
749
|
terminatingActionTooltip={terminatingActionTooltip}
|
|
697
750
|
detail={tool ? detail : undefined}
|
|
698
751
|
insight={tool ? insightsQ.data ?? null : null}
|
|
752
|
+
warnings={tree?.warnings}
|
|
699
753
|
insightLoading={insightsQ.isLoading}
|
|
700
754
|
healthDocsUrl={GITOPS_HEALTH_DOCS_URL}
|
|
701
755
|
remoteDestinationHint={<RemoteDestinationCloudHint />}
|
|
@@ -732,7 +786,7 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
732
786
|
// failure doesn't yield a misleading "sync triggered" toast.
|
|
733
787
|
if (isArgoApp) {
|
|
734
788
|
argoSync.mutate(
|
|
735
|
-
{ namespace, name },
|
|
789
|
+
{ namespace, name, applicationSyncOptions: appSyncOptions },
|
|
736
790
|
{
|
|
737
791
|
onSuccess: () => {
|
|
738
792
|
showSuccess(`Created namespace ${nsName}`, 'Sync triggered to retry the apply.')
|
|
@@ -812,9 +866,11 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
812
866
|
insight={insightsQ.data}
|
|
813
867
|
error={insightsQ.error as Error | null}
|
|
814
868
|
onRollback={isArgoApp && !operationInProgress ? (item) => {
|
|
815
|
-
if (parseArgoRollbackID(item.id) == null) return
|
|
869
|
+
if (argoRollbackUpgrade || argoRollbackBlockedReason || parseArgoRollbackID(item.id) == null) return
|
|
816
870
|
setRollbackTarget(item)
|
|
817
871
|
} : undefined}
|
|
872
|
+
rollbackUpgrade={argoRollbackUpgrade}
|
|
873
|
+
rollbackBlockedReason={argoRollbackBlockedReason}
|
|
818
874
|
/>
|
|
819
875
|
)
|
|
820
876
|
}
|
|
@@ -890,23 +946,28 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
890
946
|
<SyncOptionsDialog
|
|
891
947
|
open={!!syncDialogTarget}
|
|
892
948
|
appLabel={`${namespace}/${name}`}
|
|
949
|
+
multiSource={isArgoMultiSource(resourceQ.data)}
|
|
950
|
+
pinsComparedRevision={argoInheritanceSupport === 'supported' && argoComparedRevisionCurrent(resourceQ.data)}
|
|
893
951
|
resource={syncDialogTarget?.scope === 'resource' ? syncDialogTarget.resource : undefined}
|
|
952
|
+
comparedRevision={resourceQ.data?.status?.sync?.revision}
|
|
953
|
+
applicationSyncOptions={appSyncOptions}
|
|
894
954
|
pending={argoSync.isPending}
|
|
895
955
|
autoSyncEnabled={argoAutoSyncEnabled}
|
|
896
956
|
validationPending={argoResourceValidation.isPending}
|
|
897
957
|
operationInProgress={operationInProgress}
|
|
898
|
-
validationResult={argoResourceValidation.data}
|
|
899
|
-
validationError={argoResourceValidation.error?.message}
|
|
958
|
+
validationResult={validationStale ? null : argoResourceValidation.data}
|
|
959
|
+
validationError={validationStale ? undefined : argoResourceValidation.error?.message}
|
|
900
960
|
onCancel={closeArgoSyncDialog}
|
|
901
961
|
onValidationReset={() => argoResourceValidation.reset()}
|
|
902
962
|
onValidate={syncDialogTarget?.scope === 'resource' ? (opts) => {
|
|
903
|
-
|
|
963
|
+
setValidatedTargetKey(deployTargetKey)
|
|
964
|
+
argoResourceValidation.mutate(buildArgoResourceSyncVars(namespace, name, syncDialogTarget.resource, opts, appSyncOptions))
|
|
904
965
|
} : undefined}
|
|
905
966
|
onConfirm={(opts) => {
|
|
906
967
|
if (!syncDialogTarget) return
|
|
907
968
|
const variables = syncDialogTarget.scope === 'resource'
|
|
908
|
-
? buildArgoResourceSyncVars(namespace, name, syncDialogTarget.resource, opts)
|
|
909
|
-
: { namespace, name, ...opts }
|
|
969
|
+
? buildArgoResourceSyncVars(namespace, name, syncDialogTarget.resource, opts, appSyncOptions)
|
|
970
|
+
: { namespace, name, ...opts, applicationSyncOptions: appSyncOptions }
|
|
910
971
|
argoSync.mutate(variables, {
|
|
911
972
|
onSettled: closeArgoSyncDialog,
|
|
912
973
|
})
|
|
@@ -917,9 +978,17 @@ function GitOpsDetailView({ namespaces, onOpenResource, onOpenSettings }: GitOps
|
|
|
917
978
|
appLabel={`${namespace}/${name}`}
|
|
918
979
|
revision={rollbackTarget?.revision || ''}
|
|
919
980
|
historyId={rollbackTarget?.id}
|
|
981
|
+
source={rollbackTarget?.source}
|
|
982
|
+
multiSourceWarning={rollbackTarget?.rollbackMultiSourceWarning}
|
|
920
983
|
pending={argoRollback.isPending}
|
|
984
|
+
blockedReason={argoRollbackBlockedReason || (argoRollbackUpgrade ? radarUpgradeNoteText(argoRollbackUpgrade) : undefined)}
|
|
921
985
|
onCancel={() => setRollbackTarget(null)}
|
|
922
986
|
onConfirm={(opts) => {
|
|
987
|
+
if (argoRollbackUpgrade || argoRollbackBlockedReason) {
|
|
988
|
+
showError('Rollback unavailable', argoRollbackBlockedReason || radarUpgradeNoteText(argoRollbackUpgrade!))
|
|
989
|
+
setRollbackTarget(null)
|
|
990
|
+
return
|
|
991
|
+
}
|
|
923
992
|
const id = parseArgoRollbackID(rollbackTarget?.id)
|
|
924
993
|
if (id == null) {
|
|
925
994
|
showError('Rollback target became invalid', 'The history entry changed while the dialog was open. Reselect a target and try again.')
|
|
@@ -1128,7 +1197,7 @@ function TopologyCounts({ tree }: { tree: GitOpsResourceTree }) {
|
|
|
1128
1197
|
const outOfSync = nodes.filter((n) => (n.sync || '').toLowerCase() === 'outofsync').length
|
|
1129
1198
|
return (
|
|
1130
1199
|
<div className="hidden min-w-0 flex-1 items-center gap-3 truncate text-[11px] text-theme-text-tertiary sm:flex">
|
|
1131
|
-
<span><span className="text-theme-text-primary">{total}</span> resources</span>
|
|
1200
|
+
<span><span className="text-theme-text-primary">{total}</span> resources shown</span>
|
|
1132
1201
|
{dependencies > 0 && <span><span className="text-theme-text-primary">{dependencies}</span> {dependencies === 1 ? 'dependency' : 'dependencies'}</span>}
|
|
1133
1202
|
{failingDependencies > 0 && <span className="flex items-center gap-1 font-medium text-red-600 dark:text-red-400"><span className="h-1.5 w-1.5 rounded-full bg-red-500" /> {failingDependencies} {failingDependencies === 1 ? 'dependency' : 'dependencies'} failing</span>}
|
|
1134
1203
|
{healthy > 0 && <span className="flex items-center gap-1"><span className="h-1.5 w-1.5 rounded-full bg-emerald-500" /> {healthy} healthy</span>}
|
|
@@ -2,8 +2,7 @@ import { useNavCustomization } from '../../context/NavCustomization'
|
|
|
2
2
|
import { useCapabilities } from '../../api/client'
|
|
3
3
|
import { openCloudFunnel } from '../CloudFunnelButton'
|
|
4
4
|
|
|
5
|
-
// The one sentence a standalone Radar adds
|
|
6
|
-
// to another cluster": the thing the user just ran into is what Radar Cloud
|
|
5
|
+
// The one sentence a standalone Radar adds for a remote destination: what Radar Cloud
|
|
7
6
|
// does. "Radar Cloud" opens the same dialog as the top-right button, so
|
|
8
7
|
// there is one pitch and one connect flow. That dialog connects THIS
|
|
9
8
|
// cluster; the destination is a second connect from Cloud, which is why the
|
|
@@ -16,7 +15,7 @@ export function RemoteDestinationCloudHint() {
|
|
|
16
15
|
if (embedded || !capabilities.data?.cloudConnect) return null
|
|
17
16
|
return (
|
|
18
17
|
<>
|
|
19
|
-
|
|
18
|
+
For resources on another cluster, connect both clusters to{' '}
|
|
20
19
|
<button type="button" onClick={openCloudFunnel} className="underline decoration-theme-border underline-offset-2 hover:text-theme-text-primary">
|
|
21
20
|
Radar Cloud
|
|
22
21
|
</button>{' '}
|