@@ -51,15 +51,26 @@ const cronJobV1Beta1Validator = (workloads: IWorkloadLocator[]) =>
5151 workload . type === WorkloadKind . CronJob ,
5252 ) !== undefined ;
5353
54- let cronJobV1Supported = true ;
55- let cronJobV1Beta1Supported = true ;
54+ const argoRolloutValidator = ( workloads : IWorkloadLocator [ ] ) =>
55+ workloads . find (
56+ ( workload ) =>
57+ workload . name === 'argo-rollout' &&
58+ workload . type === WorkloadKind . ArgoRollout ,
59+ ) !== undefined ;
60+
61+ const supported = {
62+ cronJobV1 : true ,
63+ cronJobV1Beta1 : true ,
64+ argoRollout : true ,
65+ } ;
66+
5667// Next we apply some sample workloads
5768test ( 'deploy sample workloads' , async ( ) => {
5869 const argoNamespace = 'argo-rollouts' ;
5970 const servicesNamespace = 'services' ;
6071 const someImageWithSha =
6172 'docker.io/library/alpine@sha256:7746df395af22f04212cd25a92c1d6dbc5a06a0ca9579a229ef43008d4d1302a' ;
62- await Promise . all ( [
73+ await Promise . allSettled ( [
6374 kubectl . applyK8sYaml ( './test/fixtures/alpine-pod.yaml' ) ,
6475 kubectl . applyK8sYaml ( './test/fixtures/oci-dummy-pod.yaml' ) ,
6576 kubectl . applyK8sYaml ( './test/fixtures/nginx-replicationcontroller.yaml' ) ,
@@ -69,13 +80,13 @@ test('deploy sample workloads', async () => {
6980 kubectl . applyK8sYaml ( './test/fixtures/consul-deployment.yaml' ) ,
7081 kubectl . applyK8sYaml ( './test/fixtures/cronjob.yaml' ) . catch ( ( error ) => {
7182 console . log ( 'CronJob is possibly unsupported' , error ) ;
72- cronJobV1Supported = false ;
83+ supported . cronJobV1 = false ;
7384 } ) ,
7485 kubectl
7586 . applyK8sYaml ( './test/fixtures/cronjob-v1beta1.yaml' )
7687 . catch ( ( error ) => {
7788 console . log ( 'CronJobV1Beta1 is possibly unsupported' , error ) ;
78- cronJobV1Beta1Supported = false ;
89+ supported . cronJobV1Beta1 = false ;
7990 } ) ,
8091 kubectl . createPodFromImage (
8192 'alpine-from-sha' ,
@@ -90,7 +101,11 @@ test('deploy sample workloads', async () => {
90101 argoNamespace ,
91102 ) ,
92103 )
93- . then ( ( ) => kubectl . applyK8sYaml ( './test/fixtures/argo-rollout.yaml' ) ) ,
104+ . then ( ( ) => kubectl . applyK8sYaml ( './test/fixtures/argo-rollout.yaml' ) )
105+ . catch ( ( error ) => {
106+ console . log ( 'ArgoRollout is possibly unsupported' , error ) ;
107+ supported . argoRollout = false ;
108+ } ) ,
94109 ] ) ;
95110} ) ;
96111
@@ -186,11 +201,8 @@ test('snyk-monitor sends data to kubernetes-upstream', async () => {
186201 workload . name === 'consul' &&
187202 workload . type === WorkloadKind . Deployment ,
188203 ) !== undefined &&
189- workloads . find (
190- ( workload ) =>
191- workload . name === 'argo-rollout' &&
192- workload . type === WorkloadKind . ArgoRollout ,
193- ) !== undefined &&
204+ // It's either there or unsupported
205+ ( argoRolloutValidator ( workloads ) || ! supported . argoRollout ) &&
194206 // only one of the cronjob versions needs to be valid
195207 ( cronJobValidator ( workloads ) || cronJobV1Beta1Validator ( workloads ) )
196208 ) ;
@@ -269,7 +281,7 @@ test('snyk-monitor sends data to kubernetes-upstream', async () => {
269281 } ,
270282 ] ) ;
271283
272- if ( cronJobV1Beta1Supported ) {
284+ if ( supported . cronJobV1Beta1 ) {
273285 const scanResultsCronJobBeta = await getUpstreamResponseBody (
274286 `api/v1/scan-results/${ integrationId } /Default%20cluster/services/CronJob/cron-job-v1beta1` ,
275287 ) ;
@@ -284,7 +296,7 @@ test('snyk-monitor sends data to kubernetes-upstream', async () => {
284296 ] ) ;
285297 }
286298
287- if ( cronJobV1Supported ) {
299+ if ( supported . cronJobV1 ) {
288300 const scanResultsCronJob = await getUpstreamResponseBody (
289301 `api/v1/scan-results/${ integrationId } /Default%20cluster/services/CronJob/cron-job` ,
290302 ) ;
@@ -298,6 +310,21 @@ test('snyk-monitor sends data to kubernetes-upstream', async () => {
298310 } ,
299311 ] ) ;
300312 }
313+
314+ if ( supported . argoRollout ) {
315+ const scanResultsArgoRollout = await getUpstreamResponseBody (
316+ `api/v1/scan-results/${ integrationId } /Default%20cluster/services/Rollout/argo-rollout` ,
317+ ) ;
318+ expect (
319+ scanResultsArgoRollout . workloadScanResults [ 'argoproj/rollouts-demo' ] ,
320+ ) . toEqual < ScanResult [ ] > ( [
321+ {
322+ identity : { type : 'linux' , args : { platform : 'linux/amd64' } } ,
323+ facts : expect . any ( Array ) ,
324+ target : { image : 'docker-image|argoproj/rollouts-demo' } ,
325+ } ,
326+ ] ) ;
327+ }
301328} ) ;
302329
303330test ( 'snyk-monitor sends binary hashes to kubernetes-upstream after adding another deployment' , async ( ) => {
0 commit comments