@@ -269,26 +269,24 @@ func RunInternalPlugin(pluginType PluginType, config BasicAndOLMPluginConfig, lo
269
269
log .SetOutput (logReadWriter )
270
270
log .Printf ("Running for cr: %s" , cr )
271
271
var obj * unstructured.Unstructured
272
- if ! config .ListOpt {
273
- if ! config .OLMDeployed {
274
- if err := createFromYAMLFile (config .Namespace , config .GlobalManifest , config .ProxyImage , config .ProxyPullPolicy ); err != nil {
275
- return scapiv1alpha1.ScorecardOutput {}, fmt .Errorf ("failed to create global resources: %v" , err )
276
- }
277
- if err := createFromYAMLFile (config .Namespace , config .NamespacedManifest , config .ProxyImage , config .ProxyPullPolicy ); err != nil {
278
- return scapiv1alpha1.ScorecardOutput {}, fmt .Errorf ("failed to create namespaced resources: %v" , err )
279
- }
280
- }
281
- if err := createFromYAMLFile (config .Namespace , cr , config .ProxyImage , config .ProxyPullPolicy ); err != nil {
282
- return scapiv1alpha1.ScorecardOutput {}, fmt .Errorf ("failed to create cr resource: %v" , err )
283
- }
284
- obj , err = yamlToUnstructured (config .Namespace , cr )
285
- if err != nil {
286
- return scapiv1alpha1.ScorecardOutput {}, fmt .Errorf ("failed to decode custom resource manifest into object: %s" , err )
272
+ if ! config .OLMDeployed {
273
+ if err := createFromYAMLFile (config .Namespace , config .GlobalManifest , config .ProxyImage , config .ProxyPullPolicy ); err != nil {
274
+ return scapiv1alpha1.ScorecardOutput {}, fmt .Errorf ("failed to create global resources: %v" , err )
287
275
}
288
- if err := waitUntilCRStatusExists ( time . Second * time . Duration ( config .InitTimeout ), obj ); err != nil {
289
- return scapiv1alpha1.ScorecardOutput {}, fmt .Errorf ("failed waiting to check if CR status exists : %v" , err )
276
+ if err := createFromYAMLFile ( config . Namespace , config . NamespacedManifest , config .ProxyImage , config . ProxyPullPolicy ); err != nil {
277
+ return scapiv1alpha1.ScorecardOutput {}, fmt .Errorf ("failed to create namespaced resources : %v" , err )
290
278
}
291
279
}
280
+ if err := createFromYAMLFile (config .Namespace , cr , config .ProxyImage , config .ProxyPullPolicy ); err != nil {
281
+ return scapiv1alpha1.ScorecardOutput {}, fmt .Errorf ("failed to create cr resource: %v" , err )
282
+ }
283
+ obj , err = yamlToUnstructured (config .Namespace , cr )
284
+ if err != nil {
285
+ return scapiv1alpha1.ScorecardOutput {}, fmt .Errorf ("failed to decode custom resource manifest into object: %s" , err )
286
+ }
287
+ if err := waitUntilCRStatusExists (time .Second * time .Duration (config .InitTimeout ), obj ); err != nil {
288
+ return scapiv1alpha1.ScorecardOutput {}, fmt .Errorf ("failed waiting to check if CR status exists: %v" , err )
289
+ }
292
290
if pluginType == BasicOperator {
293
291
conf := BasicTestConfig {
294
292
Client : runtimeClient ,
@@ -299,18 +297,14 @@ func RunInternalPlugin(pluginType PluginType, config BasicAndOLMPluginConfig, lo
299
297
if schelpers .IsV1alpha2 (config .Version ) {
300
298
basicTests .ApplySelector (config .Selector )
301
299
}
302
- if config .ListOpt {
303
- basicTests .List ()
300
+ basicTests .Run (context .TODO ())
301
+ logs , err := ioutil .ReadAll (logReadWriter )
302
+ if err != nil {
303
+ basicTests .Log = fmt .Sprintf ("failed to read log buffer: %v" , err )
304
304
} else {
305
- basicTests .Run (context .TODO ())
306
- logs , err := ioutil .ReadAll (logReadWriter )
307
- if err != nil {
308
- basicTests .Log = fmt .Sprintf ("failed to read log buffer: %v" , err )
309
- } else {
310
- basicTests .Log = string (logs )
311
- }
312
- suites = append (suites , * basicTests )
305
+ basicTests .Log = string (logs )
313
306
}
307
+ suites = append (suites , * basicTests )
314
308
}
315
309
if pluginType == OLMIntegration {
316
310
conf := OLMTestConfig {
@@ -324,18 +318,14 @@ func RunInternalPlugin(pluginType PluginType, config BasicAndOLMPluginConfig, lo
324
318
if schelpers .IsV1alpha2 (config .Version ) {
325
319
olmTests .ApplySelector (config .Selector )
326
320
}
327
- if config .ListOpt {
328
- olmTests .List ()
321
+ olmTests .Run (context .TODO ())
322
+ logs , err := ioutil .ReadAll (logReadWriter )
323
+ if err != nil {
324
+ olmTests .Log = fmt .Sprintf ("failed to read log buffer: %v" , err )
329
325
} else {
330
- olmTests .Run (context .TODO ())
331
- logs , err := ioutil .ReadAll (logReadWriter )
332
- if err != nil {
333
- olmTests .Log = fmt .Sprintf ("failed to read log buffer: %v" , err )
334
- } else {
335
- olmTests .Log = string (logs )
336
- }
337
- suites = append (suites , * olmTests )
326
+ olmTests .Log = string (logs )
338
327
}
328
+ suites = append (suites , * olmTests )
339
329
}
340
330
// change logging back to main log
341
331
log .SetOutput (logFile )
@@ -358,3 +348,47 @@ func RunInternalPlugin(pluginType PluginType, config BasicAndOLMPluginConfig, lo
358
348
}
359
349
return output , nil
360
350
}
351
+
352
+ func ListInternalPlugin (pluginType PluginType , config BasicAndOLMPluginConfig ) (scapiv1alpha1.ScorecardOutput , error ) {
353
+ var suites []schelpers.TestSuite
354
+
355
+ if pluginType == BasicOperator {
356
+ conf := BasicTestConfig {}
357
+ basicTests := NewBasicTestSuite (conf )
358
+ if schelpers .IsV1alpha2 (config .Version ) {
359
+ basicTests .ApplySelector (config .Selector )
360
+ }
361
+
362
+ basicTests .TestResults = make ([]schelpers.TestResult , 0 )
363
+ for i := 0 ; i < len (basicTests .Tests ); i ++ {
364
+ result := schelpers.TestResult {}
365
+ result .Test = basicTests .Tests [i ]
366
+ result .Suggestions = make ([]string , 0 )
367
+ result .Errors = make ([]error , 0 )
368
+ basicTests .TestResults = append (basicTests .TestResults , result )
369
+ }
370
+ suites = append (suites , * basicTests )
371
+ }
372
+ if pluginType == OLMIntegration {
373
+ conf := OLMTestConfig {}
374
+ olmTests := NewOLMTestSuite (conf )
375
+ if schelpers .IsV1alpha2 (config .Version ) {
376
+ olmTests .ApplySelector (config .Selector )
377
+ }
378
+ olmTests .TestResults = make ([]schelpers.TestResult , 0 )
379
+ for i := 0 ; i < len (olmTests .Tests ); i ++ {
380
+ result := schelpers.TestResult {}
381
+ result .Test = olmTests .Tests [i ]
382
+ result .Suggestions = make ([]string , 0 )
383
+ result .Errors = make ([]error , 0 )
384
+ olmTests .TestResults = append (olmTests .TestResults , result )
385
+ }
386
+ suites = append (suites , * olmTests )
387
+ }
388
+ suites , err := schelpers .MergeSuites (suites )
389
+ if err != nil {
390
+ return scapiv1alpha1.ScorecardOutput {}, fmt .Errorf ("failed to merge test suite results: %v" , err )
391
+ }
392
+ output := schelpers .TestSuitesToScorecardOutput (suites , "" )
393
+ return output , nil
394
+ }
0 commit comments