@skyhook-io/k8s-ui 1.12.0 → 1.13.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/package.json +4 -4
- package/src/components/issues/severity.ts +1 -0
- package/src/components/resources/ResourcesView.empty-note.test.ts +41 -0
- package/src/components/resources/ResourcesView.tsx +410 -5
- package/src/components/resources/index.ts +27 -0
- package/src/components/resources/kyverno-legacy-action.test.ts +98 -0
- package/src/components/resources/renderers/AnalysisRunRenderer.test.tsx +241 -0
- package/src/components/resources/renderers/AnalysisRunRenderer.tsx +166 -0
- package/src/components/resources/renderers/CNPGBackupRenderer.tsx +31 -2
- package/src/components/resources/renderers/CNPGClusterRenderer.test.tsx +33 -0
- package/src/components/resources/renderers/CNPGClusterRenderer.tsx +47 -4
- package/src/components/resources/renderers/CNPGDeclarativeRenderer.tsx +243 -0
- package/src/components/resources/renderers/CNPGObjectStoreRenderer.test.tsx +99 -0
- package/src/components/resources/renderers/CNPGObjectStoreRenderer.tsx +235 -0
- package/src/components/resources/renderers/CNPGScheduledBackupRenderer.tsx +23 -1
- package/src/components/resources/renderers/CNPGShared.tsx +27 -0
- package/src/components/resources/renderers/CalicoHostEndpointRenderer.tsx +71 -0
- package/src/components/resources/renderers/CalicoIPPoolRenderer.tsx +32 -0
- package/src/components/resources/renderers/CalicoNetworkPolicyDiagram.test.tsx +205 -0
- package/src/components/resources/renderers/CalicoNetworkPolicyDiagram.tsx +537 -0
- package/src/components/resources/renderers/CalicoNetworkPolicyRenderer.test.tsx +223 -0
- package/src/components/resources/renderers/CalicoNetworkPolicyRenderer.tsx +670 -0
- package/src/components/resources/renderers/CalicoTierRenderer.tsx +19 -0
- package/src/components/resources/renderers/KyvernoCELPolicyRenderers.tsx +13 -6
- package/src/components/resources/renderers/KyvernoExceptionRenderers.tsx +3 -2
- package/src/components/resources/renderers/KyvernoGlobalContextRenderer.test.ts +31 -0
- package/src/components/resources/renderers/KyvernoGlobalContextRenderer.tsx +124 -0
- package/src/components/resources/renderers/KyvernoPolicyReportRenderer.tsx +28 -2
- package/src/components/resources/renderers/KyvernoQueueRenderers.tsx +303 -0
- package/src/components/resources/renderers/LookupFailureNote.test.tsx +60 -0
- package/src/components/resources/renderers/LookupFailureNote.tsx +42 -0
- package/src/components/resources/renderers/NetworkPolicyDiagram.tsx +27 -26
- package/src/components/resources/renderers/NetworkPolicyRenderer.tsx +6 -3
- package/src/components/resources/renderers/PolicyCoverageSection.test.tsx +348 -0
- package/src/components/resources/renderers/PolicyCoverageSection.tsx +939 -0
- package/src/components/resources/renderers/PolicySection.test.tsx +59 -2
- package/src/components/resources/renderers/PolicySection.tsx +32 -5
- package/src/components/resources/renderers/RolloutRenderer.test.tsx +491 -0
- package/src/components/resources/renderers/RolloutRenderer.tsx +391 -92
- package/src/components/resources/renderers/VeleroBSLRenderer.test.tsx +374 -0
- package/src/components/resources/renderers/VeleroBSLRenderer.tsx +179 -3
- package/src/components/resources/renderers/VeleroBackupRenderer.test.tsx +221 -0
- package/src/components/resources/renderers/VeleroBackupRenderer.tsx +119 -6
- package/src/components/resources/renderers/VeleroBackupRepositoryRenderer.test.tsx +69 -0
- package/src/components/resources/renderers/VeleroBackupRepositoryRenderer.tsx +96 -0
- package/src/components/resources/renderers/VeleroRestoreRenderer.test.tsx +55 -0
- package/src/components/resources/renderers/VeleroRestoreRenderer.tsx +22 -4
- package/src/components/resources/renderers/VeleroRunMessages.test.tsx +152 -0
- package/src/components/resources/renderers/VeleroRunMessages.tsx +139 -0
- package/src/components/resources/renderers/VeleroScheduleRenderer.test.tsx +88 -0
- package/src/components/resources/renderers/VeleroScheduleRenderer.tsx +16 -6
- package/src/components/resources/renderers/calico-cells.tsx +177 -0
- package/src/components/resources/renderers/cnpg-cells.tsx +100 -0
- package/src/components/resources/renderers/index.ts +16 -1
- package/src/components/resources/renderers/kyverno-cells.tsx +81 -0
- package/src/components/resources/renderers/network-policy-peer-styles.ts +25 -0
- package/src/components/resources/renderers/velero-cells.tsx +29 -7
- package/src/components/resources/renderers/velero-dead-ends.test.tsx +142 -0
- package/src/components/resources/resource-utils-calico.test.ts +215 -0
- package/src/components/resources/resource-utils-calico.ts +261 -0
- package/src/components/resources/resource-utils-cnpg-declarative.test.ts +104 -0
- package/src/components/resources/resource-utils-cnpg-objectstore.test.ts +122 -0
- package/src/components/resources/resource-utils-cnpg.test.ts +54 -0
- package/src/components/resources/resource-utils-cnpg.ts +264 -3
- package/src/components/resources/resource-utils-kyverno-modern.ts +24 -0
- package/src/components/resources/resource-utils-kyverno-queue.test.ts +164 -0
- package/src/components/resources/resource-utils-kyverno-queue.ts +198 -0
- package/src/components/resources/resource-utils-kyverno.ts +43 -7
- package/src/components/resources/resource-utils-velero.test.ts +26 -0
- package/src/components/resources/resource-utils-velero.ts +68 -0
- package/src/components/resources/resource-utils.ts +98 -0
- package/src/components/shared/ResourceActionsBar.tsx +101 -16
- package/src/components/shared/ResourceRendererDispatch.test.tsx +379 -3
- package/src/components/shared/ResourceRendererDispatch.tsx +199 -22
- package/src/components/shared/index.ts +1 -1
- package/src/components/shared/revision-role-badges.test.ts +120 -0
- package/src/components/topology/K8sResourceNode.test.ts +10 -0
- package/src/components/topology/K8sResourceNode.tsx +22 -0
- package/src/components/topology/TopologyFilterSidebar.test.tsx +31 -0
- package/src/components/topology/TopologyFilterSidebar.tsx +5 -0
- package/src/components/topology/TopologyGraph.tsx +6 -6
- package/src/components/topology/TopologySearch.tsx +7 -0
- package/src/components/topology/layout.ts +3 -0
- package/src/components/trace/ReachabilityView.tsx +1 -0
- package/src/components/trace/TracePanel.tsx +12 -2
- package/src/components/trace/reachFixtures.ts +26 -1
- package/src/components/trace/reachGraphModel.test.ts +20 -0
- package/src/components/trace/reachGraphModel.ts +8 -1
- package/src/components/trace/reachOrigins.test.ts +31 -0
- package/src/components/trace/reachOrigins.ts +11 -1
- package/src/components/ui/Badge.tsx +10 -0
- package/src/components/ui/ScheduleValue.test.tsx +80 -0
- package/src/components/ui/ScheduleValue.tsx +85 -0
- package/src/components/ui/drawer-components.test.tsx +17 -1
- package/src/components/ui/drawer-components.tsx +9 -2
- package/src/components/ui/index.ts +2 -0
- package/src/components/workload/WorkloadView.tsx +3 -0
- package/src/types/core.ts +29 -0
- package/src/types/policy.ts +153 -2
- package/src/utils/navigation.test.ts +5 -0
- package/src/utils/navigation.ts +5 -0
- package/src/utils/resource-icons.test.ts +49 -2
- package/src/utils/resource-icons.ts +29 -2
package/src/types/core.ts
CHANGED
|
@@ -202,6 +202,11 @@ export type CoreNodeKind =
|
|
|
202
202
|
| 'KubeadmControlPlane' // Cluster API KubeadmControlPlane
|
|
203
203
|
| 'ClusterClass' // Cluster API ClusterClass
|
|
204
204
|
| 'MachineHealthCheck' // Cluster API MachineHealthCheck
|
|
205
|
+
| 'CalicoNetworkPolicy'
|
|
206
|
+
| 'CalicoGlobalNetworkPolicy'
|
|
207
|
+
| 'CalicoStagedNetworkPolicy'
|
|
208
|
+
| 'CalicoStagedGlobalNetworkPolicy'
|
|
209
|
+
| 'CalicoStagedKubernetesNetworkPolicy'
|
|
205
210
|
|
|
206
211
|
// NodeKind can be a core kind or any arbitrary CRD kind string
|
|
207
212
|
export type NodeKind = CoreNodeKind | (string & {})
|
|
@@ -236,6 +241,11 @@ export function displayKind(kind: string): string {
|
|
|
236
241
|
KubeadmControlPlane: 'Control Plane',
|
|
237
242
|
ClusterClass: 'ClusterClass',
|
|
238
243
|
MachineHealthCheck: 'Health Check',
|
|
244
|
+
CalicoNetworkPolicy: 'Calico NetworkPolicy',
|
|
245
|
+
CalicoGlobalNetworkPolicy: 'Calico GlobalNetworkPolicy',
|
|
246
|
+
CalicoStagedNetworkPolicy: 'Calico StagedNetworkPolicy',
|
|
247
|
+
CalicoStagedGlobalNetworkPolicy: 'Calico StagedGlobalNetworkPolicy',
|
|
248
|
+
CalicoStagedKubernetesNetworkPolicy: 'Calico StagedKubernetesNetworkPolicy',
|
|
239
249
|
}
|
|
240
250
|
return shortNames[kind] || kind
|
|
241
251
|
}
|
|
@@ -258,6 +268,7 @@ export interface TopologyEdge {
|
|
|
258
268
|
target: string
|
|
259
269
|
type: EdgeType
|
|
260
270
|
label?: string
|
|
271
|
+
partial?: boolean
|
|
261
272
|
/** Hover tooltip for the edge label. Used by the Reachability view to keep the
|
|
262
273
|
* DECLARED route path available when the label shows an overridden tested path. */
|
|
263
274
|
labelTitle?: string
|
|
@@ -1204,6 +1215,13 @@ export interface TrafficFlow {
|
|
|
1204
1215
|
bytesSent: number
|
|
1205
1216
|
bytesRecv: number
|
|
1206
1217
|
connections: number
|
|
1218
|
+
/** The conversation's initiator could not be established, so source and
|
|
1219
|
+
* destination are ordered arbitrarily rather than describing a caller. */
|
|
1220
|
+
directionUnknown?: boolean
|
|
1221
|
+
/** 5xx responses per second. How a rate-based source reports failures: it
|
|
1222
|
+
* measures a rate rather than observing individual responses, so it has a
|
|
1223
|
+
* status code for no single flow. */
|
|
1224
|
+
errorRate?: number
|
|
1207
1225
|
verdict: string // forwarded, dropped, error
|
|
1208
1226
|
lastSeen: string // ISO date string
|
|
1209
1227
|
}
|
|
@@ -1236,6 +1254,9 @@ export interface AggregatedFlow {
|
|
|
1236
1254
|
bytesRecv: number
|
|
1237
1255
|
connections: number
|
|
1238
1256
|
lastSeen: string
|
|
1257
|
+
/** The conversation's initiator could not be established, so the endpoints are
|
|
1258
|
+
* ordered arbitrarily and the edge is drawn without an arrowhead. */
|
|
1259
|
+
directionUnknown?: boolean
|
|
1239
1260
|
l7Protocol?: string // HTTP, gRPC, DNS
|
|
1240
1261
|
requestCount?: number
|
|
1241
1262
|
errorCount?: number
|
|
@@ -1307,6 +1328,11 @@ export interface TrafficFlowsResponse {
|
|
|
1307
1328
|
flows: TrafficFlow[]
|
|
1308
1329
|
aggregated: AggregatedFlow[]
|
|
1309
1330
|
warning?: string // Non-fatal warning (e.g., query errors)
|
|
1331
|
+
/** 'transient' (or absent) means the condition may clear on its own and a
|
|
1332
|
+
* retry is worthwhile. 'partial' means the flows are correct but incomplete
|
|
1333
|
+
* for a reason retrying cannot change, so show the warning next to them and
|
|
1334
|
+
* do not refetch. */
|
|
1335
|
+
warningKind?: 'transient' | 'partial'
|
|
1310
1336
|
}
|
|
1311
1337
|
|
|
1312
1338
|
// Wizard state for traffic setup
|
|
@@ -1424,6 +1450,9 @@ export interface WorkloadRevision {
|
|
|
1424
1450
|
isCurrent: boolean
|
|
1425
1451
|
replicas: number
|
|
1426
1452
|
template?: string // Pod template spec as YAML (for revision diff)
|
|
1453
|
+
// Rollouts only: mid-canary isCurrent (rolling out) and isStable (serving traffic) differ.
|
|
1454
|
+
isStable?: boolean
|
|
1455
|
+
podHash?: string
|
|
1427
1456
|
}
|
|
1428
1457
|
|
|
1429
1458
|
// Workload log stream event data
|
package/src/types/policy.ts
CHANGED
|
@@ -26,17 +26,168 @@ export interface PolicyResourceCounts {
|
|
|
26
26
|
skip: number
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/** One resource a policy recorded an outcome for, from
|
|
30
|
+
* GET /api/policy/policies/{policy}. */
|
|
31
|
+
export interface PolicyCoverageSubject {
|
|
32
|
+
group?: string
|
|
33
|
+
kind: string
|
|
34
|
+
namespace?: string
|
|
35
|
+
name: string
|
|
36
|
+
result: PolicyResult
|
|
37
|
+
message?: string
|
|
38
|
+
/** Matched through a rule Kyverno synthesised from an authored Pod rule,
|
|
39
|
+
* not through a rule the user wrote. */
|
|
40
|
+
autogen?: boolean
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface PolicyCoverageRule {
|
|
44
|
+
/** Empty for the modern CEL families, which have no named rules. */
|
|
45
|
+
rule: string
|
|
46
|
+
counts: PolicyResourceCounts
|
|
47
|
+
subjects: PolicyCoverageSubject[]
|
|
48
|
+
total: number
|
|
49
|
+
truncated?: boolean
|
|
50
|
+
/** How many of `total` the namespace view filter held back. `counts` still
|
|
51
|
+
* describe every outcome, so the two must be read together. */
|
|
52
|
+
hiddenByFilter?: number
|
|
53
|
+
/** The non-passing part of `hiddenByFilter`. Only non-passing subjects are
|
|
54
|
+
* listed, so this is what separates a row the server cap dropped from one
|
|
55
|
+
* the view filter held back. */
|
|
56
|
+
hiddenNotable?: number
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** What one policy decided about the cluster — the inverse of
|
|
60
|
+
* PolicyResourceResponse.
|
|
61
|
+
*
|
|
62
|
+
* Carries one partiality the per-resource view never needed: a resource may be
|
|
63
|
+
* missing because the caller cannot read its namespace, so an absent subject is
|
|
64
|
+
* not evidence of absence. `withheldNamespaces` is how the UI says so. */
|
|
65
|
+
export interface PolicyCoverageResponse {
|
|
66
|
+
evaluated: boolean
|
|
67
|
+
status: string
|
|
68
|
+
reasonCode?: string
|
|
69
|
+
deniedGroups?: string[]
|
|
70
|
+
liveUpdates: boolean
|
|
71
|
+
/** The report-side name that matched — namespaced policies report as
|
|
72
|
+
* "namespace/name". */
|
|
73
|
+
policy: string
|
|
74
|
+
counts: PolicyResourceCounts
|
|
75
|
+
scopeNamespaces: number
|
|
76
|
+
withheldNamespaces: number
|
|
77
|
+
clusterScoped?: boolean
|
|
78
|
+
/** Separate from withheldNamespaces — a cluster-scoped subject has no
|
|
79
|
+
* namespace to name. */
|
|
80
|
+
withheldClusterScoped?: boolean
|
|
81
|
+
/** Outcomes dropped because they came only from a report family this caller
|
|
82
|
+
* cannot read. The server drops them before counting, so the note can state
|
|
83
|
+
* how many were left out rather than hedging that some might have been. */
|
|
84
|
+
withheldByFamily?: number
|
|
85
|
+
/** Report families the CALLER cannot read. Distinct from deniedGroups, which
|
|
86
|
+
* are the ones radar's own probe could not read. */
|
|
87
|
+
unreadableFamilies?: string[]
|
|
88
|
+
/** How many distinct resources these outcomes describe, and how many of those
|
|
89
|
+
* have at least one non-passing outcome. One resource matched by two rules
|
|
90
|
+
* produces two outcomes, so any sentence saying "resources" needs these —
|
|
91
|
+
* `counts` and `examined` are checks. Not derivable client-side: the per-rule
|
|
92
|
+
* subject lists are capped. */
|
|
93
|
+
subjects?: number
|
|
94
|
+
subjectsFailing?: number
|
|
95
|
+
/** How many outcomes back these counts. */
|
|
96
|
+
examined: number
|
|
97
|
+
/** How many subjects the namespace view filter held back, across all rules. */
|
|
98
|
+
hiddenByFilter?: number
|
|
99
|
+
engines?: string[]
|
|
100
|
+
rules: PolicyCoverageRule[]
|
|
101
|
+
}
|
|
102
|
+
|
|
29
103
|
export interface PolicyResourceResponse {
|
|
30
104
|
/** False whenever the answer is "we could not check". Never treat an empty
|
|
31
105
|
* findings array as "clean" without consulting this first. */
|
|
32
106
|
evaluated: boolean
|
|
33
107
|
status: string
|
|
34
108
|
reasonCode?: string
|
|
35
|
-
/** Report families
|
|
36
|
-
* the
|
|
109
|
+
/** Report families RADAR's own probe could not read, so nobody's answer
|
|
110
|
+
* carries them — not the same as `withheldByFamily`, which is what THIS
|
|
111
|
+
* caller may not see. Present even when evaluated: the answer is real but
|
|
112
|
+
* incomplete. */
|
|
37
113
|
deniedGroups?: string[]
|
|
38
114
|
/** False when the index is frozen at its initial contents. */
|
|
39
115
|
liveUpdates: boolean
|
|
40
116
|
counts: PolicyResourceCounts
|
|
41
117
|
findings: PolicyResourceFinding[]
|
|
118
|
+
/** Findings dropped because they came only from a report family this caller
|
|
119
|
+
* cannot read. `counts` excludes them too, so an all-passing count with this
|
|
120
|
+
* set is not an all-clear — it is the part of the answer they may see. */
|
|
121
|
+
withheldByFamily?: number
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Background work Kyverno currently has in flight for one policy, from
|
|
125
|
+
* GET /api/policy/policies/{policy}/queued. Computed server-side: the requests
|
|
126
|
+
* live in the engine's namespace, not the policy's. */
|
|
127
|
+
export interface PolicyQueuedResponse {
|
|
128
|
+
/** Zero is a real answer — Kyverno deletes these seconds after they complete. */
|
|
129
|
+
requests: number
|
|
130
|
+
byState?: Record<string, number>
|
|
131
|
+
/** Separates healthy churn from a stopped controller. */
|
|
132
|
+
oldestPending?: string
|
|
133
|
+
/** The only diagnosis these objects carry. */
|
|
134
|
+
messages?: string[]
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** One Cluster pinned to a CloudNativePG image catalog. */
|
|
138
|
+
export interface CNPGCatalogUser {
|
|
139
|
+
namespace: string
|
|
140
|
+
name: string
|
|
141
|
+
/** Absent when the reference carries no major — the screen must not render
|
|
142
|
+
* "asks for PostgreSQL 0". */
|
|
143
|
+
major?: number
|
|
144
|
+
/** A catalog-pinned Cluster has no spec.imageName, so this is the only place
|
|
145
|
+
* the image it actually resolved appears. */
|
|
146
|
+
image?: string
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Clusters referencing one image catalog, from the CNPG catalog-users endpoint. */
|
|
150
|
+
export interface CNPGCatalogUsersResponse {
|
|
151
|
+
clusters: CNPGCatalogUser[]
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** What one Velero BackupStorageLocation holds, from the stored-backups lookup. */
|
|
155
|
+
export interface VeleroStoredBackupsResponse {
|
|
156
|
+
backups: Array<{
|
|
157
|
+
namespace: string
|
|
158
|
+
name: string
|
|
159
|
+
phase?: string
|
|
160
|
+
expiration?: string
|
|
161
|
+
completed?: string
|
|
162
|
+
}>
|
|
163
|
+
/** How many reached Completed and are still inside their retention — the rest
|
|
164
|
+
* are stored here but are not something to restore from. Counted over the
|
|
165
|
+
* whole location, like `stored`: recomputing it from the capped list above
|
|
166
|
+
* undercounts every location big enough to be capped. */
|
|
167
|
+
restorable: number
|
|
168
|
+
/** How many reached Completed but have aged out. Same scope as `restorable`. */
|
|
169
|
+
expired?: number
|
|
170
|
+
/** How many the location holds in total, counted before the list was capped. */
|
|
171
|
+
stored?: number
|
|
172
|
+
/** The list above is a page, not the whole location. */
|
|
173
|
+
truncated?: boolean
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** One warning or error behind a Velero run's counts, with the scope Velero
|
|
177
|
+
* filed it under: "velero", "cluster", or a namespace name. */
|
|
178
|
+
export interface VeleroMessage {
|
|
179
|
+
scope: string
|
|
180
|
+
message: string
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** What a Backup or Restore actually reported, fetched on demand.
|
|
184
|
+
*
|
|
185
|
+
* The counts live on the CR; these messages do not — they are in a results
|
|
186
|
+
* file in object storage that only Velero's controller can hand out a link to.
|
|
187
|
+
* So this is never present until someone asks for it. */
|
|
188
|
+
export interface VeleroRunMessagesResponse {
|
|
189
|
+
warnings: VeleroMessage[]
|
|
190
|
+
errors: VeleroMessage[]
|
|
191
|
+
/** Set when the results file held more than were returned. */
|
|
192
|
+
truncated?: boolean
|
|
42
193
|
}
|
|
@@ -24,6 +24,11 @@ describe('kindToPlural', () => {
|
|
|
24
24
|
|
|
25
25
|
test('handles kinds ending in consonant+y (changes to -ies)', () => {
|
|
26
26
|
expect(kindToPlural('NetworkPolicy')).toBe('networkpolicies')
|
|
27
|
+
expect(kindToPlural('CalicoNetworkPolicy')).toBe('networkpolicies')
|
|
28
|
+
expect(kindToPlural('CalicoGlobalNetworkPolicy')).toBe('globalnetworkpolicies')
|
|
29
|
+
expect(kindToPlural('CalicoStagedNetworkPolicy')).toBe('stagednetworkpolicies')
|
|
30
|
+
expect(kindToPlural('CalicoStagedGlobalNetworkPolicy')).toBe('stagedglobalnetworkpolicies')
|
|
31
|
+
expect(kindToPlural('CalicoStagedKubernetesNetworkPolicy')).toBe('stagedkubernetesnetworkpolicies')
|
|
27
32
|
})
|
|
28
33
|
|
|
29
34
|
test('handles already-plural kind names (Endpoints)', () => {
|
package/src/utils/navigation.ts
CHANGED
|
@@ -100,6 +100,11 @@ export function kindToPlural(kind: string): string {
|
|
|
100
100
|
horizontalpodautoscaler: 'horizontalpodautoscalers',
|
|
101
101
|
pvc: 'persistentvolumeclaims',
|
|
102
102
|
podgroup: 'pods',
|
|
103
|
+
caliconetworkpolicy: 'networkpolicies',
|
|
104
|
+
calicoglobalnetworkpolicy: 'globalnetworkpolicies',
|
|
105
|
+
calicostagednetworkpolicy: 'stagednetworkpolicies',
|
|
106
|
+
calicostagedglobalnetworkpolicy: 'stagedglobalnetworkpolicies',
|
|
107
|
+
calicostagedkubernetesnetworkpolicy: 'stagedkubernetesnetworkpolicies',
|
|
103
108
|
}
|
|
104
109
|
if (aliases[kindLower]) return aliases[kindLower]
|
|
105
110
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest'
|
|
2
|
-
import { Database, Server, Puzzle } from 'lucide-react'
|
|
3
|
-
import { getResourceIcon, DEFAULT_RESOURCE_ICON } from './resource-icons'
|
|
2
|
+
import { Database, Network, Server, ShieldCheck, Puzzle } from 'lucide-react'
|
|
3
|
+
import { getResourceIcon, getTopologyIcon, DEFAULT_RESOURCE_ICON } from './resource-icons'
|
|
4
4
|
|
|
5
5
|
describe('getResourceIcon', () => {
|
|
6
6
|
it('disambiguates colliding kinds by API group', () => {
|
|
@@ -14,6 +14,53 @@ describe('getResourceIcon', () => {
|
|
|
14
14
|
// A third operator's `clusters` CRD must not inherit a Postgres icon.
|
|
15
15
|
expect(getResourceIcon('Cluster', 'apps.kubeblocks.io')).toBe(DEFAULT_RESOURCE_ICON)
|
|
16
16
|
expect(getResourceIcon('Backup', 'kubevirt.io')).toBe(DEFAULT_RESOURCE_ICON)
|
|
17
|
+
expect(getResourceIcon('HostEndpoint', 'networking.example.io')).toBe(DEFAULT_RESOURCE_ICON)
|
|
18
|
+
expect(getResourceIcon('IPPool', 'networking.example.io')).toBe(DEFAULT_RESOURCE_ICON)
|
|
19
|
+
expect(getResourceIcon('IPPool', 'extension.projectcalico.org')).toBe(DEFAULT_RESOURCE_ICON)
|
|
20
|
+
expect(getResourceIcon('Tier', 'extension.projectcalico.org')).toBe(DEFAULT_RESOURCE_ICON)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('resolves Calico IPPool only for Calico API groups', () => {
|
|
24
|
+
expect(getResourceIcon('IPPool', 'crd.projectcalico.org')).toBe(Network)
|
|
25
|
+
expect(getResourceIcon('IPPool', 'projectcalico.org')).toBe(Network)
|
|
26
|
+
expect(getResourceIcon('IPPool')).toBe(DEFAULT_RESOURCE_ICON)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('resolves Calico HostEndpoint only for Calico API groups', () => {
|
|
30
|
+
expect(getResourceIcon('HostEndpoint', 'crd.projectcalico.org')).toBe(Network)
|
|
31
|
+
expect(getResourceIcon('HostEndpoint', 'projectcalico.org')).toBe(Network)
|
|
32
|
+
expect(getResourceIcon('HostEndpoint')).toBe(DEFAULT_RESOURCE_ICON)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('resolves Calico Tier only for Calico API groups', () => {
|
|
36
|
+
expect(getResourceIcon('Tier', 'crd.projectcalico.org')).toBe(Network)
|
|
37
|
+
expect(getResourceIcon('Tier', 'projectcalico.org')).toBe(Network)
|
|
38
|
+
expect(getResourceIcon('Tier')).toBe(DEFAULT_RESOURCE_ICON)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('disambiguates NetworkPolicy and Calico policy kinds by API group', () => {
|
|
42
|
+
expect(getResourceIcon('NetworkPolicy', 'networking.k8s.io')).toBe(ShieldCheck)
|
|
43
|
+
expect(getResourceIcon('NetworkPolicy', 'projectcalico.org')).toBe(ShieldCheck)
|
|
44
|
+
expect(getResourceIcon('NetworkPolicy', 'crd.projectcalico.org')).toBe(ShieldCheck)
|
|
45
|
+
expect(getResourceIcon('NetworkPolicy', 'networking.example.io')).toBe(DEFAULT_RESOURCE_ICON)
|
|
46
|
+
expect(getResourceIcon('GlobalNetworkPolicy', 'projectcalico.org')).toBe(ShieldCheck)
|
|
47
|
+
expect(getResourceIcon('StagedNetworkPolicy', 'crd.projectcalico.org')).toBe(ShieldCheck)
|
|
48
|
+
expect(getResourceIcon('StagedGlobalNetworkPolicy', 'projectcalico.org')).toBe(ShieldCheck)
|
|
49
|
+
expect(getResourceIcon('StagedKubernetesNetworkPolicy', 'crd.projectcalico.org')).toBe(ShieldCheck)
|
|
50
|
+
expect(getResourceIcon('GlobalNetworkPolicy', 'networking.example.io')).toBe(DEFAULT_RESOURCE_ICON)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
it('uses ShieldCheck for all Calico policy topology nodes', () => {
|
|
54
|
+
for (const kind of [
|
|
55
|
+
'CalicoNetworkPolicy',
|
|
56
|
+
'CalicoGlobalNetworkPolicy',
|
|
57
|
+
'CalicoStagedNetworkPolicy',
|
|
58
|
+
'CalicoStagedGlobalNetworkPolicy',
|
|
59
|
+
'CalicoStagedKubernetesNetworkPolicy',
|
|
60
|
+
]) {
|
|
61
|
+
expect(getTopologyIcon(kind)).toBe(ShieldCheck)
|
|
62
|
+
expect(getResourceIcon(kind)).toBe(ShieldCheck)
|
|
63
|
+
}
|
|
17
64
|
})
|
|
18
65
|
|
|
19
66
|
it('ignores the group for kinds that do not collide', () => {
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
ShieldAlert,
|
|
21
21
|
Radio,
|
|
22
22
|
Globe,
|
|
23
|
+
Network,
|
|
23
24
|
|
|
24
25
|
// Config
|
|
25
26
|
FileSliders,
|
|
@@ -96,6 +97,11 @@ const KIND_ICON_MAP: Record<string, LucideIcon> = {
|
|
|
96
97
|
service: Plug,
|
|
97
98
|
ingress: DoorOpen,
|
|
98
99
|
networkpolicy: ShieldCheck,
|
|
100
|
+
caliconetworkpolicy: ShieldCheck,
|
|
101
|
+
calicoglobalnetworkpolicy: ShieldCheck,
|
|
102
|
+
calicostagednetworkpolicy: ShieldCheck,
|
|
103
|
+
calicostagedglobalnetworkpolicy: ShieldCheck,
|
|
104
|
+
calicostagedkubernetesnetworkpolicy: ShieldCheck,
|
|
99
105
|
ciliumnetworkpolicy: ShieldCheck,
|
|
100
106
|
ciliumclusterwidenetworkpolicy: ShieldCheck,
|
|
101
107
|
clusternetworkpolicy: ShieldCheck,
|
|
@@ -291,13 +297,33 @@ const GROUP_QUALIFIED_KIND_ICONS: Record<string, Record<string, LucideIcon>> = {
|
|
|
291
297
|
backup: { 'postgresql.cnpg.io': DatabaseBackup },
|
|
292
298
|
scheduledbackup: { 'postgresql.cnpg.io': DatabaseBackup },
|
|
293
299
|
pooler: { 'postgresql.cnpg.io': Waypoints },
|
|
300
|
+
networkpolicy: {
|
|
301
|
+
'networking.k8s.io': ShieldCheck,
|
|
302
|
+
'crd.projectcalico.org': ShieldCheck,
|
|
303
|
+
'projectcalico.org': ShieldCheck,
|
|
304
|
+
},
|
|
305
|
+
hostendpoint: { 'crd.projectcalico.org': Network, 'projectcalico.org': Network },
|
|
306
|
+
ippool: { 'crd.projectcalico.org': Network, 'projectcalico.org': Network },
|
|
307
|
+
tier: { 'crd.projectcalico.org': Network, 'projectcalico.org': Network },
|
|
308
|
+
globalnetworkpolicy: { 'crd.projectcalico.org': ShieldCheck, 'projectcalico.org': ShieldCheck },
|
|
309
|
+
stagednetworkpolicy: { 'crd.projectcalico.org': ShieldCheck, 'projectcalico.org': ShieldCheck },
|
|
310
|
+
stagedglobalnetworkpolicy: { 'crd.projectcalico.org': ShieldCheck, 'projectcalico.org': ShieldCheck },
|
|
311
|
+
stagedkubernetesnetworkpolicy: { 'crd.projectcalico.org': ShieldCheck, 'projectcalico.org': ShieldCheck },
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
const TOPOLOGY_KIND_ICONS: Record<string, LucideIcon> = {
|
|
315
|
+
CalicoNetworkPolicy: ShieldCheck,
|
|
316
|
+
CalicoGlobalNetworkPolicy: ShieldCheck,
|
|
317
|
+
CalicoStagedNetworkPolicy: ShieldCheck,
|
|
318
|
+
CalicoStagedGlobalNetworkPolicy: ShieldCheck,
|
|
319
|
+
CalicoStagedKubernetesNetworkPolicy: ShieldCheck,
|
|
294
320
|
}
|
|
295
321
|
|
|
296
322
|
export function getResourceIcon(kind: string, group?: string): LucideIcon {
|
|
297
323
|
const k = kind.toLowerCase()
|
|
298
324
|
if (group) {
|
|
299
|
-
const
|
|
300
|
-
if (
|
|
325
|
+
const groupMap = GROUP_QUALIFIED_KIND_ICONS[k]
|
|
326
|
+
if (groupMap) return groupMap[group] ?? DEFAULT_RESOURCE_ICON
|
|
301
327
|
}
|
|
302
328
|
return KIND_ICON_MAP[k] ?? Puzzle
|
|
303
329
|
}
|
|
@@ -306,6 +332,7 @@ export function getResourceIcon(kind: string, group?: string): LucideIcon {
|
|
|
306
332
|
export function getTopologyIcon(kind: string): LucideIcon {
|
|
307
333
|
if (kind === 'Internet') return Globe
|
|
308
334
|
if (kind === 'PodGroup') return Boxes
|
|
335
|
+
if (TOPOLOGY_KIND_ICONS[kind]) return TOPOLOGY_KIND_ICONS[kind]
|
|
309
336
|
return getResourceIcon(kind)
|
|
310
337
|
}
|
|
311
338
|
|