@skyhook-io/radar-app 1.20.0 → 1.20.3
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 +1 -1
- package/src/App.tsx +18 -11
- package/src/api/client.namespaceSwitch.hook.test.tsx +170 -1
- package/src/api/client.pauseDeployment.test.tsx +77 -0
- package/src/api/client.restartError.test.ts +14 -0
- package/src/api/client.revisionRefresh.test.tsx +44 -0
- package/src/api/client.rollbackError.test.ts +14 -0
- package/src/api/client.ts +287 -21
- package/src/api/helmInventory.test.tsx +108 -0
- package/src/api/networkAttachments.test.tsx +120 -0
- package/src/api/networkAttachments.ts +30 -0
- package/src/api/radarFeatures.test.ts +5 -0
- package/src/api/radarFeatures.ts +5 -0
- package/src/api/secretsStore.test.ts +33 -0
- package/src/api/secretsStore.ts +37 -0
- package/src/components/ConnectionErrorView.test.tsx +11 -0
- package/src/components/ConnectionErrorView.tsx +19 -0
- package/src/components/ContextSwitcher.tsx +9 -2
- package/src/components/applications/ApplicationsView.openResource.test.tsx +118 -0
- package/src/components/applications/ApplicationsView.tsx +8 -11
- package/src/components/cost/CostView.tsx +27 -9
- package/src/components/curl/ServiceCurlAvailability.test.tsx +32 -0
- package/src/components/curl/ServiceCurlButton.tsx +2 -2
- package/src/components/diagnose/InvestigationView.tsx +12 -3
- package/src/components/diagnose/investigationCase.test.tsx +41 -0
- package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +72 -0
- package/src/components/diagnose/investigationEvidence/adapters/helm.test.tsx +52 -0
- package/src/components/diagnose/investigationEvidence/adapters/helm.ts +61 -16
- package/src/components/diagnose/investigationEvidence/adapters/listings.ts +34 -4
- package/src/components/diagnose/investigationEvidence/adapters/resource.ts +3 -2
- package/src/components/diagnose/investigationEvidence/bodies/platform.tsx +82 -51
- package/src/components/diagnose/investigationEvidence/types.ts +5 -0
- package/src/components/dock/TerminalPreferences.query.test.tsx +57 -0
- package/src/components/dock/TerminalPreferences.test.tsx +68 -0
- package/src/components/dock/TerminalPreferences.tsx +73 -0
- package/src/components/gitops/GitOpsView.tsx +1 -9
- package/src/components/helm/HelmDrawerFrame.tsx +101 -0
- package/src/components/helm/HelmDrawerRouting.test.tsx +86 -0
- package/src/components/helm/HelmReleaseDrawer.tsx +47 -98
- package/src/components/helm/HelmView.tsx +215 -71
- package/src/components/helm/NotCheckedBadge.test.tsx +62 -0
- package/src/components/helm/NotCheckedBadge.tsx +39 -0
- package/src/components/helm/ObservedHelmNotice.tsx +146 -0
- package/src/components/helm/ObservedHelmRelease.test.tsx +261 -0
- package/src/components/helm/ObservedHelmReleaseDrawer.test.tsx +80 -0
- package/src/components/helm/ObservedHelmReleaseDrawer.tsx +228 -0
- package/src/components/helm/OwnedResources.test.tsx +86 -0
- package/src/components/helm/OwnedResources.tsx +69 -10
- package/src/components/home/ClusterHealthCard.heading.test.tsx +72 -0
- package/src/components/home/ClusterHealthCard.restricted.test.tsx +76 -0
- package/src/components/home/ClusterHealthCard.test.ts +44 -1
- package/src/components/home/ClusterHealthCard.tsx +49 -14
- package/src/components/home/HelmSummary.tsx +38 -19
- package/src/components/home/HelmSummary.unread.test.ts +16 -0
- package/src/components/home/HomeAgentBlock.tsx +7 -0
- package/src/components/home/MCPSetupDialog.test.tsx +38 -12
- package/src/components/home/MCPSetupDialog.tsx +5 -2
- package/src/components/home/mcpToolCatalog.ts +45 -5
- package/src/components/issues/uncheckedSources.test.ts +2 -0
- package/src/components/issues/uncheckedSources.ts +3 -0
- package/src/components/resource/RightsizingStrip.test.ts +57 -0
- package/src/components/resource/RightsizingStrip.tsx +53 -4
- package/src/components/resources/ImageFilesystemModal.test.tsx +74 -6
- package/src/components/resources/ImageFilesystemModal.tsx +98 -6
- package/src/components/resources/PodFileUploadPanel.tsx +150 -0
- package/src/components/resources/PodFilesystemModal.tsx +246 -3
- package/src/components/resources/pod-file-upload.test.tsx +223 -0
- package/src/components/resources/pod-file-upload.ts +266 -0
- package/src/components/resources/renderers/HTTPRouteRenderer.test.tsx +50 -0
- package/src/components/resources/renderers/HTTPRouteRenderer.tsx +27 -0
- package/src/components/resources/renderers/PodRenderer.tsx +26 -1
- package/src/components/resources/renderers/SecretProviderClassRenderer.tsx +25 -0
- package/src/components/resources/renderers/ServiceRenderer.test.tsx +15 -2
- package/src/components/resources/renderers/ServiceRenderer.tsx +1 -1
- package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.test.tsx +160 -0
- package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.tsx +128 -0
- package/src/components/rightsizing/RightsizingScanView.tsx +16 -1
- package/src/components/rightsizing/model.test.ts +11 -0
- package/src/components/rightsizing/model.ts +3 -1
- package/src/components/rightsizing/presentation.test.ts +46 -0
- package/src/components/rightsizing/presentation.ts +17 -2
- package/src/components/traffic/TrafficView.tsx +27 -27
- package/src/components/traffic/trafficFilters.test.ts +18 -1
- package/src/components/traffic/trafficFilters.ts +30 -1
- package/src/components/ui/Omnibar.tsx +4 -1
- package/src/components/ui/RadarOmnibar.test.tsx +55 -2
- package/src/components/ui/RadarOmnibar.tsx +7 -1
- package/src/components/ui/SearchSyntaxHelp.test.tsx +9 -2
- package/src/components/ui/SearchSyntaxHelp.tsx +3 -2
- package/src/components/ui/UpdateNotification.test.tsx +23 -1
- package/src/components/ui/UpdateNotification.tsx +26 -2
- package/src/components/ui/omnibar-match.test.ts +7 -0
- package/src/components/ui/omnibar-match.ts +1 -0
- package/src/components/ui/searchCoverageNote.test.ts +17 -0
- package/src/components/ui/searchCoverageNote.ts +31 -7
- package/src/components/useContextSwitchFlow.tsx +9 -1
- package/src/components/whats-new/releaseNotes.ts +1 -1
- package/src/components/workload/NodeCertificateEvidence.test.tsx +51 -0
- package/src/components/workload/NodeCertificateEvidence.tsx +44 -0
- package/src/components/workload/WorkloadView.tsx +51 -11
- package/src/context/ConnectionContext.test.ts +1 -0
- package/src/context/ConnectionContext.tsx +2 -2
- package/src/contexts/CapabilitiesContext.tsx +2 -0
- package/src/hooks/useResolvedGitOpsOwner.test.ts +22 -0
- package/src/hooks/useResolvedGitOpsOwner.ts +6 -3
- package/src/integrations/resourceHosts.test.tsx +2 -2
- package/src/integrations/resourceHosts.tsx +9 -0
- package/src/utils/namespacePick.test.ts +87 -0
- package/src/utils/namespacePick.ts +88 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act, useEffect } from 'react'
|
|
3
|
+
import { createRoot, type Root } from 'react-dom/client'
|
|
4
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
5
|
+
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
|
6
|
+
import { unreadReason } from '@skyhook-io/k8s-ui/components/kueue/related-read'
|
|
7
|
+
import { SecondaryNetworksSection } from '@skyhook-io/k8s-ui/components/resources/renderers/SecondaryNetworksSection'
|
|
8
|
+
import { getPodNetworks, uniqueNetworkAttachmentRefs, type NetworkAttachmentLookups, type NetworkAttachmentRef } from '@skyhook-io/k8s-ui/utils/multus'
|
|
9
|
+
import { useNetworkAttachmentLookups } from './networkAttachments'
|
|
10
|
+
|
|
11
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true })
|
|
12
|
+
let root: Root
|
|
13
|
+
let container: HTMLDivElement
|
|
14
|
+
let client: QueryClient
|
|
15
|
+
let lookups: NetworkAttachmentLookups
|
|
16
|
+
const requests: string[] = []
|
|
17
|
+
// Responses per definition name, served in order; the last one repeats.
|
|
18
|
+
let responses: Record<string, { status: number; body: unknown }[]>
|
|
19
|
+
|
|
20
|
+
const found = { status: 200, body: { resource: { metadata: { name: 'x' } } } }
|
|
21
|
+
const fail = (status: number, error_code?: string) => ({ status, body: { error: 'nope', ...(error_code ? { error_code } : {}) } })
|
|
22
|
+
|
|
23
|
+
function Lookups({ refs }: { refs: NetworkAttachmentRef[] }) {
|
|
24
|
+
const result = useNetworkAttachmentLookups(refs)
|
|
25
|
+
useEffect(() => { lookups = result }, [result])
|
|
26
|
+
return null
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function Section({ names }: { names: string }) {
|
|
30
|
+
const pod = { metadata: { name: 'worker', namespace: 'apps', annotations: { 'k8s.v1.cni.cncf.io/networks': names } } }
|
|
31
|
+
const attachmentLookups = useNetworkAttachmentLookups(uniqueNetworkAttachmentRefs(getPodNetworks(pod).rows))
|
|
32
|
+
return <SecondaryNetworksSection pod={pod} attachmentLookups={attachmentLookups} onNavigate={() => undefined} />
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const ref = (name: string, namespace = 'apps'): NetworkAttachmentRef => ({ namespace, name })
|
|
36
|
+
const linked = (name: string) => [...container.querySelectorAll('button')].some(button => button.textContent === name)
|
|
37
|
+
const requestsFor = (name: string) => requests.filter(url => url.includes(`/${name}?`)).length
|
|
38
|
+
|
|
39
|
+
beforeEach(() => {
|
|
40
|
+
requests.length = 0
|
|
41
|
+
lookups = {}
|
|
42
|
+
responses = {}
|
|
43
|
+
vi.stubGlobal('fetch', async (input: string | URL | Request) => {
|
|
44
|
+
const url = String(input)
|
|
45
|
+
requests.push(url)
|
|
46
|
+
const name = new URL(url, 'http://localhost').pathname.split('/').pop() ?? ''
|
|
47
|
+
const queue = responses[name] ?? [found]
|
|
48
|
+
const next = queue.length > 1 ? queue.shift()! : queue[0]
|
|
49
|
+
return new Response(JSON.stringify(next.body), { status: next.status })
|
|
50
|
+
})
|
|
51
|
+
client = new QueryClient()
|
|
52
|
+
container = document.createElement('div')
|
|
53
|
+
root = createRoot(container)
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
afterEach(async () => {
|
|
57
|
+
await act(async () => root.unmount())
|
|
58
|
+
client.clear()
|
|
59
|
+
vi.unstubAllGlobals()
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
async function renderLookups(refs: NetworkAttachmentRef[]) {
|
|
63
|
+
await act(async () => root.render(<QueryClientProvider client={client}><Lookups refs={refs} /></QueryClientProvider>))
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function renderSection(names: string) {
|
|
67
|
+
await act(async () => root.render(<QueryClientProvider client={client}><Section names={names} /></QueryClientProvider>))
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
it('says whose access refused the read, and does not re-read a viewer denial', async () => {
|
|
71
|
+
const viewer = { state: 'unavailable', code: 'user_forbidden' } as const
|
|
72
|
+
const radar = { state: 'unavailable', code: 'radar_forbidden' } as const
|
|
73
|
+
responses = { hidden: [fail(403, 'user_forbidden')], blocked: [fail(503, 'radar_forbidden')] }
|
|
74
|
+
await renderSection('hidden,blocked')
|
|
75
|
+
await vi.waitFor(() => {
|
|
76
|
+
expect(container.textContent).toContain(unreadReason(viewer))
|
|
77
|
+
expect(container.textContent).toContain(unreadReason(radar))
|
|
78
|
+
}, { timeout: 6000 })
|
|
79
|
+
expect(linked('hidden') || linked('blocked')).toBe(false)
|
|
80
|
+
expect(requestsFor('hidden')).toBe(1)
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
it('keeps reading while Radar is still connecting and links the definition once it answers', async () => {
|
|
84
|
+
responses = { later: [fail(503, 'cluster_connecting'), found] }
|
|
85
|
+
await renderSection('later')
|
|
86
|
+
await vi.waitFor(() => expect(linked('later')).toBe(true), { timeout: 6000 })
|
|
87
|
+
expect(requestsFor('later')).toBe(2)
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it('reads a definition as missing only when the server proved it absent', async () => {
|
|
91
|
+
responses = { gone: [fail(404, 'object_not_found')], vague: [fail(404)] }
|
|
92
|
+
await renderSection('gone,vague')
|
|
93
|
+
const unconfirmed = unreadReason({ state: 'unconfirmed' })
|
|
94
|
+
await vi.waitFor(() => expect(container.textContent).toContain(unconfirmed), { timeout: 6000 })
|
|
95
|
+
const cards = [...container.querySelectorAll('.card-inner')].map(card => card.textContent ?? '')
|
|
96
|
+
const missing = 'No NetworkAttachmentDefinition with this name'
|
|
97
|
+
expect(cards.find(card => card.startsWith('gone'))).toContain(missing)
|
|
98
|
+
expect(cards.find(card => card.startsWith('vague'))).not.toContain(missing)
|
|
99
|
+
expect(requestsFor('gone')).toBe(1)
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it('reads the definition by its exact group and hyphenated plural', async () => {
|
|
103
|
+
await renderLookups([ref('present', 'shared')])
|
|
104
|
+
await vi.waitFor(() => expect(lookups['shared/present']?.state).toBe('found'))
|
|
105
|
+
expect(requests[0]).toBe('/api/resources/network-attachment-definitions/shared/present?group=k8s.cni.cncf.io')
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
it('makes no request for a Pod that names no definitions', async () => {
|
|
109
|
+
await renderLookups([])
|
|
110
|
+
expect(requests).toEqual([])
|
|
111
|
+
expect(lookups).toEqual({})
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
it('bounds how many definitions one Pod can make Radar read and marks the rest unchecked', async () => {
|
|
115
|
+
await renderLookups(Array.from({ length: 30 }, (_, index) => ref(`net-${index}`)))
|
|
116
|
+
await vi.waitFor(() => expect(Object.values(lookups).filter(lookup => lookup.state === 'found')).toHaveLength(20))
|
|
117
|
+
expect(new Set(requests).size).toBe(20)
|
|
118
|
+
const unchecked = Object.entries(lookups).filter(([, lookup]) => lookup.state === 'unchecked').map(([key]) => key)
|
|
119
|
+
expect(unchecked).toEqual(Array.from({ length: 10 }, (_, index) => `apps/net-${index + 20}`))
|
|
120
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NETWORK_ATTACHMENT_DEFINITION_GROUP,
|
|
3
|
+
NETWORK_ATTACHMENT_DEFINITION_PLURAL,
|
|
4
|
+
networkAttachmentKey,
|
|
5
|
+
type NetworkAttachmentLookups,
|
|
6
|
+
type NetworkAttachmentRef,
|
|
7
|
+
} from '@skyhook-io/k8s-ui/utils/multus'
|
|
8
|
+
import { useRelatedReads } from '../components/kueue/useRelatedReads'
|
|
9
|
+
|
|
10
|
+
// The names come from a Pod annotation anyone who can create Pods controls.
|
|
11
|
+
const MAX_LOOKUPS = 20
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Whether each NetworkAttachmentDefinition a Pod names can be read, as the
|
|
15
|
+
* viewer. One read per definition rather than a list: a denied list comes back
|
|
16
|
+
* empty, which would look the same as a definition that does not exist.
|
|
17
|
+
*/
|
|
18
|
+
export function useNetworkAttachmentLookups(refs: NetworkAttachmentRef[]): NetworkAttachmentLookups {
|
|
19
|
+
const bounded = refs.slice(0, MAX_LOOKUPS)
|
|
20
|
+
const reads = useRelatedReads(bounded.map(ref => ({
|
|
21
|
+
kind: NETWORK_ATTACHMENT_DEFINITION_PLURAL,
|
|
22
|
+
group: NETWORK_ATTACHMENT_DEFINITION_GROUP,
|
|
23
|
+
namespace: ref.namespace,
|
|
24
|
+
name: ref.name,
|
|
25
|
+
})))
|
|
26
|
+
const lookups: NetworkAttachmentLookups = {}
|
|
27
|
+
bounded.forEach((ref, index) => { lookups[networkAttachmentKey(ref)] = reads[index] })
|
|
28
|
+
for (const ref of refs.slice(MAX_LOOKUPS)) lookups[networkAttachmentKey(ref)] = { state: 'unchecked' }
|
|
29
|
+
return lookups
|
|
30
|
+
}
|
|
@@ -15,6 +15,11 @@ import {
|
|
|
15
15
|
} from './radarFeatures'
|
|
16
16
|
|
|
17
17
|
describe('radarFeatureSupport', () => {
|
|
18
|
+
it('requires explicit Event content support even when the older search endpoint is available', () => {
|
|
19
|
+
expect(radarFeatureSupport('searchEventContent', { features: { searchCoverage: true } }, 'v99.0.0')).toBe('unsupported')
|
|
20
|
+
expect(radarFeatureSupport('searchEventContent', { features: { searchEventContent: true } }, 'v1.0.0')).toBe('supported')
|
|
21
|
+
expect(radarFeatureSupport('searchEventContent', undefined, 'dev')).toBe('unknown')
|
|
22
|
+
})
|
|
18
23
|
it('trusts the advertised flag over the version', () => {
|
|
19
24
|
expect(radarFeatureSupport('policyResource', { features: { policyResource: true } }, 'v1.7.2')).toBe('supported')
|
|
20
25
|
expect(radarFeatureSupport('policyResource', { features: { policyResource: true } }, undefined)).toBe('supported')
|
package/src/api/radarFeatures.ts
CHANGED
|
@@ -33,6 +33,7 @@ export const RADAR_FEATURES = {
|
|
|
33
33
|
resourceReadCoverage: { label: 'Resource read coverage', flag: 'resourceReadCoverage', flagShippedWithEndpoint: true },
|
|
34
34
|
searchCoverage: { label: 'Search coverage and object filters', flag: 'searchCoverage', flagShippedWithEndpoint: true },
|
|
35
35
|
applicationEvidence: { label: 'Application evidence collection', flag: 'applicationEvidence', flagShippedWithEndpoint: true },
|
|
36
|
+
searchEventContent: { label: 'Event reason and message searches', flag: 'searchEventContent', flagShippedWithEndpoint: true },
|
|
36
37
|
resourceIssues: { label: 'Operational issues', minimumVersion: 'v1.8.0', flag: 'resourceIssues' },
|
|
37
38
|
resourceIssueCoverage: { label: 'Resource-specific issue views', flag: 'resourceIssueCoverage', flagShippedWithEndpoint: true },
|
|
38
39
|
podEnvironment: { label: 'Values from ConfigMaps and Secrets', minimumVersion: 'v1.9.0', flag: 'podEnvironment' },
|
|
@@ -44,6 +45,7 @@ export const RADAR_FEATURES = {
|
|
|
44
45
|
drainPlan: { label: 'Drain plans', minimumVersion: 'v1.14.0' },
|
|
45
46
|
applications: { label: 'Applications', minimumVersion: 'v1.7.7' },
|
|
46
47
|
workloadHistory: { label: 'Workload history', flag: 'workloadHistory', flagShippedWithEndpoint: true },
|
|
48
|
+
deploymentPause: { label: 'Deployment rollout pause and resume', flag: 'deploymentPause', flagShippedWithEndpoint: true },
|
|
47
49
|
cnpgWorkspace: { label: 'CloudNativePG views', flag: 'cnpgWorkspace', flagShippedWithEndpoint: true },
|
|
48
50
|
cnpgProtectionSetup: { label: 'CloudNativePG backup setup', flag: 'cnpgProtectionSetup', flagShippedWithEndpoint: true },
|
|
49
51
|
gitopsWriteEvidence: { label: 'GitOps revert warnings', flag: 'gitopsWriteEvidence', flagShippedWithEndpoint: true },
|
|
@@ -66,7 +68,10 @@ export const RADAR_FEATURES = {
|
|
|
66
68
|
// turns it on.
|
|
67
69
|
argoEnableSelfHealOff: { label: 'Auto-sync that starts without self-heal', flag: 'argoEnableSelfHealOff', flagShippedWithEndpoint: true },
|
|
68
70
|
helmSourceIdentity: { label: 'Helm source selection', flag: 'helmSourceIdentity', flagShippedWithEndpoint: true },
|
|
71
|
+
// Never blocks a control: on an older Radar the Helm view reads /helm/releases.
|
|
72
|
+
helmInventory: { label: 'Helm releases without Secret access', flag: 'helmInventory', flagShippedWithEndpoint: true },
|
|
69
73
|
agentSigninCheck: { label: 'Agent sign-in checks', flag: 'agentSigninCheck', flagShippedWithEndpoint: true },
|
|
74
|
+
podFileUpload: { label: 'Pod file uploads', flag: 'podFileUpload', flagShippedWithEndpoint: true },
|
|
70
75
|
} as const satisfies Record<string, RadarFeatureSpec>
|
|
71
76
|
|
|
72
77
|
export type RadarFeature = keyof typeof RADAR_FEATURES
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { ApiError } from './client'
|
|
3
|
+
import { toSecretsStoreRead } from './secretsStore'
|
|
4
|
+
|
|
5
|
+
const complete = { status: 'complete' as const, scope: { type: 'namespaces' as const }, gaps: [] }
|
|
6
|
+
const partial = (code: string) => ({ status: 'partial' as const, scope: { type: 'namespaces' as const }, gaps: [{ code, action: 'retry' }] })
|
|
7
|
+
|
|
8
|
+
describe('toSecretsStoreRead', () => {
|
|
9
|
+
it('trusts absence only from a complete answer', () => {
|
|
10
|
+
expect(toSecretsStoreRead({ data: [], coverage: complete, error: null, isLoading: false })).toEqual({ state: 'ok', items: [], complete: true })
|
|
11
|
+
expect(toSecretsStoreRead({ data: [{}], coverage: partial('radar_forbidden') as any, error: null, isLoading: false })).toEqual({ state: 'ok', items: [{}], complete: false })
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('does not trust absence from a list without coverage', () => {
|
|
15
|
+
expect(toSecretsStoreRead({ data: [], coverage: { status: 'unknown' }, error: null, isLoading: false })).toEqual({ state: 'ok', items: [], complete: false })
|
|
16
|
+
expect(toSecretsStoreRead({ data: [], error: null, isLoading: false })).toEqual({ state: 'ok', items: [], complete: false })
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('keeps a denial apart from an empty list', () => {
|
|
20
|
+
expect(toSecretsStoreRead({ error: new ApiError('forbidden', 403), isLoading: false })).toEqual({ state: 'forbidden' })
|
|
21
|
+
expect(toSecretsStoreRead({ data: [], coverage: partial('user_forbidden') as any, error: null, isLoading: false })).toEqual({ state: 'forbidden' })
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('reports an unserved API as unavailable, not missing', () => {
|
|
25
|
+
const notServed = new ApiError('unknown resource kind: secretproviderclasses', 400, { error_code: 'kind_unknown' } as any)
|
|
26
|
+
expect(toSecretsStoreRead({ error: notServed, isLoading: false }).state).toBe('unavailable')
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('stays loading while the kind syncs', () => {
|
|
30
|
+
expect(toSecretsStoreRead({ isLoading: true, error: null })).toEqual({ state: 'loading' })
|
|
31
|
+
expect(toSecretsStoreRead({ data: [], coverage: partial('kind_sync_pending') as any, error: null, isLoading: false })).toEqual({ state: 'loading' })
|
|
32
|
+
})
|
|
33
|
+
})
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ResourceCoverage } from '@skyhook-io/k8s-ui/types/resource-coverage'
|
|
2
|
+
import type { SecretsStoreRead } from '@skyhook-io/k8s-ui/components/resources/resource-utils-secrets-store'
|
|
3
|
+
import { ApiError, isForbiddenError, isStillLoadingError } from './client'
|
|
4
|
+
|
|
5
|
+
interface ListQuery<T> {
|
|
6
|
+
data?: T[]
|
|
7
|
+
coverage?: ResourceCoverage
|
|
8
|
+
error: unknown
|
|
9
|
+
isLoading: boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* One namespace list read, as the Secrets Store renderers need it: what came
|
|
14
|
+
* back, and whether its absence of an object can be trusted. A denial, a kind
|
|
15
|
+
* that is not served and a read still warming up stay distinct from an empty
|
|
16
|
+
* answer.
|
|
17
|
+
*/
|
|
18
|
+
export function toSecretsStoreRead<T>(query: ListQuery<T>): SecretsStoreRead<T> {
|
|
19
|
+
if (query.error) {
|
|
20
|
+
if (isForbiddenError(query.error)) return { state: 'forbidden' }
|
|
21
|
+
if (isStillLoadingError(query.error)) return { state: 'loading' }
|
|
22
|
+
if (query.error instanceof ApiError && query.error.data?.error_code === 'kind_unknown') {
|
|
23
|
+
return { state: 'unavailable', message: 'The Secrets Store CSI driver’s API is not served in this cluster.' }
|
|
24
|
+
}
|
|
25
|
+
return { state: 'unavailable', message: query.error instanceof Error ? query.error.message : String(query.error) }
|
|
26
|
+
}
|
|
27
|
+
if (query.isLoading || !query.data) return { state: 'loading' }
|
|
28
|
+
const coverage = query.coverage
|
|
29
|
+
if (coverage?.status === 'partial') {
|
|
30
|
+
// The caller asked for one namespace, so a user denial leaves nothing read.
|
|
31
|
+
if (query.data.length === 0 && coverage.gaps.some(gap => gap.code === 'user_forbidden')) return { state: 'forbidden' }
|
|
32
|
+
if (query.data.length === 0 && coverage.gaps.some(gap => gap.code === 'kind_sync_pending')) return { state: 'loading' }
|
|
33
|
+
return { state: 'ok', items: query.data, complete: false }
|
|
34
|
+
}
|
|
35
|
+
// Without coverage (an older Radar) a list cannot establish absence.
|
|
36
|
+
return { state: 'ok', items: query.data, complete: coverage?.status === 'complete' }
|
|
37
|
+
}
|
|
@@ -192,6 +192,17 @@ describe('ConnectionErrorView kubeconfig guidance', () => {
|
|
|
192
192
|
})
|
|
193
193
|
})
|
|
194
194
|
|
|
195
|
+
describe('ConnectionErrorView settings error', () => {
|
|
196
|
+
it('shows the message itself and no action a restart is needed to clear', () => {
|
|
197
|
+
const markup = renderError('settings', 'prod')
|
|
198
|
+
|
|
199
|
+
expect(markup).toContain('safe error')
|
|
200
|
+
expect(markup).not.toContain('id="connection-raw-error"')
|
|
201
|
+
expect(markup).not.toContain('Retry Connection')
|
|
202
|
+
expect(markup).not.toContain('Switch context')
|
|
203
|
+
})
|
|
204
|
+
})
|
|
205
|
+
|
|
195
206
|
describe('ConnectionErrorView after a refused switch', () => {
|
|
196
207
|
const connection = { state: 'disconnected' as const, context: 'staging-eu', errorType: 'auth', error: 'safe error' }
|
|
197
208
|
|
|
@@ -403,6 +403,25 @@ export function ConnectionErrorView({ connection, onRetry, isRetrying, back, var
|
|
|
403
403
|
openLocalTerminal({ initialCommand: command, title: 'Auth' })
|
|
404
404
|
}
|
|
405
405
|
|
|
406
|
+
// A startup setting kept Radar from connecting, and the error names the
|
|
407
|
+
// setting to change. Settings are read at startup, so retrying or switching
|
|
408
|
+
// context can't clear it: only the message, no recovery actions.
|
|
409
|
+
if (connection.errorType === 'settings') {
|
|
410
|
+
return (
|
|
411
|
+
<div className="flex-1 flex items-start justify-center pt-12 px-8">
|
|
412
|
+
<div className="max-w-xl w-full flex flex-col items-center text-center">
|
|
413
|
+
<div className="w-14 h-14 rounded-full bg-red-500/10 flex items-center justify-center mb-5">
|
|
414
|
+
<ServerOff className="w-8 h-8 text-red-400" />
|
|
415
|
+
</div>
|
|
416
|
+
<h2 className="text-xl font-semibold text-theme-text-primary mb-6">Settings Need a Change</h2>
|
|
417
|
+
<div className="w-full bg-theme-surface border border-theme-border rounded-lg p-4 text-left">
|
|
418
|
+
<p className="text-sm text-theme-text-secondary break-words">{connection.error}</p>
|
|
419
|
+
</div>
|
|
420
|
+
</div>
|
|
421
|
+
</div>
|
|
422
|
+
)
|
|
423
|
+
}
|
|
424
|
+
|
|
406
425
|
return (
|
|
407
426
|
<div className="flex-1 flex items-start justify-center pt-12 px-8">
|
|
408
427
|
<div className="max-w-xl w-full">
|
|
@@ -7,6 +7,7 @@ import { useContexts, useClusterInfo, useCapabilities } from '../api/client'
|
|
|
7
7
|
import type { ContextInfo } from '../types'
|
|
8
8
|
import { useContextSwitchFlow } from './useContextSwitchFlow'
|
|
9
9
|
import { useContextSwitch } from '../context/ContextSwitchContext'
|
|
10
|
+
import { useConnection } from '../context/ConnectionContext'
|
|
10
11
|
import { parseContextForSwitcher, visibleContextQualifier, type ParsedContextName } from '../utils/context-name'
|
|
11
12
|
|
|
12
13
|
interface ContextSwitcherProps {
|
|
@@ -31,6 +32,10 @@ export const ContextSwitcher = forwardRef<ContextSwitcherHandle, ContextSwitcher
|
|
|
31
32
|
const { data: capabilities } = useCapabilities()
|
|
32
33
|
const switchFlow = useContextSwitchFlow()
|
|
33
34
|
const { failedSwitch } = useContextSwitch()
|
|
35
|
+
// A settings error (Desktop's namespace list over the limit) blocks every
|
|
36
|
+
// switch until restart, so offering the list would only lead to a refusal.
|
|
37
|
+
const { connection } = useConnection()
|
|
38
|
+
const settingsBlocked = connection.errorType === 'settings'
|
|
34
39
|
|
|
35
40
|
// Parse contexts and decide whether to render group headers (multi-account only).
|
|
36
41
|
// hasMultipleSources gates the kubeconfig-source chip — only useful when 2+
|
|
@@ -80,7 +85,9 @@ export const ContextSwitcher = forwardRef<ContextSwitcherHandle, ContextSwitcher
|
|
|
80
85
|
id: p.context.name,
|
|
81
86
|
name: p.raw,
|
|
82
87
|
nameQualifier: visibleContextQualifier(p.nameQualifier, p.context.source, hasMultipleSources),
|
|
83
|
-
|
|
88
|
+
// The full context under any shortened name: OpenShift writes one context
|
|
89
|
+
// per project for the same server, and only this line tells them apart.
|
|
90
|
+
secondary: p.raw !== p.clusterName ? p.raw : undefined,
|
|
84
91
|
badge: p.region || undefined,
|
|
85
92
|
sourceLabel: hasMultipleSources ? p.context.source : undefined,
|
|
86
93
|
group: { key: groupKey, label: groupLabel },
|
|
@@ -134,7 +141,7 @@ export const ContextSwitcher = forwardRef<ContextSwitcherHandle, ContextSwitcher
|
|
|
134
141
|
items={items}
|
|
135
142
|
onSelect={handleSelect}
|
|
136
143
|
loading={switchFlow.isPending}
|
|
137
|
-
disabled={contextsLoading || !capabilities || capabilities.configManagement === 'operator'}
|
|
144
|
+
disabled={settingsBlocked || contextsLoading || !capabilities || capabilities.configManagement === 'operator'}
|
|
138
145
|
searchable={items.length > 1}
|
|
139
146
|
currentSelectable={!!failedSwitch}
|
|
140
147
|
showGroupHeaders={hasMultipleAccounts}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act, useEffect } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { MemoryRouter, useLocation } from 'react-router-dom'
|
|
5
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
6
|
+
import { afterEach, beforeEach, expect, it, vi } from 'vitest'
|
|
7
|
+
import { ToastProvider, type AppRow, type AppWorkload, type SelectedResource } from '@skyhook-io/k8s-ui'
|
|
8
|
+
import { ApplicationsView } from './ApplicationsView'
|
|
9
|
+
|
|
10
|
+
let apps: AppRow[] = []
|
|
11
|
+
const idle = { data: undefined, isLoading: false, isError: false, error: null }
|
|
12
|
+
|
|
13
|
+
vi.mock('../../api/client', () => ({
|
|
14
|
+
useApplications: () => ({ ...idle, data: { applications: apps }, isSuccess: true, dataUpdatedAt: 0, refetch: () => {} }),
|
|
15
|
+
useApplicationHistory: () => idle,
|
|
16
|
+
useGitOpsTree: () => idle,
|
|
17
|
+
useHelmRelease: () => idle,
|
|
18
|
+
useIssues: () => idle,
|
|
19
|
+
useTopology: () => idle,
|
|
20
|
+
}))
|
|
21
|
+
vi.mock('../../context/ConnectionContext', () => ({ useConnection: () => ({ connection: { state: 'connected', context: 'test' } }) }))
|
|
22
|
+
vi.mock('../../context/TimelineSource', () => ({
|
|
23
|
+
useTimelineSource: () => ({ capabilities: { mode: 'local' }, useEvents: () => ({ data: [], isLoading: false, isError: false }) }),
|
|
24
|
+
}))
|
|
25
|
+
// The workload view's own content is out of scope here: the stub stands in for
|
|
26
|
+
// any resource the user clicks inside it (a config chip or a topology node).
|
|
27
|
+
vi.mock('../workload/WorkloadView', () => ({
|
|
28
|
+
WorkloadView: ({ name, onNavigateToResource }: { name: string; onNavigateToResource: (r: SelectedResource) => void }) => (
|
|
29
|
+
<div data-testid="workload-view" data-name={name}>
|
|
30
|
+
<button data-testid="open-cm" onClick={() => onNavigateToResource({ kind: 'ConfigMap', namespace: 'shop', name: 'web-config' })} />
|
|
31
|
+
<button data-testid="open-ing" onClick={() => onNavigateToResource({ kind: 'Ingress', namespace: 'shop', name: 'web', group: 'networking.k8s.io' })} />
|
|
32
|
+
</div>
|
|
33
|
+
),
|
|
34
|
+
}))
|
|
35
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
36
|
+
|
|
37
|
+
function deployment(name: string): AppWorkload {
|
|
38
|
+
return { kind: 'Deployment', group: 'apps', namespace: 'shop', name, health: 'healthy', ready: 1, desired: 1, restarts: 0 }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function app(key: string, workloadNames: string[]): AppRow {
|
|
42
|
+
return { key, name: key.split('/').pop() ?? key, namespace: 'shop', health: 'healthy', workloads: workloadNames.map(deployment) }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let root: ReturnType<typeof createRoot>
|
|
46
|
+
let container: HTMLDivElement
|
|
47
|
+
let client: QueryClient
|
|
48
|
+
let location = ''
|
|
49
|
+
|
|
50
|
+
function recordLocation(next: string) {
|
|
51
|
+
location = next
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function LocationProbe({ onChange }: { onChange: (location: string) => void }) {
|
|
55
|
+
const loc = useLocation()
|
|
56
|
+
useEffect(() => onChange(`${loc.pathname}${loc.search}`), [loc, onChange])
|
|
57
|
+
return null
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
beforeEach(() => {
|
|
61
|
+
vi.stubGlobal('matchMedia', () => ({ matches: false, addEventListener: () => {}, removeEventListener: () => {} }))
|
|
62
|
+
container = document.createElement('div')
|
|
63
|
+
document.body.appendChild(container)
|
|
64
|
+
root = createRoot(container)
|
|
65
|
+
client = new QueryClient({ defaultOptions: { queries: { retry: false } } })
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
afterEach(async () => {
|
|
69
|
+
await act(async () => root.unmount())
|
|
70
|
+
container.remove()
|
|
71
|
+
client.clear()
|
|
72
|
+
vi.unstubAllGlobals()
|
|
73
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
async function renderAt(url: string, onOpenResource = vi.fn()) {
|
|
77
|
+
await act(async () => {
|
|
78
|
+
root.render(
|
|
79
|
+
<QueryClientProvider client={client}>
|
|
80
|
+
<ToastProvider>
|
|
81
|
+
<MemoryRouter initialEntries={[url]}>
|
|
82
|
+
<ApplicationsView namespaces={[]} onOpenResource={onOpenResource} />
|
|
83
|
+
<LocationProbe onChange={recordLocation} />
|
|
84
|
+
</MemoryRouter>
|
|
85
|
+
</ToastProvider>
|
|
86
|
+
</QueryClientProvider>,
|
|
87
|
+
)
|
|
88
|
+
})
|
|
89
|
+
await act(async () => { await new Promise((resolve) => setTimeout(resolve, 0)) })
|
|
90
|
+
return onOpenResource
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async function click(testId: string) {
|
|
94
|
+
const button = container.querySelector(`[data-testid="${testId}"]`)
|
|
95
|
+
if (!(button instanceof HTMLElement)) throw new Error(`no ${testId} in the workload view`)
|
|
96
|
+
await act(async () => button.click())
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
it('opens a ConfigMap clicked in a single-workload app on its resource page', async () => {
|
|
100
|
+
apps = [app('shop/Deployment/web', ['web'])]
|
|
101
|
+
await renderAt('/applications?app=shop%2FDeployment%2Fweb&tab=topology')
|
|
102
|
+
await click('open-cm')
|
|
103
|
+
const url = new URL(location, 'http://radar.invalid')
|
|
104
|
+
expect(url.pathname).toBe('/resources/configmaps')
|
|
105
|
+
expect(url.searchParams.get('resource')).toBe('shop/web-config')
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
it('keeps the API group, namespace filter and open investigation when opening an Ingress from a single-workload app', async () => {
|
|
109
|
+
apps = [app('shop/Deployment/web', ['web'])]
|
|
110
|
+
await renderAt('/applications?app=shop%2FDeployment%2Fweb&namespaces=shop&ai-run=run-1')
|
|
111
|
+
await click('open-ing')
|
|
112
|
+
const url = new URL(location, 'http://radar.invalid')
|
|
113
|
+
expect(url.pathname).toBe('/resources/ingresses')
|
|
114
|
+
expect(url.searchParams.get('resource')).toBe('shop/web')
|
|
115
|
+
expect(url.searchParams.get('apiGroup')).toBe('networking.k8s.io')
|
|
116
|
+
expect(url.searchParams.get('namespaces')).toBe('shop')
|
|
117
|
+
expect(url.searchParams.get('ai-run')).toBe('run-1')
|
|
118
|
+
})
|
|
@@ -52,7 +52,7 @@ import {
|
|
|
52
52
|
} from "../../api/client";
|
|
53
53
|
import { useConnection } from "../../context/ConnectionContext";
|
|
54
54
|
import { useTimelineSource } from "../../context/TimelineSource";
|
|
55
|
-
import { apiVersionToGroup,
|
|
55
|
+
import { apiVersionToGroup, kindToPluralWithGroup, relatedResourcePath, withCrossViewParams } from "../../utils/navigation";
|
|
56
56
|
import { WorkloadView } from "../workload/WorkloadView";
|
|
57
57
|
import { ApplicationCostTab } from "../cost/ApplicationCostTab";
|
|
58
58
|
import { useTimelineRetentionNote } from "../../context/TimelineCustomization";
|
|
@@ -484,21 +484,18 @@ function AppDetailRoute({
|
|
|
484
484
|
const openWorkloadResource = useCallback(
|
|
485
485
|
(resource: SelectedResource) => {
|
|
486
486
|
const pluralKind = kindToPluralWithGroup(resource.kind, resource.group ?? "")
|
|
487
|
-
|
|
487
|
+
// The peek never covers the inline workload view: opening it drops
|
|
488
|
+
// ?workload so the app overview sits behind it. A single-workload app
|
|
489
|
+
// has no app overview and puts ?workload straight back, which would hide
|
|
490
|
+
// the peek, so its resources open on their own page instead.
|
|
491
|
+
if (pluralKind.toLowerCase() !== "pods" && !singleWorkloadKey) {
|
|
488
492
|
onOpenResource(resource);
|
|
489
493
|
return;
|
|
490
494
|
}
|
|
491
495
|
|
|
492
|
-
|
|
493
|
-
...resource,
|
|
494
|
-
kind: pluralKind,
|
|
495
|
-
}).split("?");
|
|
496
|
-
const params = new URLSearchParams(rawSearch);
|
|
497
|
-
const activeNamespaces = searchParams.get("namespaces");
|
|
498
|
-
if (activeNamespaces) params.set("namespaces", activeNamespaces);
|
|
499
|
-
navigate({ pathname, search: params.toString() });
|
|
496
|
+
navigate(withCrossViewParams(relatedResourcePath(resource), searchParams.toString()));
|
|
500
497
|
},
|
|
501
|
-
[navigate, onOpenResource, searchParams],
|
|
498
|
+
[navigate, onOpenResource, searchParams, singleWorkloadKey],
|
|
502
499
|
);
|
|
503
500
|
const openSource = useCallback(
|
|
504
501
|
(source: AppSourceRef) => {
|
|
@@ -57,6 +57,8 @@ interface CostViewProps {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
const SYSTEM_COST_NAMESPACES = new Set(['kube-system', 'kube-public', 'kube-node-lease'])
|
|
60
|
+
const STORAGE_UNKNOWN_HINT =
|
|
61
|
+
"Storage cost couldn't be calculated, so totals here leave it out. It needs volume sizes in Prometheus: kube_persistentvolume_capacity_bytes from kube-state-metrics."
|
|
60
62
|
|
|
61
63
|
export function CostView(props: CostViewProps) {
|
|
62
64
|
const { pathname } = useLocation()
|
|
@@ -170,7 +172,8 @@ function CostOverview({ onBack, onOpenResource }: CostViewProps) {
|
|
|
170
172
|
const totalCpu = namespaces.reduce((sum, ns) => sum + ns.cpuCost, 0)
|
|
171
173
|
const totalMem = namespaces.reduce((sum, ns) => sum + ns.memoryCost, 0)
|
|
172
174
|
const totalStorage = data.totalStorageCost ?? 0
|
|
173
|
-
const
|
|
175
|
+
const storageUnknown = data.totalStorageCost === null
|
|
176
|
+
const hasStorage = namespaces.some((ns) => (ns.storageCost ?? 0) > 0)
|
|
174
177
|
const hasSystemNamespaces = namespaces.some((ns) => isSystemCostNamespace(ns.name))
|
|
175
178
|
|
|
176
179
|
// Compute split percentages (CPU + Memory + optional Storage)
|
|
@@ -277,11 +280,20 @@ function CostOverview({ onBack, onOpenResource }: CostViewProps) {
|
|
|
277
280
|
<span className="w-2.5 h-2.5 rounded-sm bg-amber-500" />
|
|
278
281
|
Memory {formatProjectedMonthlyRate(totalMem, currency)}
|
|
279
282
|
</span>
|
|
280
|
-
{
|
|
281
|
-
<
|
|
282
|
-
<span className="
|
|
283
|
-
|
|
284
|
-
|
|
283
|
+
{storageUnknown ? (
|
|
284
|
+
<Tooltip content={STORAGE_UNKNOWN_HINT}>
|
|
285
|
+
<span className="flex items-center gap-1.5 cursor-help">
|
|
286
|
+
<span className="w-2.5 h-2.5 rounded-sm bg-teal-500" />
|
|
287
|
+
Storage unknown
|
|
288
|
+
</span>
|
|
289
|
+
</Tooltip>
|
|
290
|
+
) : (
|
|
291
|
+
hasStorage && (
|
|
292
|
+
<span className="flex items-center gap-1.5">
|
|
293
|
+
<span className="w-2.5 h-2.5 rounded-sm bg-teal-500" />
|
|
294
|
+
Storage {formatProjectedMonthlyRate(totalStorage, currency)}
|
|
295
|
+
</span>
|
|
296
|
+
)
|
|
285
297
|
)}
|
|
286
298
|
</div>
|
|
287
299
|
</div>
|
|
@@ -294,7 +306,7 @@ function CostOverview({ onBack, onOpenResource }: CostViewProps) {
|
|
|
294
306
|
className="h-full bg-amber-500 transition-all duration-300"
|
|
295
307
|
style={{ width: `${memPct}%` }}
|
|
296
308
|
/>
|
|
297
|
-
{hasStorage && (
|
|
309
|
+
{hasStorage && !storageUnknown && (
|
|
298
310
|
<div
|
|
299
311
|
className="h-full bg-teal-500 transition-all duration-300"
|
|
300
312
|
style={{ width: `${storagePct}%` }}
|
|
@@ -492,9 +504,15 @@ function NamespaceCostRow({
|
|
|
492
504
|
<span className="text-[11px] text-theme-text-tertiary tabular-nums text-right">
|
|
493
505
|
{formatProjectedMonthlyCost(ns.cpuCost, currency)} /{' '}
|
|
494
506
|
{formatProjectedMonthlyCost(ns.memoryCost, currency)}
|
|
495
|
-
{
|
|
507
|
+
{ns.storageCost === null ? (
|
|
508
|
+
<Tooltip content={STORAGE_UNKNOWN_HINT}>
|
|
509
|
+
<span className="cursor-help"> / storage unknown</span>
|
|
510
|
+
</Tooltip>
|
|
511
|
+
) : (
|
|
512
|
+
hasStorage &&
|
|
496
513
|
(ns.storageCost ?? 0) > 0 &&
|
|
497
|
-
` / ${formatProjectedMonthlyCost(ns.storageCost ?? 0, currency)}`
|
|
514
|
+
` / ${formatProjectedMonthlyCost(ns.storageCost ?? 0, currency)}`
|
|
515
|
+
)}
|
|
498
516
|
</span>
|
|
499
517
|
</button>
|
|
500
518
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
2
|
+
import { expect, it } from 'vitest'
|
|
3
|
+
import { ServicePortCards } from '@skyhook-io/k8s-ui/components/resources/renderers/ServiceRenderer'
|
|
4
|
+
import { CurlButton, isHttpishPort } from './ServiceCurlButton'
|
|
5
|
+
|
|
6
|
+
// The UI keeps Curl for every Service shape, including headless, ExternalName
|
|
7
|
+
// and selector-less ones; only MCP's curl_service is narrower.
|
|
8
|
+
it.each([
|
|
9
|
+
['ClusterIP', '10.0.0.8', { app: 'demo' }],
|
|
10
|
+
['LoadBalancer', '10.0.0.8', { app: 'demo' }],
|
|
11
|
+
['ClusterIP', 'None', { app: 'demo' }],
|
|
12
|
+
['ClusterIP', undefined, { app: 'demo' }],
|
|
13
|
+
['ClusterIP', '10.0.0.8', {}],
|
|
14
|
+
['ExternalName', undefined, {}],
|
|
15
|
+
] as const)('preserves UI Service requests through the shared workload port cards: %s %s', (type, clusterIP, selector) => {
|
|
16
|
+
const service = { metadata: { namespace: 'team', name: 'app' }, spec: { type, clusterIP, selector, ports: [{ port: 80, protocol: 'TCP' }] } }
|
|
17
|
+
const html = renderToStaticMarkup(<ServicePortCards service={service} renderPortAction={() => <CurlButton active={false} onClick={() => {}} />} />)
|
|
18
|
+
expect(html).toContain('aria-expanded')
|
|
19
|
+
// Port information remains available even when the HTTP action is unsupported.
|
|
20
|
+
expect(html).toContain('80')
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it.each([
|
|
24
|
+
['TCP', true],
|
|
25
|
+
[undefined, true],
|
|
26
|
+
['tcp', true],
|
|
27
|
+
['UDP', false],
|
|
28
|
+
['SCTP', false],
|
|
29
|
+
] as const)('offers Curl only on TCP ports (HTTP rides TCP): protocol %s', (protocol, offered) => {
|
|
30
|
+
// Port 8080 and name http would otherwise read as HTTP.
|
|
31
|
+
expect(isHttpishPort(8080, 'http', undefined, protocol)).toBe(offered)
|
|
32
|
+
})
|
|
@@ -36,8 +36,8 @@ export function defaultPathForPort(port: number, name?: string, appProtocol?: st
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export function isHttpishPort(port: number, name?: string, appProtocol?: string, protocol?: string): boolean {
|
|
39
|
-
// HTTP rides TCP —
|
|
40
|
-
if (
|
|
39
|
+
// HTTP rides TCP — UDP and SCTP ports are never GET targets (e.g. statsd "metrics-udp").
|
|
40
|
+
if (protocol && protocol.toUpperCase() !== 'TCP') return false
|
|
41
41
|
const proto = (appProtocol || '').toLowerCase()
|
|
42
42
|
if (proto === 'http' || proto === 'https' || proto === 'http2') return true
|
|
43
43
|
if (proto && proto !== 'tcp') {
|