-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathprepareCustomObjectAPI.ts
More file actions
58 lines (54 loc) · 2.58 KB
/
prepareCustomObjectAPI.ts
File metadata and controls
58 lines (54 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* Copyright (c) 2018-2025 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
import * as k8s from '@kubernetes/client-node';
import { JSON_PATCH_OPTIONS } from '@/devworkspaceClient/services/helpers/patchOptions';
import { retryableExec } from '@/devworkspaceClient/services/helpers/retryableExec';
export type CustomObjectAPI = Pick<
k8s.CustomObjectsApi,
| 'getClusterCustomObject'
| 'listClusterCustomObject'
| 'listNamespacedCustomObject'
| 'getNamespacedCustomObject'
| 'createNamespacedCustomObject'
| 'replaceNamespacedCustomObject'
| 'deleteNamespacedCustomObject'
| 'patchNamespacedCustomObject'
>;
export function prepareCustomObjectAPI(kc: k8s.KubeConfig): CustomObjectAPI {
const customObjectsApi = kc.makeApiClient(k8s.CustomObjectsApi);
return {
getClusterCustomObject: (...args: Parameters<typeof customObjectsApi.getClusterCustomObject>) =>
retryableExec(() => customObjectsApi.getClusterCustomObject(...args)),
listClusterCustomObject: (
...args: Parameters<typeof customObjectsApi.listClusterCustomObject>
) => retryableExec(() => customObjectsApi.listClusterCustomObject(...args)),
listNamespacedCustomObject: (
...args: Parameters<typeof customObjectsApi.listNamespacedCustomObject>
) => retryableExec(() => customObjectsApi.listNamespacedCustomObject(...args)),
getNamespacedCustomObject: (
...args: Parameters<typeof customObjectsApi.getNamespacedCustomObject>
) => retryableExec(() => customObjectsApi.getNamespacedCustomObject(...args)),
createNamespacedCustomObject: (
...args: Parameters<typeof customObjectsApi.createNamespacedCustomObject>
) => retryableExec(() => customObjectsApi.createNamespacedCustomObject(...args)),
replaceNamespacedCustomObject: (
...args: Parameters<typeof customObjectsApi.replaceNamespacedCustomObject>
) => retryableExec(() => customObjectsApi.replaceNamespacedCustomObject(...args)),
deleteNamespacedCustomObject: (
...args: Parameters<typeof customObjectsApi.deleteNamespacedCustomObject>
) => retryableExec(() => customObjectsApi.deleteNamespacedCustomObject(...args)),
patchNamespacedCustomObject: (
param: Parameters<typeof customObjectsApi.patchNamespacedCustomObject>[0],
) =>
retryableExec(() => customObjectsApi.patchNamespacedCustomObject(param, JSON_PATCH_OPTIONS)),
};
}