File tree Expand file tree Collapse file tree 4 files changed +81
-3
lines changed Expand file tree Collapse file tree 4 files changed +81
-3
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,8 @@ export const ROUTES = {
77
77
PROJECT_LIST_MIN : 'team/autocomplete' ,
78
78
USER_CHECK_ROLE : 'user/check/roles' ,
79
79
IMAGE_TAGGING : 'app/image-tagging' ,
80
+ CREATE_RESOURCE : 'k8s/resource/create' ,
81
+ K8S_RESOURCE_CREATE : 'k8s/resources/apply' ,
80
82
CI_CONFIG_GET : 'app/ci-pipeline' ,
81
83
CD_MATERIAL_GET : 'app/cd-pipeline' ,
82
84
DEPLOYMENT_TEMPLATE_LIST : 'app/template/list' ,
@@ -115,6 +117,7 @@ export const ROUTES = {
115
117
DEPLOYMENT_CHARTS_LIST : 'deployment/template/fetch' ,
116
118
USER_LIST_MIN : 'user/list/min' ,
117
119
CONFIG_DATA : 'config/data' ,
120
+ K8S_RESOURCE : 'k8s/resource' ,
118
121
K8S_RESOURCE_LIST : 'k8s/resource/list' ,
119
122
}
120
123
Original file line number Diff line number Diff line change 16
16
17
17
import { AggregationKeys , NodeType , Nodes } from '../../Shared'
18
18
import { ALL_NAMESPACE_OPTION } from './constants'
19
- import { ApiResourceGroupType } from './ResourceBrowser.Types'
19
+ import {
20
+ ApiResourceGroupType ,
21
+ CreateResourceRequestBodyParamsType ,
22
+ CreateResourceRequestBodyType ,
23
+ } from './ResourceBrowser.Types'
20
24
21
25
export function getAggregator ( nodeType : NodeType , defaultAsOtherResources ?: boolean ) : AggregationKeys {
22
26
switch ( nodeType ) {
@@ -85,3 +89,28 @@ export const getK8sResourceListPayload = (
85
89
} ,
86
90
...filters ,
87
91
} )
92
+
93
+ export const createResourceRequestBody = ( {
94
+ clusterId,
95
+ group,
96
+ version,
97
+ kind,
98
+ name,
99
+ namespace,
100
+ updatedManifest,
101
+ } : CreateResourceRequestBodyParamsType ) : CreateResourceRequestBodyType => ( {
102
+ appId : '' ,
103
+ clusterId,
104
+ k8sRequest : {
105
+ resourceIdentifier : {
106
+ groupVersionKind : {
107
+ Group : group || '' ,
108
+ Version : version || 'v1' ,
109
+ Kind : kind ,
110
+ } ,
111
+ namespace,
112
+ name,
113
+ } ,
114
+ ...( updatedManifest && { patch : updatedManifest } ) ,
115
+ } ,
116
+ } )
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ export interface BulkOperation {
82
82
}
83
83
84
84
export type BulkOperationModalProps = {
85
- operationType : 'restart' | 'delete'
85
+ operationType : 'restart' | 'delete' | 'creation'
86
86
clusterName : string
87
87
operations : NonNullable < BulkOperation [ ] >
88
88
handleModalClose : ( ) => void
@@ -93,3 +93,40 @@ export type BulkOperationModalProps = {
93
93
}
94
94
95
95
export type BulkOperationModalState = BulkOperationModalProps [ 'operationType' ] | 'closed'
96
+
97
+ export interface CreateResourceRequestBodyType {
98
+ appId : string
99
+ clusterId : number
100
+ k8sRequest : {
101
+ resourceIdentifier : Required < K8sRequestResourceIdentifierType >
102
+ patch ?: string
103
+ }
104
+ }
105
+
106
+ export interface ResourceManifestDTO {
107
+ manifestResponse : {
108
+ manifest : Record < string , unknown >
109
+ }
110
+ secretViewAccess : boolean
111
+ }
112
+
113
+ export interface CreateResourceRequestBodyParamsType
114
+ extends Pick < CreateResourceRequestBodyType , 'clusterId' > ,
115
+ Required < Pick < K8sRequestResourceIdentifierType , 'name' | 'namespace' > > {
116
+ updatedManifest ?: string
117
+ group : GVKType [ 'Group' ]
118
+ version : GVKType [ 'Version' ]
119
+ kind : GVKType [ 'Kind' ]
120
+ }
121
+
122
+ export interface CreateResourcePayload {
123
+ clusterId : number
124
+ manifest : string
125
+ }
126
+
127
+ export interface CreateResourceDTO {
128
+ kind : string
129
+ name : string
130
+ isUpdate : boolean
131
+ error : string
132
+ }
Original file line number Diff line number Diff line change 1
1
import { post } from '@Common/Api'
2
2
import { ROUTES } from '@Common/Constants'
3
3
import { ResponseType } from '@Common/Types'
4
- import { K8sResourceDetailType , K8sResourceListPayloadType } from './ResourceBrowser.Types'
4
+ import {
5
+ CreateResourceDTO ,
6
+ CreateResourcePayload ,
7
+ K8sResourceDetailType ,
8
+ K8sResourceListPayloadType ,
9
+ } from './ResourceBrowser.Types'
5
10
6
11
export const getK8sResourceList = (
7
12
resourceListPayload : K8sResourceListPayloadType ,
@@ -10,3 +15,7 @@ export const getK8sResourceList = (
10
15
post ( ROUTES . K8S_RESOURCE_LIST , resourceListPayload , {
11
16
signal,
12
17
} )
18
+
19
+ export const createNewResource = (
20
+ resourceListPayload : CreateResourcePayload ,
21
+ ) : Promise < ResponseType < CreateResourceDTO [ ] > > => post ( ROUTES . K8S_RESOURCE_CREATE , resourceListPayload )
You can’t perform that action at this time.
0 commit comments