-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathResourceBrowser.Types.ts
More file actions
218 lines (192 loc) · 5.99 KB
/
ResourceBrowser.Types.ts
File metadata and controls
218 lines (192 loc) · 5.99 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/*
* Copyright (c) 2024. Devtron Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Dispatch, RefObject, SetStateAction } from 'react'
import { GroupBase } from 'react-select'
import { ServerErrors } from '@Common/ServerError'
import { SelectPickerOptionType } from '@Shared/Components'
import { Nodes, NodeType } from '@Shared/types'
export interface GVKType {
Group: string
Version: string
Kind: Nodes | NodeType
}
export interface ApiResourceGroupType {
gvk: GVKType
namespaced: boolean
isGrouped?: boolean
shortNames?: string[] | null
}
export interface ApiResourceType {
apiResources: ApiResourceGroupType[]
allowedAll: boolean
}
export interface K8SObjectBaseType {
name: string
isExpanded: boolean
}
interface K8sRequestResourceIdentifierType {
groupVersionKind: GVKType
namespace?: string
name?: string
}
interface ResourceListPayloadK8sRequestType {
resourceIdentifier: K8sRequestResourceIdentifierType
patch?: string
forceDelete?: boolean
}
export interface K8sResourceListPayloadType {
clusterId: number
filter?: string
k8sRequest: ResourceListPayloadK8sRequestType
}
export enum ResourceRecommenderHeaderType {
NAME = 'name',
NAMESPACE = 'namespace',
KIND = 'kind',
API_VERSION = 'apiVersion',
CONTAINER_NAME = 'containerName',
CPU_REQUEST = 'cpuRequest',
CPU_LIMIT = 'cpuLimit',
MEMORY_REQUEST = 'memoryRequest',
MEMORY_LIMIT = 'memoryLimit',
}
export type ResourceRecommenderHeaderWithStringValue = Extract<
ResourceRecommenderHeaderType,
| ResourceRecommenderHeaderType.NAME
| ResourceRecommenderHeaderType.NAMESPACE
| ResourceRecommenderHeaderType.KIND
| ResourceRecommenderHeaderType.API_VERSION
| ResourceRecommenderHeaderType.CONTAINER_NAME
>
export type ResourceRecommenderHeaderWithRecommendation = Extract<
ResourceRecommenderHeaderType,
| ResourceRecommenderHeaderType.CPU_REQUEST
| ResourceRecommenderHeaderType.CPU_LIMIT
| ResourceRecommenderHeaderType.MEMORY_REQUEST
| ResourceRecommenderHeaderType.MEMORY_LIMIT
>
export type K8sResourceDetailDataType = {
[key: string]: string | number | object | boolean
additionalMetadata?: Partial<
Record<
ResourceRecommenderHeaderWithRecommendation,
{
// In case there is not limit or request set, it will be null
current: {
value: string | 'none'
} | null
// In case cron is yet to run
recommended: {
value: string | 'none'
} | null
// In case any of current or recommended is null, delta will be null
delta: number | null
}
>
>
}
export interface K8sResourceDetailType {
headers: string[]
data: K8sResourceDetailDataType[]
}
export interface BulkSelectionActionWidgetProps {
isResourceRecommendationView: boolean
count: number
handleOpenBulkDeleteModal: () => void
handleClearBulkSelection: () => void
handleOpenCordonNodeModal: () => void
handleOpenUncordonNodeModal: () => void
handleOpenDrainNodeModal: () => void
handleOpenRestartWorkloadModal: () => void
handleOpenApplyResourceRecommendationModal: () => void
parentRef: RefObject<HTMLDivElement>
showBulkRestartOption: boolean
showNodeListingOptions: boolean
}
export type RBBulkOperationType = 'restart' | 'delete' | 'cordon' | 'uncordon' | 'drain' | 'applyResourceRecommendation'
export interface CreateResourceRequestBodyType {
appId: string
clusterId: number
k8sRequest: {
resourceIdentifier: Required<K8sRequestResourceIdentifierType>
patch?: string
}
}
export interface ResourceManifestDTO {
manifestResponse: {
manifest: Record<string, unknown>
recommendedManifest?: Record<string, unknown>
}
secretViewAccess: boolean
}
export interface CreateResourceRequestBodyParamsType
extends Pick<CreateResourceRequestBodyType, 'clusterId'>,
Required<Pick<K8sRequestResourceIdentifierType, 'name' | 'namespace'>> {
updatedManifest?: string
group: GVKType['Group']
version: GVKType['Version']
kind: GVKType['Kind']
}
export interface CreateResourcePayload {
clusterId: number
manifest: string
}
export interface CreateResourceDTO {
kind: string
name: string
isUpdate: boolean
error: string
}
export interface ResourceListPayloadType {
clusterId: number
k8sRequest: {
resourceIdentifier: {
groupVersionKind: GVKType
namespace?: string
name?: string
}
patch?: string
forceDelete?: boolean
}
}
export interface ResourceType {
kind: string
name: string
isUpdate: boolean
error: string
}
export interface NodeActionRequest {
clusterId?: number
name: string
version: string
kind: string
}
export interface GVKOptionValueType {
kind: string
apiVersion: string
}
export interface GetResourceRecommenderResourceListPropsType {
resourceList: K8sResourceDetailType
reloadResourceListData: () => void
setShowAbsoluteValuesInResourceRecommender: Dispatch<SetStateAction<boolean>>
showAbsoluteValuesInResourceRecommender: boolean
gvkOptions: GroupBase<SelectPickerOptionType<GVKOptionValueType>>[]
areGVKOptionsLoading: boolean
reloadGVKOptions: () => void
gvkOptionsError: ServerErrors
isResourceListLoading: boolean
resourceListError: ServerErrors
}