1
- import { IncomingMessage } from 'http' ;
2
1
import { deleteWorkload } from './workload' ;
3
2
import { WorkloadKind } from '../../types' ;
4
3
import {
@@ -20,10 +19,7 @@ import { trimWorkload } from '../../workload-sanitization';
20
19
21
20
export async function paginatedNamespacedArgoRolloutList (
22
21
namespace : string ,
23
- ) : Promise < {
24
- response : IncomingMessage ;
25
- body : V1alpha1RolloutList ;
26
- } > {
22
+ ) : Promise < V1alpha1RolloutList > {
27
23
const rolloutList = new V1alpha1RolloutList ( ) ;
28
24
rolloutList . apiVersion = 'argoproj.io/v1alpha1' ;
29
25
rolloutList . kind = 'RolloutList' ;
@@ -32,26 +28,26 @@ export async function paginatedNamespacedArgoRolloutList(
32
28
return await paginatedNamespacedList (
33
29
namespace ,
34
30
rolloutList ,
35
- async (
36
- namespace : string ,
37
- pretty ?: string ,
38
- _allowWatchBookmarks ?: boolean ,
39
- _continue ?: string ,
40
- fieldSelector ?: string ,
41
- labelSelector ?: string ,
42
- limit ?: number ,
43
- ) =>
44
- k8sApi . customObjectsClient . listNamespacedCustomObject (
45
- 'argoproj.io' ,
46
- 'v1alpha1' ,
47
- namespace ,
48
- 'rollouts' ,
49
- pretty ,
50
- false ,
51
- _continue ,
52
- fieldSelector ,
53
- labelSelector ,
54
- limit ,
31
+ async ( batchRequest : {
32
+ namespace : string ;
33
+ pretty ?: string ;
34
+ _allowWatchBookmarks ?: boolean ;
35
+ _continue ?: string ;
36
+ fieldSelector ?: string ;
37
+ labelSelector ?: string ;
38
+ limit ?: number ;
39
+ } ) =>
40
+ k8sApi . customObjectsClient . listNamespacedCustomObject ( {
41
+ group : 'argoproj.io' ,
42
+ version : 'v1alpha1' ,
43
+ namespace : namespace ,
44
+ plural : 'rollouts' ,
45
+ pretty : batchRequest . pretty ,
46
+ allowWatchBookmarks : false ,
47
+ _continue : batchRequest . _continue ,
48
+ fieldSelector : batchRequest . fieldSelector ,
49
+ labelSelector : batchRequest . labelSelector ,
50
+ limit : batchRequest . limit ,
55
51
/**
56
52
* The K8s client's listNamespacedCustomObject() doesn't allow to specify
57
53
* the type of the response body and returns the generic "object" type,
@@ -61,40 +57,37 @@ export async function paginatedNamespacedArgoRolloutList(
61
57
* Type 'Promise<{ response: IncomingMessage; ***body: object;*** }>' is not assignable to type
62
58
* 'Promise<{ response: IncomingMessage; ***body: KubernetesListObject<...>;*** }>'
63
59
*/
64
- ) as any ,
60
+ } ) as any ,
65
61
) ;
66
62
}
67
63
68
- export async function paginatedClusterArgoRolloutList ( ) : Promise < {
69
- response : IncomingMessage ;
70
- body : V1alpha1RolloutList ;
71
- } > {
64
+ export async function paginatedClusterArgoRolloutList ( ) : Promise < V1alpha1RolloutList > {
72
65
const rolloutList = new V1alpha1RolloutList ( ) ;
73
66
rolloutList . apiVersion = 'argoproj.io/v1' ;
74
67
rolloutList . kind = 'RolloutList' ;
75
68
rolloutList . items = new Array < V1alpha1Rollout > ( ) ;
76
69
77
70
return await paginatedClusterList (
78
71
rolloutList ,
79
- async (
80
- _allowWatchBookmarks ?: boolean ,
81
- _continue ?: string ,
82
- fieldSelector ?: string ,
83
- labelSelector ?: string ,
84
- limit ?: number ,
85
- pretty ?: string ,
86
- ) =>
87
- k8sApi . customObjectsClient . listClusterCustomObject (
88
- 'argoproj.io' ,
89
- 'v1alpha1' ,
90
- 'rollouts' ,
91
- pretty ,
92
- false ,
93
- _continue ,
94
- fieldSelector ,
95
- labelSelector ,
96
- limit ,
97
- ) as any ,
72
+ async ( clusterRequest : {
73
+ _allowWatchBookmarks ?: boolean ;
74
+ _continue ?: string ;
75
+ fieldSelector ?: string ;
76
+ labelSelector ?: string ;
77
+ limit ?: number ;
78
+ pretty ?: string ;
79
+ } ) =>
80
+ k8sApi . customObjectsClient . listClusterCustomObject ( {
81
+ group : 'argoproj.io' ,
82
+ version : 'v1alpha1' ,
83
+ plural : 'rollouts' ,
84
+ pretty : clusterRequest . pretty ,
85
+ allowWatchBookmarks : false ,
86
+ _continue : clusterRequest . _continue ,
87
+ fieldSelector : clusterRequest . fieldSelector ,
88
+ labelSelector : clusterRequest . labelSelector ,
89
+ limit : clusterRequest . limit ,
90
+ } ) as any ,
98
91
) ;
99
92
}
100
93
@@ -109,23 +102,32 @@ export async function argoRolloutWatchHandler(
109
102
// Perform lookup for known supported kinds: https://github.com/argoproj/argo-rollouts/blob/master/rollout/templateref.go#L40-L52
110
103
case 'Deployment' : {
111
104
const deployResult = await retryKubernetesApiRequest ( ( ) =>
112
- k8sApi . appsClient . readNamespacedDeployment ( workloadName , namespace ) ,
105
+ k8sApi . appsClient . readNamespacedDeployment ( {
106
+ name : workloadName ,
107
+ namespace,
108
+ } ) ,
113
109
) ;
114
- rollout . spec . template = deployResult . body . spec ?. template ;
110
+ rollout . spec . template = deployResult . spec ?. template ;
115
111
break ;
116
112
}
117
113
case 'ReplicaSet' : {
118
114
const replicaSetResult = await retryKubernetesApiRequest ( ( ) =>
119
- k8sApi . appsClient . readNamespacedReplicaSet ( workloadName , namespace ) ,
115
+ k8sApi . appsClient . readNamespacedReplicaSet ( {
116
+ name : workloadName ,
117
+ namespace,
118
+ } ) ,
120
119
) ;
121
- rollout . spec . template = replicaSetResult . body . spec ?. template ;
120
+ rollout . spec . template = replicaSetResult . spec ?. template ;
122
121
break ;
123
122
}
124
123
case 'PodTemplate' : {
125
124
const podTemplateResult = await retryKubernetesApiRequest ( ( ) =>
126
- k8sApi . coreClient . readNamespacedPodTemplate ( workloadName , namespace ) ,
125
+ k8sApi . coreClient . readNamespacedPodTemplate ( {
126
+ name : workloadName ,
127
+ namespace,
128
+ } ) ,
127
129
) ;
128
- rollout . spec . template = podTemplateResult . body . template ;
130
+ rollout . spec . template = podTemplateResult . template ;
129
131
break ;
130
132
}
131
133
default :
@@ -186,21 +188,20 @@ export async function isNamespacedArgoRolloutSupported(
186
188
const resourceVersion = undefined ; // List anything in the cluster
187
189
const timeoutSeconds = 10 ; // Don't block the snyk-monitor indefinitely
188
190
const attemptedApiCall = await retryKubernetesApiRequest ( ( ) =>
189
- k8sApi . customObjectsClient . listNamespacedCustomObject (
190
- 'argoproj.io' ,
191
- 'v1alpha1' ,
192
- namespace ,
193
- 'rollouts' ,
194
- pretty ,
195
- false ,
196
- continueToken ,
197
- fieldSelector ,
198
- labelSelector ,
199
- limit ,
200
- resourceVersion ,
201
- undefined ,
202
- timeoutSeconds ,
203
- ) ,
191
+ k8sApi . customObjectsClient . listNamespacedCustomObject ( {
192
+ group : 'argoproj.io' ,
193
+ version : 'v1alpha1' ,
194
+ namespace : namespace ,
195
+ plural : 'rollouts' ,
196
+ pretty : pretty ,
197
+ allowWatchBookmarks : false ,
198
+ _continue : continueToken ,
199
+ fieldSelector : fieldSelector ,
200
+ labelSelector : labelSelector ,
201
+ limit : limit ,
202
+ resourceVersion : resourceVersion ,
203
+ timeoutSeconds : timeoutSeconds ,
204
+ } ) ,
204
205
) ;
205
206
return (
206
207
attemptedApiCall !== undefined &&
@@ -228,20 +229,19 @@ export async function isClusterArgoRolloutSupported(): Promise<boolean> {
228
229
const resourceVersion = undefined ; // List anything in the cluster
229
230
const timeoutSeconds = 10 ; // Don't block the snyk-monitor indefinitely
230
231
const attemptedApiCall = await retryKubernetesApiRequest ( ( ) =>
231
- k8sApi . customObjectsClient . listClusterCustomObject (
232
- 'argoproj.io' ,
233
- 'v1alpha1' ,
234
- 'rollouts' ,
235
- pretty ,
236
- false ,
237
- continueToken ,
238
- fieldSelector ,
239
- labelSelector ,
240
- limit ,
241
- resourceVersion ,
242
- undefined ,
243
- timeoutSeconds ,
244
- ) ,
232
+ k8sApi . customObjectsClient . listClusterCustomObject ( {
233
+ group : 'argoproj.io' ,
234
+ version : 'v1alpha1' ,
235
+ plural : 'rollouts' ,
236
+ pretty : pretty ,
237
+ allowWatchBookmarks : false ,
238
+ _continue : continueToken ,
239
+ fieldSelector : fieldSelector ,
240
+ labelSelector : labelSelector ,
241
+ limit : limit ,
242
+ resourceVersion : resourceVersion ,
243
+ timeoutSeconds : timeoutSeconds ,
244
+ } ) ,
245
245
) ;
246
246
return (
247
247
attemptedApiCall !== undefined &&
0 commit comments