@stolostron/multicluster-sdk 0.3.5 → 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 +122 -17
- package/lib/api/FleetResourceLink.js +1 -1
- package/lib/api/FleetResourceLink.js.map +1 -1
- package/lib/api/index.d.ts +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +1 -1
- package/lib/api/index.js.map +1 -1
- package/lib/api/search/types.d.ts +7 -8
- package/lib/api/search/types.d.ts.map +1 -1
- package/lib/api/search/useFleetSearchPoll.d.ts +3 -0
- package/lib/api/search/useFleetSearchPoll.d.ts.map +1 -0
- package/lib/api/search/useFleetSearchPoll.js +104 -0
- package/lib/api/search/useFleetSearchPoll.js.map +1 -0
- 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/api/useHubClusterName.d.ts +5 -0
- package/lib/api/useHubClusterName.d.ts.map +1 -1
- package/lib/api/useHubClusterName.js +40 -8
- package/lib/api/useHubClusterName.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.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/cachedHubClusterName.d.ts +3 -0
- package/lib/internal/cachedHubClusterName.d.ts.map +1 -0
- package/lib/internal/cachedHubClusterName.js +32 -0
- package/lib/internal/cachedHubClusterName.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 +5 -3
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ Setup depends on your usage scenarios.
|
|
|
52
52
|
- [useFleetK8sWatchResource](#gear-usefleetk8swatchresource)
|
|
53
53
|
- [useFleetPrometheusPoll](#gear-usefleetprometheuspoll)
|
|
54
54
|
- [useHubClusterName](#gear-usehubclustername)
|
|
55
|
-
- [
|
|
55
|
+
- [useIsFleetAvailable](#gear-useisfleetavailable)
|
|
56
56
|
|
|
57
57
|
### :gear: fleetK8sCreate
|
|
58
58
|
|
|
@@ -108,7 +108,7 @@ Setup depends on your usage scenarios.
|
|
|
108
108
|
| ---------- | ---------- |
|
|
109
109
|
| `getFleetK8sAPIPath` | `(cluster?: string or undefined) => Promise<string>` |
|
|
110
110
|
|
|
111
|
-
[: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)
|
|
112
112
|
|
|
113
113
|
### :gear: useFleetAccessReview
|
|
114
114
|
|
|
@@ -134,7 +134,7 @@ Returns:
|
|
|
134
134
|
|
|
135
135
|
Array with `isAllowed` and `loading` values.
|
|
136
136
|
|
|
137
|
-
[: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)
|
|
138
138
|
|
|
139
139
|
### :gear: useFleetClusterNames
|
|
140
140
|
|
|
@@ -150,15 +150,54 @@ Array with `isAllowed` and `loading` values.
|
|
|
150
150
|
| ---------- | ---------- |
|
|
151
151
|
| `useFleetK8sAPIPath` | `UseFleetK8sAPIPath` |
|
|
152
152
|
|
|
153
|
-
[: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)
|
|
154
154
|
|
|
155
155
|
### :gear: useFleetK8sWatchResource
|
|
156
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
|
+
|
|
157
165
|
| Function | Type |
|
|
158
166
|
| ---------- | ---------- |
|
|
159
167
|
| `useFleetK8sWatchResource` | `UseFleetK8sWatchResource` |
|
|
160
168
|
|
|
161
|
-
|
|
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)
|
|
162
201
|
|
|
163
202
|
### :gear: useFleetPrometheusPoll
|
|
164
203
|
|
|
@@ -168,33 +207,73 @@ Array with `isAllowed` and `loading` values.
|
|
|
168
207
|
|
|
169
208
|
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/api/useFleetPrometheusPoll/index.ts#L13)
|
|
170
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
|
+
|
|
171
218
|
### :gear: useHubClusterName
|
|
172
219
|
|
|
220
|
+
Hook that provides hub cluster name.
|
|
221
|
+
|
|
173
222
|
| Function | Type |
|
|
174
223
|
| ---------- | ---------- |
|
|
175
224
|
| `useHubClusterName` | `UseHubClusterName` |
|
|
176
225
|
|
|
177
|
-
|
|
226
|
+
Returns:
|
|
227
|
+
|
|
228
|
+
Array with `hubclustername`, `loaded` and `error` values.
|
|
229
|
+
|
|
230
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/api/useHubClusterName.ts#L12)
|
|
178
231
|
|
|
179
|
-
### :gear:
|
|
232
|
+
### :gear: useIsFleetAvailable
|
|
233
|
+
|
|
234
|
+
Hook that determines if the fleet support is available.
|
|
235
|
+
|
|
236
|
+
Checks if the feature flag with the name corresponding to the `REQUIRED_PROVIDER_FLAG` constant is enabled.
|
|
237
|
+
Red Hat Advanced Cluster Management enables this feature flag in versions that provide all of the dependencies
|
|
238
|
+
required by this version of the multicluster SDK.
|
|
180
239
|
|
|
181
240
|
| Function | Type |
|
|
182
241
|
| ---------- | ---------- |
|
|
183
|
-
| `
|
|
242
|
+
| `useIsFleetAvailable` | `UseIsFleetAvailable` |
|
|
243
|
+
|
|
244
|
+
Returns:
|
|
245
|
+
|
|
246
|
+
`true` if a version of Red Hat Advanced Cluster Management that is compatible with the multicluster SDK is available; `false` otherwise
|
|
247
|
+
|
|
248
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/api/useIsFleetAvailable.ts#L15)
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
## :wrench: Constants
|
|
252
|
+
|
|
253
|
+
- [REQUIRED_PROVIDER_FLAG](#gear-required_provider_flag)
|
|
254
|
+
|
|
255
|
+
### :gear: REQUIRED_PROVIDER_FLAG
|
|
256
|
+
|
|
257
|
+
| Constant | Type |
|
|
258
|
+
| ---------- | ---------- |
|
|
259
|
+
| `REQUIRED_PROVIDER_FLAG` | `"MULTICLUSTER_SDK_PROVIDER_1"` |
|
|
184
260
|
|
|
185
|
-
[: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)
|
|
186
262
|
|
|
187
263
|
|
|
188
264
|
|
|
189
265
|
## :cocktail: Types
|
|
190
266
|
|
|
191
267
|
- [Fleet](#gear-fleet)
|
|
268
|
+
- [FleetAccessReviewResourceAttributes](#gear-fleetaccessreviewresourceattributes)
|
|
192
269
|
- [FleetK8sResourceCommon](#gear-fleetk8sresourcecommon)
|
|
193
270
|
- [FleetResourceLinkProps](#gear-fleetresourcelinkprops)
|
|
271
|
+
- [FleetWatchK8sResource](#gear-fleetwatchk8sresource)
|
|
194
272
|
- [UseFleetClusterNames](#gear-usefleetclusternames)
|
|
195
273
|
- [UseFleetK8sAPIPath](#gear-usefleetk8sapipath)
|
|
196
274
|
- [UseFleetK8sWatchResource](#gear-usefleetk8swatchresource)
|
|
197
275
|
- [UseHubClusterName](#gear-usehubclustername)
|
|
276
|
+
- [UseIsFleetAvailable](#gear-useisfleetavailable)
|
|
198
277
|
|
|
199
278
|
### :gear: Fleet
|
|
200
279
|
|
|
@@ -202,7 +281,15 @@ Array with `isAllowed` and `loading` values.
|
|
|
202
281
|
| ---------- | ---------- |
|
|
203
282
|
| `Fleet` | `T and { cluster?: string }` |
|
|
204
283
|
|
|
205
|
-
[: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)
|
|
206
293
|
|
|
207
294
|
### :gear: FleetK8sResourceCommon
|
|
208
295
|
|
|
@@ -210,7 +297,7 @@ Array with `isAllowed` and `loading` values.
|
|
|
210
297
|
| ---------- | ---------- |
|
|
211
298
|
| `FleetK8sResourceCommon` | `Fleet<K8sResourceCommon>` |
|
|
212
299
|
|
|
213
|
-
[: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)
|
|
214
301
|
|
|
215
302
|
### :gear: FleetResourceLinkProps
|
|
216
303
|
|
|
@@ -218,7 +305,15 @@ Array with `isAllowed` and `loading` values.
|
|
|
218
305
|
| ---------- | ---------- |
|
|
219
306
|
| `FleetResourceLinkProps` | `Fleet<ResourceLinkProps>` |
|
|
220
307
|
|
|
221
|
-
[: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)
|
|
222
317
|
|
|
223
318
|
### :gear: UseFleetClusterNames
|
|
224
319
|
|
|
@@ -226,7 +321,7 @@ Array with `isAllowed` and `loading` values.
|
|
|
226
321
|
| ---------- | ---------- |
|
|
227
322
|
| `UseFleetClusterNames` | `() => [string[], boolean, any]` |
|
|
228
323
|
|
|
229
|
-
[: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)
|
|
230
325
|
|
|
231
326
|
### :gear: UseFleetK8sAPIPath
|
|
232
327
|
|
|
@@ -234,7 +329,7 @@ Array with `isAllowed` and `loading` values.
|
|
|
234
329
|
| ---------- | ---------- |
|
|
235
330
|
| `UseFleetK8sAPIPath` | `( cluster?: string ) => [k8sAPIPath: string or undefined, loaded: boolean, error: Error or undefined]` |
|
|
236
331
|
|
|
237
|
-
[: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)
|
|
238
333
|
|
|
239
334
|
### :gear: UseFleetK8sWatchResource
|
|
240
335
|
|
|
@@ -242,7 +337,7 @@ Array with `isAllowed` and `loading` values.
|
|
|
242
337
|
| ---------- | ---------- |
|
|
243
338
|
| `UseFleetK8sWatchResource` | `<R extends FleetK8sResourceCommon or FleetK8sResourceCommon[]>( initResource: FleetWatchK8sResource or null ) => WatchK8sResult<R> or [undefined, boolean, any]` |
|
|
244
339
|
|
|
245
|
-
[: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)
|
|
246
341
|
|
|
247
342
|
### :gear: UseHubClusterName
|
|
248
343
|
|
|
@@ -250,7 +345,17 @@ Array with `isAllowed` and `loading` values.
|
|
|
250
345
|
| ---------- | ---------- |
|
|
251
346
|
| `UseHubClusterName` | `() => [hubClusterName: string or undefined, loaded: boolean, error: any]` |
|
|
252
347
|
|
|
253
|
-
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/fleet.ts#
|
|
348
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/fleet.ts#L16)
|
|
349
|
+
|
|
350
|
+
### :gear: UseIsFleetAvailable
|
|
351
|
+
|
|
352
|
+
Signature of the `useIsFleetAvailable` hook
|
|
353
|
+
|
|
354
|
+
| Type | Type |
|
|
355
|
+
| ---------- | ---------- |
|
|
356
|
+
| `UseIsFleetAvailable` | `() => boolean` |
|
|
357
|
+
|
|
358
|
+
[:link: Source](https://github.com/stolostron/console/blob/main/frontend/packages/multicluster-sdk/tree/../src/types/fleet.ts#L27)
|
|
254
359
|
|
|
255
360
|
|
|
256
361
|
<!-- TSDOC_END -->
|
|
@@ -261,4 +366,4 @@ Array with `isAllowed` and `loading` values.
|
|
|
261
366
|
|
|
262
367
|
## Contributing
|
|
263
368
|
|
|
264
|
-
All contributions to the repository must be submitted under the terms of the [Apache Public License 2.0](https://www.apache.org/licenses/LICENSE-2.0). For contribution guidelines, see [CONTRIBUTING.md](https://github.com/stolostron/console/blob/main/CONTRIBUTING.md).
|
|
369
|
+
All contributions to the repository must be submitted under the terms of the [Apache Public License 2.0](https://www.apache.org/licenses/LICENSE-2.0). For contribution guidelines, see [CONTRIBUTING.md](https://github.com/stolostron/console/blob/main/CONTRIBUTING.md).
|
|
@@ -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;YAClC,4BAA4B,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Q,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"}
|
package/lib/api/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export * from './FleetResourceLink';
|
|
|
3
3
|
export * from './useFleetK8sAPIPath';
|
|
4
4
|
export * from './useFleetK8sWatchResource';
|
|
5
5
|
export * from './useFleetClusterNames';
|
|
6
|
-
export * from './search/
|
|
6
|
+
export * from './search/useFleetSearchPoll';
|
|
7
7
|
export * from './apiRequests';
|
|
8
8
|
export * from './useHubClusterName';
|
|
9
9
|
export * from './useFleetPrometheusPoll';
|
package/lib/api/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,wBAAwB,CAAA;AACtC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA;AACpC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,wBAAwB,CAAA;AACtC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,eAAe,CAAA;AAC7B,cAAc,qBAAqB,CAAA;AACnC,cAAc,0BAA0B,CAAA;AACxC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA"}
|
package/lib/api/index.js
CHANGED
|
@@ -20,7 +20,7 @@ __exportStar(require("./FleetResourceLink"), exports);
|
|
|
20
20
|
__exportStar(require("./useFleetK8sAPIPath"), exports);
|
|
21
21
|
__exportStar(require("./useFleetK8sWatchResource"), exports);
|
|
22
22
|
__exportStar(require("./useFleetClusterNames"), exports);
|
|
23
|
-
__exportStar(require("./search/
|
|
23
|
+
__exportStar(require("./search/useFleetSearchPoll"), exports);
|
|
24
24
|
__exportStar(require("./apiRequests"), exports);
|
|
25
25
|
__exportStar(require("./useHubClusterName"), exports);
|
|
26
26
|
__exportStar(require("./useFleetPrometheusPoll"), exports);
|
package/lib/api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mEAAmE;AACnE,8CAA2B;AAC3B,sDAAmC;AACnC,uDAAoC;AACpC,6DAA0C;AAC1C,yDAAsC;AACtC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mEAAmE;AACnE,8CAA2B;AAC3B,sDAAmC;AACnC,uDAAoC;AACpC,6DAA0C;AAC1C,yDAAsC;AACtC,8DAA2C;AAC3C,gDAA6B;AAC7B,sDAAmC;AACnC,2DAAwC;AACxC,yDAAsC;AACtC,wDAAqC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { WatchK8sResource } from '@openshift-console/dynamic-plugin-sdk';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export {};
|
|
2
|
+
import { Fleet } from '../../types';
|
|
3
|
+
export type SearchResult<R extends K8sResourceCommon | K8sResourceCommon[]> = R extends (infer T)[] ? Fleet<T>[] : Fleet<R>;
|
|
4
|
+
export type AdvancedSearchFilter = {
|
|
5
|
+
property: string;
|
|
6
|
+
values: string[];
|
|
7
|
+
}[];
|
|
8
|
+
export type UseFleetSearchPoll = <T extends K8sResourceCommon | K8sResourceCommon[]>(watchOptions: WatchK8sResource, advancedSearchFilters?: AdvancedSearchFilter) => [SearchResult<T> | undefined, boolean, Error | undefined];
|
|
10
9
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/api/search/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/api/search/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAA;AACxE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEnC,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,iBAAiB,GAAG,iBAAiB,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAC/F,KAAK,CAAC,CAAC,CAAC,EAAE,GACV,KAAK,CAAC,CAAC,CAAC,CAAA;AAEZ,MAAM,MAAM,oBAAoB,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,EAAE,CAAA;AAE3E,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,SAAS,iBAAiB,GAAG,iBAAiB,EAAE,EACjF,YAAY,EAAE,gBAAgB,EAC9B,qBAAqB,CAAC,EAAE,oBAAoB,KACzC,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,OAAO,EAAE,KAAK,GAAG,SAAS,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFleetSearchPoll.d.ts","sourceRoot":"","sources":["../../../src/api/search/useFleetSearchPoll.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAG1D,eAAO,MAAM,kBAAkB,EAAE,kBA4GhC,CAAA"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFleetSearchPoll = void 0;
|
|
4
|
+
/* Copyright Contributors to the Open Cluster Management project */
|
|
5
|
+
const search_sdk_1 = require("./search-sdk");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const search_client_1 = require("./search-client");
|
|
8
|
+
const useFleetSearchPoll = (watchOptions, advancedSearch) => {
|
|
9
|
+
var _a;
|
|
10
|
+
const { groupVersionKind, limit, namespace, namespaced, name, isList } = watchOptions;
|
|
11
|
+
const { group, version, kind } = groupVersionKind !== null && groupVersionKind !== void 0 ? groupVersionKind : {};
|
|
12
|
+
const searchInput = (0, react_1.useMemo)(() => {
|
|
13
|
+
const filters = [];
|
|
14
|
+
// Add filters from watchOptions (these take precedence)
|
|
15
|
+
const watchOptionsProperties = new Set();
|
|
16
|
+
if (group) {
|
|
17
|
+
filters.push({ property: 'apigroup', values: [group] });
|
|
18
|
+
watchOptionsProperties.add('apigroup');
|
|
19
|
+
}
|
|
20
|
+
if (version) {
|
|
21
|
+
filters.push({ property: 'apiversion', values: [version] });
|
|
22
|
+
watchOptionsProperties.add('apiversion');
|
|
23
|
+
}
|
|
24
|
+
if (kind) {
|
|
25
|
+
filters.push({ property: 'kind', values: [kind] });
|
|
26
|
+
watchOptionsProperties.add('kind');
|
|
27
|
+
}
|
|
28
|
+
if (namespaced && namespace) {
|
|
29
|
+
filters.push({ property: 'namespace', values: [namespace] });
|
|
30
|
+
watchOptionsProperties.add('namespace');
|
|
31
|
+
}
|
|
32
|
+
if (name && name.trim()) {
|
|
33
|
+
// Use exact match instead of wildcard
|
|
34
|
+
filters.push({ property: 'name', values: [name] });
|
|
35
|
+
watchOptionsProperties.add('name');
|
|
36
|
+
}
|
|
37
|
+
// Add filters from advancedSearch, excluding properties already specified in watchOptions
|
|
38
|
+
if (advancedSearch) {
|
|
39
|
+
for (const { property, values } of advancedSearch) {
|
|
40
|
+
if (property && values !== undefined && !watchOptionsProperties.has(property)) {
|
|
41
|
+
filters.push({ property, values });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
filters,
|
|
47
|
+
limit: limit !== null && limit !== void 0 ? limit : -1,
|
|
48
|
+
};
|
|
49
|
+
}, [group, version, kind, namespaced, namespace, name, advancedSearch, limit]);
|
|
50
|
+
const { data: result, loading, error, } = (0, search_sdk_1.useSearchResultItemsQuery)({
|
|
51
|
+
client: search_client_1.searchClient,
|
|
52
|
+
skip: kind === undefined,
|
|
53
|
+
variables: {
|
|
54
|
+
input: [searchInput],
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
const data = (0, react_1.useMemo)(() => {
|
|
58
|
+
var _a, _b, _c;
|
|
59
|
+
return (_c = (_b = (_a = result === null || result === void 0 ? void 0 : result.searchResult) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.items) === null || _c === void 0 ? void 0 : _c.map((item) => {
|
|
60
|
+
let label = {};
|
|
61
|
+
if (item === null || item === void 0 ? void 0 : item.label) {
|
|
62
|
+
label = Object.fromEntries(item.label.split(';').map((pair) => pair.trimStart().split('=')));
|
|
63
|
+
}
|
|
64
|
+
const resource = {
|
|
65
|
+
cluster: item.cluster,
|
|
66
|
+
apiVersion: `${item.apigroup ? `${item.apigroup}/` : ''}${item.apiversion}`,
|
|
67
|
+
kind: item.kind,
|
|
68
|
+
metadata: {
|
|
69
|
+
creationTimestamp: item.created,
|
|
70
|
+
name: item.name,
|
|
71
|
+
namespace: item.namespace,
|
|
72
|
+
labels: label,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
// Reverse the flattening of specific resources by the search-collector
|
|
76
|
+
// See https://github.com/stolostron/search-collector/blob/main/pkg/transforms/genericResourceConfig.go
|
|
77
|
+
switch (kind) {
|
|
78
|
+
case 'VirtualMachine':
|
|
79
|
+
resource.spec = {
|
|
80
|
+
running: item._specRunning,
|
|
81
|
+
runStrategy: item._specRunStrategy,
|
|
82
|
+
template: { spec: { domain: { cpu: { cores: item.cpu }, memory: { guest: item.memory } } } },
|
|
83
|
+
};
|
|
84
|
+
resource.status = { conditions: [{ type: 'Ready', status: item.ready }], printableStatus: item.status };
|
|
85
|
+
break;
|
|
86
|
+
case 'VirtualMachineInstance':
|
|
87
|
+
resource.status = {
|
|
88
|
+
conditions: [
|
|
89
|
+
{ type: 'LiveMigratable', status: item.liveMigratable },
|
|
90
|
+
{ type: 'Ready', status: item.ready },
|
|
91
|
+
],
|
|
92
|
+
interfaces: [{ ipAddress: item.ipaddress, name: 'default' }],
|
|
93
|
+
nodeName: item.node,
|
|
94
|
+
phase: item.phase,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return resource;
|
|
98
|
+
});
|
|
99
|
+
}, [kind, result]);
|
|
100
|
+
const nullResponse = (0, react_1.useMemo)(() => (isList ? [] : undefined), [isList]);
|
|
101
|
+
return [(_a = data) !== null && _a !== void 0 ? _a : nullResponse, !loading, error];
|
|
102
|
+
};
|
|
103
|
+
exports.useFleetSearchPoll = useFleetSearchPoll;
|
|
104
|
+
//# sourceMappingURL=useFleetSearchPoll.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFleetSearchPoll.js","sourceRoot":"","sources":["../../../src/api/search/useFleetSearchPoll.ts"],"names":[],"mappings":";;;AAAA,mEAAmE;AACnE,6CAAwD;AACxD,iCAA+B;AAE/B,mDAA8C;AAEvC,MAAM,kBAAkB,GAAuB,CAAC,YAAY,EAAE,cAAc,EAAE,EAAE;;IACrF,MAAM,EAAE,gBAAgB,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,YAAY,CAAA;IAErF,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,gBAAgB,aAAhB,gBAAgB,cAAhB,gBAAgB,GAAI,EAAE,CAAA;IAEvD,MAAM,WAAW,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAC/B,MAAM,OAAO,GAAkD,EAAE,CAAA;QAEjE,wDAAwD;QACxD,MAAM,sBAAsB,GAAG,IAAI,GAAG,EAAU,CAAA;QAEhD,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;YACvD,sBAAsB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;QACxC,CAAC;QACD,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;YAC3D,sBAAsB,CAAC,GAAG,CAAC,YAAY,CAA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AAC,CAAC,CAAA;IAEvE,OAAO,CAAC,MAAC,IAA0B,mCAAI,YAAY,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;AACvE,CAAC,CAAA;AA5GY,QAAA,kBAAkB,sBA4G9B"}
|
|
@@ -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"}
|