@stolostron/multicluster-sdk 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -16
- package/lib/api/FleetResourceLink.js +1 -1
- package/lib/api/FleetResourceLink.js.map +1 -1
- package/lib/api/use-fleet-k8s-watch-resource/index.d.ts +2 -0
- package/lib/api/use-fleet-k8s-watch-resource/index.d.ts.map +1 -0
- package/lib/api/use-fleet-k8s-watch-resource/index.js +8 -0
- package/lib/api/use-fleet-k8s-watch-resource/index.js.map +1 -0
- package/lib/api/useFleetK8sWatchResource.d.ts +32 -0
- package/lib/api/useFleetK8sWatchResource.d.ts.map +1 -1
- package/lib/api/useFleetK8sWatchResource.js +176 -3
- package/lib/api/useFleetK8sWatchResource.js.map +1 -1
- package/lib/components/FleetResourceEventStream/FleetResourceEventStream.d.ts +77 -0
- package/lib/components/FleetResourceEventStream/FleetResourceEventStream.d.ts.map +1 -0
- package/lib/components/FleetResourceEventStream/FleetResourceEventStream.js +255 -0
- package/lib/components/FleetResourceEventStream/FleetResourceEventStream.js.map +1 -0
- package/lib/components/FleetResourceEventStream.d.ts +77 -0
- package/lib/components/FleetResourceEventStream.d.ts.map +1 -0
- package/lib/components/FleetResourceEventStream.js +266 -0
- package/lib/components/FleetResourceEventStream.js.map +1 -0
- package/lib/components/FleetResourceLink.d.ts +53 -0
- package/lib/components/FleetResourceLink.d.ts.map +1 -0
- package/lib/components/FleetResourceLink.js +197 -0
- package/lib/components/FleetResourceLink.js.map +1 -0
- package/lib/extensions/index.d.ts +1 -1
- package/lib/extensions/index.d.ts.map +1 -1
- package/lib/extensions/index.js +1 -1
- package/lib/extensions/index.js.map +1 -1
- package/lib/extensions/resource.d.ts +21 -7
- package/lib/extensions/resource.d.ts.map +1 -1
- package/lib/extensions/resource.js +10 -5
- package/lib/extensions/resource.js.map +1 -1
- package/lib/extensions/resourceRouteExtension.d.ts +25 -0
- package/lib/extensions/resourceRouteExtension.d.ts.map +1 -0
- package/lib/extensions/resourceRouteExtension.js +7 -0
- package/lib/extensions/resourceRouteExtension.js.map +1 -0
- package/lib/internal/FleetResourceEventStream/EventComponent.d.ts +5 -0
- package/lib/internal/FleetResourceEventStream/EventComponent.d.ts.map +1 -0
- package/lib/internal/FleetResourceEventStream/EventComponent.js +52 -0
- package/lib/internal/FleetResourceEventStream/EventComponent.js.map +1 -0
- package/lib/internal/FleetResourceEventStream/EventStreamList.d.ts +17 -0
- package/lib/internal/FleetResourceEventStream/EventStreamList.d.ts.map +1 -0
- package/lib/internal/FleetResourceEventStream/EventStreamList.js +92 -0
- package/lib/internal/FleetResourceEventStream/EventStreamList.js.map +1 -0
- package/lib/internal/FleetResourceEventStream/TogglePlay.d.ts +8 -0
- package/lib/internal/FleetResourceEventStream/TogglePlay.d.ts.map +1 -0
- package/lib/internal/FleetResourceEventStream/TogglePlay.js +17 -0
- package/lib/internal/FleetResourceEventStream/TogglePlay.js.map +1 -0
- package/lib/internal/FleetResourceEventStream/WithScrollContainer.d.ts +7 -0
- package/lib/internal/FleetResourceEventStream/WithScrollContainer.d.ts.map +1 -0
- package/lib/internal/FleetResourceEventStream/WithScrollContainer.js +51 -0
- package/lib/internal/FleetResourceEventStream/WithScrollContainer.js.map +1 -0
- package/lib/internal/FleetResourceEventStream/constants.d.ts +30 -0
- package/lib/internal/FleetResourceEventStream/constants.d.ts.map +1 -0
- package/lib/internal/FleetResourceEventStream/constants.js +6 -0
- package/lib/internal/FleetResourceEventStream/constants.js.map +1 -0
- package/lib/internal/FleetResourceEventStream/utils.d.ts +16 -0
- package/lib/internal/FleetResourceEventStream/utils.d.ts.map +1 -0
- package/lib/internal/FleetResourceEventStream/utils.js +143 -0
- package/lib/internal/FleetResourceEventStream/utils.js.map +1 -0
- package/lib/internal/fleetK8sWatchResource.d.ts +29 -0
- package/lib/internal/fleetK8sWatchResource.d.ts.map +1 -0
- package/lib/internal/fleetK8sWatchResource.js +89 -0
- package/lib/internal/fleetK8sWatchResource.js.map +1 -0
- package/lib/internal/fleetResourceHelpers.d.ts +82 -0
- package/lib/internal/fleetResourceHelpers.d.ts.map +1 -0
- package/lib/internal/fleetResourceHelpers.js +101 -0
- package/lib/internal/fleetResourceHelpers.js.map +1 -0
- package/lib/internal/types/multicluster-sdk.d.ts.map +1 -1
- package/lib/setupTests.d.ts +3 -0
- package/lib/setupTests.d.ts.map +1 -0
- package/lib/setupTests.js +106 -0
- package/lib/setupTests.js.map +1 -0
- package/lib/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/lib/api/fleetK8sCreate.d.ts +0 -4
- package/lib/api/fleetK8sCreate.d.ts.map +0 -1
- package/lib/api/fleetK8sCreate.js +0 -49
- package/lib/api/fleetK8sCreate.js.map +0 -1
- package/lib/api/fleetK8sDelete.d.ts +0 -3
- package/lib/api/fleetK8sDelete.d.ts.map +0 -1
- package/lib/api/fleetK8sDelete.js +0 -39
- package/lib/api/fleetK8sDelete.js.map +0 -1
- package/lib/api/fleetK8sGet.d.ts +0 -3
- package/lib/api/fleetK8sGet.d.ts.map +0 -1
- package/lib/api/fleetK8sGet.js +0 -27
- package/lib/api/fleetK8sGet.js.map +0 -1
- package/lib/api/fleetK8sPatch.d.ts +0 -3
- package/lib/api/fleetK8sPatch.d.ts.map +0 -1
- package/lib/api/fleetK8sPatch.js +0 -42
- package/lib/api/fleetK8sPatch.js.map +0 -1
- package/lib/api/fleetK8sUpdate.d.ts +0 -3
- package/lib/api/fleetK8sUpdate.d.ts.map +0 -1
- package/lib/api/fleetK8sUpdate.js +0 -35
- package/lib/api/fleetK8sUpdate.js.map +0 -1
- package/lib/internal/apiRequests.d.ts +0 -77
- package/lib/internal/apiRequests.d.ts.map +0 -1
- package/lib/internal/apiRequests.js +0 -114
- package/lib/internal/apiRequests.js.map +0 -1
package/README.md
CHANGED
|
@@ -53,7 +53,6 @@ Setup depends on your usage scenarios.
|
|
|
53
53
|
- [useFleetPrometheusPoll](#gear-usefleetprometheuspoll)
|
|
54
54
|
- [useHubClusterName](#gear-usehubclustername)
|
|
55
55
|
- [useIsFleetAvailable](#gear-useisfleetavailable)
|
|
56
|
-
- [useMulticlusterSearchWatch](#gear-usemulticlustersearchwatch)
|
|
57
56
|
|
|
58
57
|
### :gear: fleetK8sCreate
|
|
59
58
|
|
|
@@ -109,7 +108,7 @@ Setup depends on your usage scenarios.
|
|
|
109
108
|
| ---------- | ---------- |
|
|
110
109
|
| `getFleetK8sAPIPath` | `(cluster?: string or undefined) => Promise<string>` |
|
|
111
110
|
|
|
112
|
-
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/api/useFleetK8sAPIPath.ts#
|
|
111
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/api/useFleetK8sAPIPath.ts#L21)
|
|
113
112
|
|
|
114
113
|
### :gear: useFleetAccessReview
|
|
115
114
|
|
|
@@ -135,7 +134,7 @@ Returns:
|
|
|
135
134
|
|
|
136
135
|
Array with `isAllowed` and `loading` values.
|
|
137
136
|
|
|
138
|
-
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/api/useFleetAccessReview
|
|
137
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/api/useFleetAccessReview.ts#L20)
|
|
139
138
|
|
|
140
139
|
### :gear: useFleetClusterNames
|
|
141
140
|
|
|
@@ -151,15 +150,54 @@ Array with `isAllowed` and `loading` values.
|
|
|
151
150
|
| ---------- | ---------- |
|
|
152
151
|
| `useFleetK8sAPIPath` | `UseFleetK8sAPIPath` |
|
|
153
152
|
|
|
154
|
-
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/api/useFleetK8sAPIPath.ts#
|
|
153
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/api/useFleetK8sAPIPath.ts#L9)
|
|
155
154
|
|
|
156
155
|
### :gear: useFleetK8sWatchResource
|
|
157
156
|
|
|
157
|
+
A hook for watching Kubernetes resources with support for multi-cluster environments.
|
|
158
|
+
It is equivalent to the [`useK8sWatchResource`](https://github.com/openshift/console/blob/main/frontend/packages/console-dynamic-plugin-sdk/docs/api.md#usek8swatchresource)
|
|
159
|
+
hook from the [OpenShift Console Dynamic Plugin SDK](https://www.npmjs.com/package/@openshift-console/dynamic-plugin-sdk)
|
|
160
|
+
but allows you to retrieve data from any cluster managed by Red Hat Advanced Cluster Management.
|
|
161
|
+
|
|
162
|
+
It automatically detects the hub cluster and handles resource watching on both hub
|
|
163
|
+
and remote clusters using WebSocket connections for real-time updates.
|
|
164
|
+
|
|
158
165
|
| Function | Type |
|
|
159
166
|
| ---------- | ---------- |
|
|
160
167
|
| `useFleetK8sWatchResource` | `UseFleetK8sWatchResource` |
|
|
161
168
|
|
|
162
|
-
|
|
169
|
+
Parameters:
|
|
170
|
+
|
|
171
|
+
* `initResource`: - The resource to watch. Can be null to disable the watch.
|
|
172
|
+
* `initResource.cluster`: - The managed cluster on which the resource resides; null for the hub cluster
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
Returns:
|
|
176
|
+
|
|
177
|
+
A tuple containing the watched resource data, a boolean indicating if the data is loaded,
|
|
178
|
+
and any error that occurred. The hook returns live-updating data.
|
|
179
|
+
|
|
180
|
+
Examples:
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
// Watch pods on a remote cluster
|
|
184
|
+
const [pods, loaded, error] = useFleetK8sWatchResource({
|
|
185
|
+
groupVersionKind: { version: 'v1', kind: 'Pod' },
|
|
186
|
+
isList: true,
|
|
187
|
+
cluster: 'remote-cluster',
|
|
188
|
+
namespace: 'default'
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
// Watch a specific deployment on hub cluster
|
|
192
|
+
const [deployment, loaded, error] = useFleetK8sWatchResource({
|
|
193
|
+
groupVersionKind: { group: 'apps', version: 'v1', kind: 'Deployment' },
|
|
194
|
+
name: 'my-app',
|
|
195
|
+
namespace: 'default'
|
|
196
|
+
})
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/api/useFleetK8sWatchResource.ts#L48)
|
|
163
201
|
|
|
164
202
|
### :gear: useFleetPrometheusPoll
|
|
165
203
|
|
|
@@ -169,6 +207,14 @@ Array with `isAllowed` and `loading` values.
|
|
|
169
207
|
|
|
170
208
|
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/api/useFleetPrometheusPoll/index.ts#L13)
|
|
171
209
|
|
|
210
|
+
### :gear: useFleetSearchPoll
|
|
211
|
+
|
|
212
|
+
| Function | Type |
|
|
213
|
+
| ---------- | ---------- |
|
|
214
|
+
| `useFleetSearchPoll` | `UseFleetSearchPoll` |
|
|
215
|
+
|
|
216
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/api/search/useFleetSearchPoll.ts#L7)
|
|
217
|
+
|
|
172
218
|
### :gear: useHubClusterName
|
|
173
219
|
|
|
174
220
|
Hook that provides hub cluster name.
|
|
@@ -181,7 +227,7 @@ Returns:
|
|
|
181
227
|
|
|
182
228
|
Array with `hubclustername`, `loaded` and `error` values.
|
|
183
229
|
|
|
184
|
-
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/api/useHubClusterName.ts#
|
|
230
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/api/useHubClusterName.ts#L12)
|
|
185
231
|
|
|
186
232
|
### :gear: useIsFleetAvailable
|
|
187
233
|
|
|
@@ -201,25 +247,33 @@ Returns:
|
|
|
201
247
|
|
|
202
248
|
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/api/useIsFleetAvailable.ts#L15)
|
|
203
249
|
|
|
204
|
-
### :gear: useMulticlusterSearchWatch
|
|
205
250
|
|
|
206
|
-
|
|
251
|
+
## :wrench: Constants
|
|
252
|
+
|
|
253
|
+
- [REQUIRED_PROVIDER_FLAG](#gear-required_provider_flag)
|
|
254
|
+
|
|
255
|
+
### :gear: REQUIRED_PROVIDER_FLAG
|
|
256
|
+
|
|
257
|
+
| Constant | Type |
|
|
207
258
|
| ---------- | ---------- |
|
|
208
|
-
| `
|
|
259
|
+
| `REQUIRED_PROVIDER_FLAG` | `"MULTICLUSTER_SDK_PROVIDER_1"` |
|
|
209
260
|
|
|
210
|
-
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/api/
|
|
261
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/api/constants.ts#L2)
|
|
211
262
|
|
|
212
263
|
|
|
213
264
|
|
|
214
265
|
## :cocktail: Types
|
|
215
266
|
|
|
216
267
|
- [Fleet](#gear-fleet)
|
|
268
|
+
- [FleetAccessReviewResourceAttributes](#gear-fleetaccessreviewresourceattributes)
|
|
217
269
|
- [FleetK8sResourceCommon](#gear-fleetk8sresourcecommon)
|
|
218
270
|
- [FleetResourceLinkProps](#gear-fleetresourcelinkprops)
|
|
271
|
+
- [FleetWatchK8sResource](#gear-fleetwatchk8sresource)
|
|
219
272
|
- [UseFleetClusterNames](#gear-usefleetclusternames)
|
|
220
273
|
- [UseFleetK8sAPIPath](#gear-usefleetk8sapipath)
|
|
221
274
|
- [UseFleetK8sWatchResource](#gear-usefleetk8swatchresource)
|
|
222
275
|
- [UseHubClusterName](#gear-usehubclustername)
|
|
276
|
+
- [UseIsFleetAvailable](#gear-useisfleetavailable)
|
|
223
277
|
|
|
224
278
|
### :gear: Fleet
|
|
225
279
|
|
|
@@ -227,7 +281,15 @@ Returns:
|
|
|
227
281
|
| ---------- | ---------- |
|
|
228
282
|
| `Fleet` | `T and { cluster?: string }` |
|
|
229
283
|
|
|
230
|
-
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/fleet.ts#
|
|
284
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/fleet.ts#L10)
|
|
285
|
+
|
|
286
|
+
### :gear: FleetAccessReviewResourceAttributes
|
|
287
|
+
|
|
288
|
+
| Type | Type |
|
|
289
|
+
| ---------- | ---------- |
|
|
290
|
+
| `FleetAccessReviewResourceAttributes` | `Fleet<AccessReviewResourceAttributes>` |
|
|
291
|
+
|
|
292
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/fleet.ts#L14)
|
|
231
293
|
|
|
232
294
|
### :gear: FleetK8sResourceCommon
|
|
233
295
|
|
|
@@ -235,7 +297,7 @@ Returns:
|
|
|
235
297
|
| ---------- | ---------- |
|
|
236
298
|
| `FleetK8sResourceCommon` | `Fleet<K8sResourceCommon>` |
|
|
237
299
|
|
|
238
|
-
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/fleet.ts#
|
|
300
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/fleet.ts#L13)
|
|
239
301
|
|
|
240
302
|
### :gear: FleetResourceLinkProps
|
|
241
303
|
|
|
@@ -243,7 +305,15 @@ Returns:
|
|
|
243
305
|
| ---------- | ---------- |
|
|
244
306
|
| `FleetResourceLinkProps` | `Fleet<ResourceLinkProps>` |
|
|
245
307
|
|
|
246
|
-
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/fleet.ts#
|
|
308
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/fleet.ts#L20)
|
|
309
|
+
|
|
310
|
+
### :gear: FleetWatchK8sResource
|
|
311
|
+
|
|
312
|
+
| Type | Type |
|
|
313
|
+
| ---------- | ---------- |
|
|
314
|
+
| `FleetWatchK8sResource` | `Fleet<WatchK8sResource>` |
|
|
315
|
+
|
|
316
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/fleet.ts#L12)
|
|
247
317
|
|
|
248
318
|
### :gear: UseFleetClusterNames
|
|
249
319
|
|
|
@@ -251,7 +321,7 @@ Returns:
|
|
|
251
321
|
| ---------- | ---------- |
|
|
252
322
|
| `UseFleetClusterNames` | `() => [string[], boolean, any]` |
|
|
253
323
|
|
|
254
|
-
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/fleet.ts#
|
|
324
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/fleet.ts#L24)
|
|
255
325
|
|
|
256
326
|
### :gear: UseFleetK8sAPIPath
|
|
257
327
|
|
|
@@ -259,7 +329,7 @@ Returns:
|
|
|
259
329
|
| ---------- | ---------- |
|
|
260
330
|
| `UseFleetK8sAPIPath` | `( cluster?: string ) => [k8sAPIPath: string or undefined, loaded: boolean, error: Error or undefined]` |
|
|
261
331
|
|
|
262
|
-
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/fleet.ts#
|
|
332
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/fleet.ts#L17)
|
|
263
333
|
|
|
264
334
|
### :gear: UseFleetK8sWatchResource
|
|
265
335
|
|
|
@@ -267,7 +337,7 @@ Returns:
|
|
|
267
337
|
| ---------- | ---------- |
|
|
268
338
|
| `UseFleetK8sWatchResource` | `<R extends FleetK8sResourceCommon or FleetK8sResourceCommon[]>( initResource: FleetWatchK8sResource or null ) => WatchK8sResult<R> or [undefined, boolean, any]` |
|
|
269
339
|
|
|
270
|
-
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/fleet.ts#
|
|
340
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/fleet.ts#L21)
|
|
271
341
|
|
|
272
342
|
### :gear: UseHubClusterName
|
|
273
343
|
|
|
@@ -30,7 +30,7 @@ const FleetResourceLink = (_a) => {
|
|
|
30
30
|
'co-resource-item--truncate': truncate,
|
|
31
31
|
});
|
|
32
32
|
const path = (groupVersionKind === null || groupVersionKind === void 0 ? void 0 : groupVersionKind.kind) === 'VirtualMachine' && namespace
|
|
33
|
-
? `/
|
|
33
|
+
? `/k8s/cluster/${cluster}/ns/${namespace}/kubevirt.io~v1~VirtualMachine/${name}`
|
|
34
34
|
: `/multicloud/search/resources${(0, searchPaths_1.getURLSearchParam)({
|
|
35
35
|
cluster,
|
|
36
36
|
kind: groupVersionKind === null || groupVersionKind === void 0 ? void 0 : groupVersionKind.kind,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FleetResourceLink.js","sourceRoot":"","sources":["../../src/api/FleetResourceLink.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAEA,8EAAkF;AAElF,4DAAmC;AACnC,2EAAiD;AACjD,qDAAuD;AAEhD,MAAM,iBAAiB,GAAqC,CAAC,EAAiC,EAAE,EAAE;QAArC,EAAE,OAAO,OAAwB,EAAnB,iBAAiB,cAA/B,WAAiC,CAAF;IACjG,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,EACJ,SAAS,EACT,WAAW,EACX,MAAM,GAAG,KAAK,EACd,gBAAgB,EAChB,IAAI,EACJ,UAAU,EACV,SAAS,EACT,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,QAAQ,GACT,GAAG,iBAAiB,CAAA;QAErB,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAA;QAC9C,MAAM,OAAO,GAAG,IAAA,oBAAU,EAAC,kBAAkB,EAAE,SAAS,IAAI,EAAE,EAAE;YAC9D,0BAA0B,EAAE,MAAM;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I;gBAC5B,QAAQ,EAAE,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,KAAK;gBACjC,UAAU,EAAE,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,OAAO;gBACrC,IAAI;gBACJ,SAAS;aACV,CAAC,EAAE,CAAA;QAEV,OAAO,CACL,kCAAM,SAAS,EAAE,OAAO,aACrB,CAAC,QAAQ,IAAI,uBAAC,iCAAY,IAAC,gBAAgB,EAAE,gBAAgB,GAAI,EACjE,IAAI,CAAC,CAAC,CAAC,CACN,wBAAC,iCAAI,IACH,EAAE,EAAE,IAAI,EACR,KAAK,EAAE,KAAK,EACZ,SAAS,EAAC,iCAAiC,kBAC7B,KAAK,eACR,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,KAAK,EAC5B,OAAO,EAAE,OAAO,aAEf,KAAK,EACL,UAAU,IACN,CACR,CAAC,CAAC,CAAC,CACF,kCAAM,SAAS,EAAC,iCAAiC,kBAAe,KAAK,eAAa,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,KAAK,aAChG,KAAK,EACL,UAAU,IACN,CACR,EACA,QAAQ,IACJ,CACR,CAAA;IACH,CAAC;SAAM,CAAC;QACN,OAAO,uBAAC,iCAAY,oBAAK,iBAAiB,EAAI,CAAA;IAChD,CAAC;AACH,CAAC,CAAA;AA/DY,QAAA,iBAAiB,qBA+D7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/use-fleet-k8s-watch-resource/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clearFleetK8sWatchResourceCache = exports.useFleetK8sWatchResource = void 0;
|
|
4
|
+
/* Copyright Contributors to the Open Cluster Management project */
|
|
5
|
+
var use_fleet_k8s_watch_resource_1 = require("./use-fleet-k8s-watch-resource");
|
|
6
|
+
Object.defineProperty(exports, "useFleetK8sWatchResource", { enumerable: true, get: function () { return use_fleet_k8s_watch_resource_1.useFleetK8sWatchResource; } });
|
|
7
|
+
Object.defineProperty(exports, "clearFleetK8sWatchResourceCache", { enumerable: true, get: function () { return use_fleet_k8s_watch_resource_1.clearFleetK8sWatchResourceCache; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/use-fleet-k8s-watch-resource/index.ts"],"names":[],"mappings":";;;AAAA,mEAAmE;AACnE,+EAA0G;AAAjG,wIAAA,wBAAwB,OAAA;AAAE,+IAAA,+BAA+B,OAAA"}
|
|
@@ -1,3 +1,35 @@
|
|
|
1
1
|
import { UseFleetK8sWatchResource } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* A hook for watching Kubernetes resources with support for multi-cluster environments.
|
|
4
|
+
* It is equivalent to the [`useK8sWatchResource`](https://github.com/openshift/console/blob/main/frontend/packages/console-dynamic-plugin-sdk/docs/api.md#usek8swatchresource)
|
|
5
|
+
* hook from the [OpenShift Console Dynamic Plugin SDK](https://www.npmjs.com/package/@openshift-console/dynamic-plugin-sdk)
|
|
6
|
+
* but allows you to retrieve data from any cluster managed by Red Hat Advanced Cluster Management.
|
|
7
|
+
*
|
|
8
|
+
* It automatically detects the hub cluster and handles resource watching on both hub
|
|
9
|
+
* and remote clusters using WebSocket connections for real-time updates.
|
|
10
|
+
*
|
|
11
|
+
* @param initResource - The resource to watch. Can be null to disable the watch.
|
|
12
|
+
* @param initResource.cluster - The managed cluster on which the resource resides; null for the hub cluster
|
|
13
|
+
* @returns A tuple containing the watched resource data, a boolean indicating if the data is loaded,
|
|
14
|
+
* and any error that occurred. The hook returns live-updating data.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // Watch pods on a remote cluster
|
|
19
|
+
* const [pods, loaded, error] = useFleetK8sWatchResource({
|
|
20
|
+
* groupVersionKind: { version: 'v1', kind: 'Pod' },
|
|
21
|
+
* isList: true,
|
|
22
|
+
* cluster: 'remote-cluster',
|
|
23
|
+
* namespace: 'default'
|
|
24
|
+
* })
|
|
25
|
+
*
|
|
26
|
+
* // Watch a specific deployment on hub cluster
|
|
27
|
+
* const [deployment, loaded, error] = useFleetK8sWatchResource({
|
|
28
|
+
* groupVersionKind: { group: 'apps', version: 'v1', kind: 'Deployment' },
|
|
29
|
+
* name: 'my-app',
|
|
30
|
+
* namespace: 'default'
|
|
31
|
+
* })
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
2
34
|
export declare const useFleetK8sWatchResource: UseFleetK8sWatchResource;
|
|
3
35
|
//# sourceMappingURL=useFleetK8sWatchResource.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFleetK8sWatchResource.d.ts","sourceRoot":"","sources":["../../src/api/useFleetK8sWatchResource.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useFleetK8sWatchResource.d.ts","sourceRoot":"","sources":["../../src/api/useFleetK8sWatchResource.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiD,wBAAwB,EAAE,MAAM,UAAU,CAAA;AAalG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,wBAAwB,EAAE,wBAgJtC,CAAA"}
|
|
@@ -1,12 +1,185 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
2
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
23
|
exports.useFleetK8sWatchResource = void 0;
|
|
4
24
|
/* Copyright Contributors to the Open Cluster Management project */
|
|
5
25
|
const useHubClusterName_1 = require("./useHubClusterName");
|
|
6
|
-
const
|
|
26
|
+
const dynamic_plugin_sdk_1 = require("@openshift-console/dynamic-plugin-sdk");
|
|
27
|
+
const useFleetK8sAPIPath_1 = require("./useFleetK8sAPIPath");
|
|
28
|
+
const useIsFleetAvailable_1 = require("./useIsFleetAvailable");
|
|
29
|
+
const react_1 = require("react");
|
|
30
|
+
const apiRequests_1 = require("./apiRequests");
|
|
31
|
+
const fleetK8sWatchResource_1 = require("../internal/fleetK8sWatchResource");
|
|
32
|
+
/**
|
|
33
|
+
* A hook for watching Kubernetes resources with support for multi-cluster environments.
|
|
34
|
+
* It is equivalent to the [`useK8sWatchResource`](https://github.com/openshift/console/blob/main/frontend/packages/console-dynamic-plugin-sdk/docs/api.md#usek8swatchresource)
|
|
35
|
+
* hook from the [OpenShift Console Dynamic Plugin SDK](https://www.npmjs.com/package/@openshift-console/dynamic-plugin-sdk)
|
|
36
|
+
* but allows you to retrieve data from any cluster managed by Red Hat Advanced Cluster Management.
|
|
37
|
+
*
|
|
38
|
+
* It automatically detects the hub cluster and handles resource watching on both hub
|
|
39
|
+
* and remote clusters using WebSocket connections for real-time updates.
|
|
40
|
+
*
|
|
41
|
+
* @param initResource - The resource to watch. Can be null to disable the watch.
|
|
42
|
+
* @param initResource.cluster - The managed cluster on which the resource resides; null for the hub cluster
|
|
43
|
+
* @returns A tuple containing the watched resource data, a boolean indicating if the data is loaded,
|
|
44
|
+
* and any error that occurred. The hook returns live-updating data.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* // Watch pods on a remote cluster
|
|
49
|
+
* const [pods, loaded, error] = useFleetK8sWatchResource({
|
|
50
|
+
* groupVersionKind: { version: 'v1', kind: 'Pod' },
|
|
51
|
+
* isList: true,
|
|
52
|
+
* cluster: 'remote-cluster',
|
|
53
|
+
* namespace: 'default'
|
|
54
|
+
* })
|
|
55
|
+
*
|
|
56
|
+
* // Watch a specific deployment on hub cluster
|
|
57
|
+
* const [deployment, loaded, error] = useFleetK8sWatchResource({
|
|
58
|
+
* groupVersionKind: { group: 'apps', version: 'v1', kind: 'Deployment' },
|
|
59
|
+
* name: 'my-app',
|
|
60
|
+
* namespace: 'default'
|
|
61
|
+
* })
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
7
64
|
const useFleetK8sWatchResource = (initResource) => {
|
|
8
|
-
|
|
9
|
-
|
|
65
|
+
var _a, _b, _c;
|
|
66
|
+
const [hubClusterName, hubClusterNameLoaded] = (0, useHubClusterName_1.useHubClusterName)();
|
|
67
|
+
const clusterSpecified = (initResource === null || initResource === void 0 ? void 0 : initResource.cluster) !== undefined;
|
|
68
|
+
const shouldWaitForHubClusterName = clusterSpecified && !hubClusterNameLoaded;
|
|
69
|
+
const _d = initResource !== null && initResource !== void 0 ? initResource : {}, { cluster } = _d, resource = __rest(_d, ["cluster"]);
|
|
70
|
+
const nullResource = !initResource || !(resource === null || resource === void 0 ? void 0 : resource.groupVersionKind);
|
|
71
|
+
const { isList, groupVersionKind, namespace, name } = resource !== null && resource !== void 0 ? resource : {};
|
|
72
|
+
const [model] = (0, dynamic_plugin_sdk_1.useK8sModel)(groupVersionKind);
|
|
73
|
+
const [backendAPIPath, backendPathLoaded] = (0, useFleetK8sAPIPath_1.useFleetK8sAPIPath)(cluster);
|
|
74
|
+
const isFleetAvailable = (0, useIsFleetAvailable_1.useIsFleetAvailable)();
|
|
75
|
+
const isRemoteCluster = !!cluster && cluster !== hubClusterName;
|
|
76
|
+
const useFleet = isFleetAvailable && !shouldWaitForHubClusterName && isRemoteCluster;
|
|
77
|
+
const useFallback = !isFleetAvailable || (!shouldWaitForHubClusterName && !isRemoteCluster);
|
|
78
|
+
const noCachedValue = (0, react_1.useMemo)(() => (isList ? [] : undefined), [isList]);
|
|
79
|
+
const requestPath = (0, react_1.useMemo)(() => backendPathLoaded && model
|
|
80
|
+
? (0, apiRequests_1.buildResourceURL)({
|
|
81
|
+
model,
|
|
82
|
+
ns: namespace,
|
|
83
|
+
name,
|
|
84
|
+
cluster,
|
|
85
|
+
basePath: backendAPIPath,
|
|
86
|
+
})
|
|
87
|
+
: '', [model, namespace, name, cluster, backendPathLoaded, backendAPIPath]);
|
|
88
|
+
const [data, setData] = (0, react_1.useState)((_a = fleetK8sWatchResource_1.fleetResourceCache[requestPath]) !== null && _a !== void 0 ? _a : noCachedValue);
|
|
89
|
+
const [loaded, setLoaded] = (0, react_1.useState)(!!fleetK8sWatchResource_1.fleetResourceCache[requestPath]);
|
|
90
|
+
const [error, setError] = (0, react_1.useState)(undefined);
|
|
91
|
+
(0, react_1.useEffect)(() => {
|
|
92
|
+
let socket;
|
|
93
|
+
const fetchData = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
|
+
var _a;
|
|
95
|
+
setError(undefined);
|
|
96
|
+
if (!useFleet || nullResource) {
|
|
97
|
+
setData(noCachedValue);
|
|
98
|
+
setLoaded(false);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (!backendPathLoaded || fleetK8sWatchResource_1.fleetResourceCache[requestPath]) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
const data = (yield (0, dynamic_plugin_sdk_1.consoleFetchJSON)(requestPath, 'GET'));
|
|
106
|
+
const processedData = (isList
|
|
107
|
+
? data.items.map((i) => (Object.assign({ cluster }, i)))
|
|
108
|
+
: Object.assign({ cluster }, data));
|
|
109
|
+
fleetK8sWatchResource_1.fleetResourceCache[requestPath] = processedData;
|
|
110
|
+
const watchQuery = {
|
|
111
|
+
ns: namespace,
|
|
112
|
+
cluster,
|
|
113
|
+
};
|
|
114
|
+
if (name) {
|
|
115
|
+
watchQuery.fieldSelector = `metadata.name=${name}`;
|
|
116
|
+
}
|
|
117
|
+
if (isList) {
|
|
118
|
+
watchQuery.resourceVersion = (_a = data === null || data === void 0 ? void 0 : data.metadata) === null || _a === void 0 ? void 0 : _a.resourceVersion;
|
|
119
|
+
}
|
|
120
|
+
const socketKey = (0, fleetK8sWatchResource_1.getCacheKey)({ model, cluster, namespace, name });
|
|
121
|
+
const cachedSocket = fleetK8sWatchResource_1.fleetSocketCache[socketKey];
|
|
122
|
+
if (!cachedSocket || cachedSocket.readyState !== WebSocket.OPEN) {
|
|
123
|
+
socket = (0, apiRequests_1.fleetWatch)(model, watchQuery, backendAPIPath);
|
|
124
|
+
fleetK8sWatchResource_1.fleetSocketCache[socketKey] = socket;
|
|
125
|
+
socket.onmessage = (event) => {
|
|
126
|
+
try {
|
|
127
|
+
(0, fleetK8sWatchResource_1.handleWebsocketEvent)(event, requestPath, setData, isList, fleetK8sWatchResource_1.fleetResourceCache, cluster);
|
|
128
|
+
}
|
|
129
|
+
catch (e) {
|
|
130
|
+
console.error('Failed to parse WebSocket message', e);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
socket.onclose = () => {
|
|
134
|
+
delete fleetK8sWatchResource_1.fleetSocketCache[socketKey];
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
socket = cachedSocket;
|
|
139
|
+
}
|
|
140
|
+
setData(processedData);
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
setError(err);
|
|
144
|
+
}
|
|
145
|
+
finally {
|
|
146
|
+
setLoaded(true);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
fetchData();
|
|
150
|
+
// Cleanup function to close the WebSocket if it was created by this effect
|
|
151
|
+
return () => {
|
|
152
|
+
if (socket && socket.readyState === WebSocket.OPEN) {
|
|
153
|
+
socket.close();
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}, [
|
|
157
|
+
cluster,
|
|
158
|
+
isList,
|
|
159
|
+
requestPath,
|
|
160
|
+
name,
|
|
161
|
+
namespace,
|
|
162
|
+
nullResource,
|
|
163
|
+
noCachedValue,
|
|
164
|
+
useFleet,
|
|
165
|
+
backendPathLoaded,
|
|
166
|
+
model,
|
|
167
|
+
backendAPIPath,
|
|
168
|
+
]);
|
|
169
|
+
const fallbackResult = (0, dynamic_plugin_sdk_1.useK8sWatchResource)(useFallback ? resource : null);
|
|
170
|
+
if (!nullResource && useFallback) {
|
|
171
|
+
return fallbackResult;
|
|
172
|
+
}
|
|
173
|
+
else if (!nullResource && useFleet) {
|
|
174
|
+
return [
|
|
175
|
+
(_c = (_b = fleetK8sWatchResource_1.fleetResourceCache[requestPath]) !== null && _b !== void 0 ? _b : data) !== null && _c !== void 0 ? _c : noCachedValue,
|
|
176
|
+
fleetK8sWatchResource_1.fleetResourceCache[requestPath] ? true : loaded,
|
|
177
|
+
error,
|
|
178
|
+
];
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
return [undefined, false, undefined];
|
|
182
|
+
}
|
|
10
183
|
};
|
|
11
184
|
exports.useFleetK8sWatchResource = useFleetK8sWatchResource;
|
|
12
185
|
//# sourceMappingURL=useFleetK8sWatchResource.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFleetK8sWatchResource.js","sourceRoot":"","sources":["../../src/api/useFleetK8sWatchResource.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useFleetK8sWatchResource.js","sourceRoot":"","sources":["../../src/api/useFleetK8sWatchResource.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,mEAAmE;AACnE,2DAAuD;AAEvD,8EAA0G;AAC1G,6DAAyD;AACzD,+DAA2D;AAC3D,iCAAoD;AACpD,+CAA4D;AAC5D,6EAK0C;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACI,MAAM,wBAAwB,GAA6B,CAGhE,YAA0C,EAC1C,EAAE;;IACF,MAAM,CAAC,cAAc,EAAE,oBAAoB,CAAC,GAAG,IAAA,qCAAiB,GAAE,CAAA;IAElE,MAAM,gBAAgB,GAAG,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,OAAO,MAAK,SAAS,CAAA;IAC5D,MAAM,2BAA2B,GAAG,gBAAgB,IAAI,CAAC,oBAAoB,CAAA;IAE7E,MAAM,KAA2B,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,EAAE,EAA7C,EAAE,OAAO,OAAoC,EAA/B,QAAQ,cAAtB,WAAwB,CAAqB,CAAA;IACnD,MAAM,YAAY,GAAG,CAAC,YAAY,IAAI,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,gBAAgB,CAAA,CAAA;IAEjE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CAAA;IACpE,MAAM,CAAC,KAAK,CAAC,GAAG,IAAA,gCAAW,EAAC,gBAAgB,CAAC,CAAA;IAC7C,MAAM,CAAC,cAA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,iBAAiB;QACjB,KAAK;QACL,cAAc;KACf,CAAC,CAAA;IAEF,MAAM,cAAc,GAAG,IAAA,wCAAmB,EAAI,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;IAE5E,IAAI,CAAC,YAAY,IAAI,WAAW,EAAE,CAAC;QACjC,OAAO,cAAc,CAAA;IACvB,CAAC;SAAM,IAAI,CAAC,YAAY,IAAI,QAAQ,EAAE,CAAC;QACrC,OAAO;YACL,MAAA,MAAA,0CAAkB,CAAC,WAAW,CAAC,mCAAI,IAAI,mCAAI,aAAa;YACxD,0CAAkB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM;YAC/C,KAAK;SACN,CAAA;IACH,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,SAAS,EAAE,KAAK,EAAE,SAAS,CAAC,CAAA;IACtC,CAAC;AACH,CAAC,CAAA;AAhJY,QAAA,wBAAwB,4BAgJpC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { FleetK8sResourceCommon } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* A multicluster-aware ResourceEventStream component that displays real-time Kubernetes events
|
|
5
|
+
* for resources across multiple clusters. Extends the OpenShift console's ResourceEventStream
|
|
6
|
+
* with fleet management capabilities.
|
|
7
|
+
*
|
|
8
|
+
* For managed cluster resources, this component establishes a websocket connection to stream
|
|
9
|
+
* events from the specified cluster. For hub cluster resources or when no cluster is specified,
|
|
10
|
+
* it falls back to the standard OpenShift console ResourceEventStream component.
|
|
11
|
+
*
|
|
12
|
+
* @component
|
|
13
|
+
* @since 2.15.0
|
|
14
|
+
*
|
|
15
|
+
* @param {Object} props - Component properties
|
|
16
|
+
* @param {FleetK8sResourceCommon} props.resource - The Kubernetes resource to show events for.
|
|
17
|
+
* Must include standard K8s metadata (name, namespace, uid, kind) and an optional cluster property.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Display events for a resource on a managed cluster
|
|
21
|
+
* <FleetResourceEventStream
|
|
22
|
+
* resource={{
|
|
23
|
+
* metadata: { name: 'my-pod', namespace: 'default', uid: '123' },
|
|
24
|
+
* kind: 'Pod',
|
|
25
|
+
* cluster: 'managed-cluster-1'
|
|
26
|
+
* }}
|
|
27
|
+
* />
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // Display events for a hub cluster resource (falls back to OpenShift console component)
|
|
31
|
+
* <FleetResourceEventStream
|
|
32
|
+
* resource={{
|
|
33
|
+
* metadata: { name: 'my-deployment', namespace: 'openshift-gitops', uid: '456' },
|
|
34
|
+
* kind: 'Deployment'
|
|
35
|
+
* // No cluster property - uses hub cluster
|
|
36
|
+
* }}
|
|
37
|
+
* />
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* // Display events for a cluster-scoped resource on a managed cluster
|
|
41
|
+
* <FleetResourceEventStream
|
|
42
|
+
* resource={{
|
|
43
|
+
* metadata: { name: 'my-node', uid: '789' },
|
|
44
|
+
* kind: 'Node',
|
|
45
|
+
* cluster: 'edge-cluster-2'
|
|
46
|
+
* }}
|
|
47
|
+
* />
|
|
48
|
+
*
|
|
49
|
+
* @returns {JSX.Element} A rendered event stream component showing real-time Kubernetes events
|
|
50
|
+
*
|
|
51
|
+
* @remarks
|
|
52
|
+
* **Behavior:**
|
|
53
|
+
* - When `resource.cluster` is set and differs from hub cluster: Uses fleet websocket connection
|
|
54
|
+
* - When `resource.cluster` is undefined or equals hub cluster: Falls back to OpenShift console ResourceEventStream
|
|
55
|
+
* - Automatically handles connection lifecycle (open, close, error, reconnect)
|
|
56
|
+
* - Supports both namespaced and cluster-scoped resources
|
|
57
|
+
* - Displays up to 50 most recent events with real-time streaming
|
|
58
|
+
* - Provides play/pause controls for event streaming
|
|
59
|
+
*
|
|
60
|
+
* **Event Filtering:**
|
|
61
|
+
* Events are filtered by `involvedObject.uid`, `involvedObject.name`, and `involvedObject.kind`
|
|
62
|
+
* to show only events related to the specified resource.
|
|
63
|
+
*
|
|
64
|
+
* **Error Handling:**
|
|
65
|
+
* - Shows loading spinner during initial connection
|
|
66
|
+
* - Displays error states for connection failures
|
|
67
|
+
* - Shows empty state when no events exist
|
|
68
|
+
* - Automatically attempts reconnection on websocket errors
|
|
69
|
+
*
|
|
70
|
+
* @see {@link FleetK8sResourceCommon} for resource type definition
|
|
71
|
+
* @see {@link https://github.com/openshift/console/tree/master/frontend/packages/console-dynamic-plugin-sdk} OpenShift Console Dynamic Plugin SDK
|
|
72
|
+
*/
|
|
73
|
+
declare const FleetResourceEventStream: FC<{
|
|
74
|
+
resource: FleetK8sResourceCommon;
|
|
75
|
+
}>;
|
|
76
|
+
export default FleetResourceEventStream;
|
|
77
|
+
//# sourceMappingURL=FleetResourceEventStream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FleetResourceEventStream.d.ts","sourceRoot":"","sources":["../../../src/components/FleetResourceEventStream/FleetResourceEventStream.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAA+B,MAAM,OAAO,CAAA;AAMvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAapD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AAEH,QAAA,MAAM,wBAAwB,EAAE,EAAE,CAAC;IAAE,QAAQ,EAAE,sBAAsB,CAAA;CAAE,CAoLtE,CAAA;AAED,eAAe,wBAAwB,CAAA"}
|