@@ -51,6 +51,8 @@ const cronJobV1Beta1Validator = (workloads: IWorkloadLocator[]) =>
5151 workload . type === WorkloadKind . CronJob ,
5252 ) !== undefined ;
5353
54+ let cronJobV1Supported = true ;
55+ let cronJobV1Beta1Supported = true ;
5456// Next we apply some sample workloads
5557test ( 'deploy sample workloads' , async ( ) => {
5658 const servicesNamespace = 'services' ;
@@ -66,11 +68,13 @@ test('deploy sample workloads', async () => {
6668 kubectl . applyK8sYaml ( './test/fixtures/consul-deployment.yaml' ) ,
6769 kubectl . applyK8sYaml ( './test/fixtures/cronjob.yaml' ) . catch ( ( error ) => {
6870 console . log ( 'CronJob is possibly unsupported' , error ) ;
71+ cronJobV1Supported = false ;
6972 } ) ,
7073 kubectl
7174 . applyK8sYaml ( './test/fixtures/cronjob-v1beta1.yaml' )
7275 . catch ( ( error ) => {
7376 console . log ( 'CronJobV1Beta1 is possibly unsupported' , error ) ;
77+ cronJobV1Beta1Supported = false ;
7478 } ) ,
7579 kubectl . createPodFromImage (
7680 'alpine-from-sha' ,
@@ -250,32 +254,35 @@ test('snyk-monitor sends data to kubernetes-upstream', async () => {
250254 } ,
251255 ] ) ;
252256
253- const scanResultsCronJob = await getUpstreamResponseBody (
254- `api/v1/scan-results/${ integrationId } /Default%20cluster/services/CronJob/cron-job` ,
255- ) ;
256- expect ( scanResultsCronJob . workloadScanResults [ 'busybox' ] ) . toEqual <
257- ScanResult [ ]
258- > ( [
259- {
260- identity : { type : 'linux' , args : { platform : 'linux/amd64' } } ,
261- facts : expect . any ( Array ) ,
262- target : { image : 'docker-image|busybox' } ,
263- } ,
264- ] ) ;
257+ if ( cronJobV1Beta1Supported ) {
258+ const scanResultsCronJobBeta = await getUpstreamResponseBody (
259+ `api/v1/scan-results/${ integrationId } /Default%20cluster/services/CronJob/cron-job-v1beta1` ,
260+ ) ;
261+ expect ( scanResultsCronJobBeta . workloadScanResults [ 'busybox' ] ) . toEqual <
262+ ScanResult [ ]
263+ > ( [
264+ {
265+ identity : { type : 'linux' , args : { platform : 'linux/amd64' } } ,
266+ facts : expect . any ( Array ) ,
267+ target : { image : 'docker-image|busybox' } ,
268+ } ,
269+ ] ) ;
270+ }
265271
266- // the v1 reader works for both v1 and v1beta1
267- const scanResultsCronJobBeta = await getUpstreamResponseBody (
268- `api/v1/scan-results/${ integrationId } /Default%20cluster/services/CronJob/cron-job-v1beta1` ,
269- ) ;
270- expect ( scanResultsCronJobBeta . workloadScanResults [ 'busybox' ] ) . toEqual <
271- ScanResult [ ]
272- > ( [
273- {
274- identity : { type : 'linux' , args : { platform : 'linux/amd64' } } ,
275- facts : expect . any ( Array ) ,
276- target : { image : 'docker-image|busybox' } ,
277- } ,
278- ] ) ;
272+ if ( cronJobV1Supported ) {
273+ const scanResultsCronJob = await getUpstreamResponseBody (
274+ `api/v1/scan-results/${ integrationId } /Default%20cluster/services/CronJob/cron-job` ,
275+ ) ;
276+ expect ( scanResultsCronJob . workloadScanResults [ 'busybox' ] ) . toEqual <
277+ ScanResult [ ]
278+ > ( [
279+ {
280+ identity : { type : 'linux' , args : { platform : 'linux/amd64' } } ,
281+ facts : expect . any ( Array ) ,
282+ target : { image : 'docker-image|busybox' } ,
283+ } ,
284+ ] ) ;
285+ }
279286} ) ;
280287
281288test ( 'snyk-monitor sends binary hashes to kubernetes-upstream after adding another deployment' , async ( ) => {
0 commit comments