Skip to content

Commit 7313800

Browse files
author
jmccormick2001
committed
slight refactor of applying selectors when listing
1 parent afa717d commit 7313800

File tree

3 files changed

+16
-26
lines changed

3 files changed

+16
-26
lines changed

internal/scorecard/plugins/basic_tests.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424

2525
v1 "k8s.io/api/core/v1"
2626
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
27-
"k8s.io/apimachinery/pkg/labels"
2827
"k8s.io/apimachinery/pkg/types"
2928
"sigs.k8s.io/controller-runtime/pkg/client"
3029
)
@@ -34,8 +33,6 @@ type BasicTestConfig struct {
3433
Client client.Client
3534
CR *unstructured.Unstructured
3635
ProxyPod *v1.Pod
37-
Version string
38-
Selector labels.Selector
3936
}
4037

4138
// Test Defintions
@@ -108,10 +105,6 @@ func NewBasicTestSuite(conf BasicTestConfig) *schelpers.TestSuite {
108105
ts.AddTest(NewCheckStatusTest(conf), 1)
109106
ts.AddTest(NewWritingIntoCRsHasEffectTest(conf), 1)
110107

111-
if schelpers.IsV1alpha2(conf.Version) {
112-
ts.ApplySelector(conf.Selector)
113-
}
114-
115108
return ts
116109
}
117110

internal/scorecard/plugins/olm_tests.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
v1 "k8s.io/api/core/v1"
2929
apiextv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
3030
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
31-
"k8s.io/apimachinery/pkg/labels"
3231
"k8s.io/apimachinery/pkg/runtime/schema"
3332
"k8s.io/apimachinery/pkg/types"
3433
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -41,8 +40,6 @@ type OLMTestConfig struct {
4140
CSV *olmapiv1alpha1.ClusterServiceVersion
4241
CRDsDir string
4342
ProxyPod *v1.Pod
44-
Selector labels.Selector
45-
Version string
4643
}
4744

4845
// Test Defintions
@@ -169,10 +166,6 @@ func NewOLMTestSuite(conf OLMTestConfig) *schelpers.TestSuite {
169166
ts.AddTest(NewSpecDescriptorsTest(conf), 1)
170167
ts.AddTest(NewStatusDescriptorsTest(conf), 1)
171168

172-
if schelpers.IsV1alpha2(conf.Version) {
173-
ts.ApplySelector(conf.Selector)
174-
}
175-
176169
return ts
177170
}
178171

internal/scorecard/plugins/plugin_runner.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,11 @@ func RunInternalPlugin(pluginType PluginType, config BasicAndOLMPluginConfig, lo
292292
Client: runtimeClient,
293293
CR: obj,
294294
ProxyPod: proxyPodGlobal,
295-
Version: config.Version,
296-
Selector: config.Selector,
297295
}
298296
basicTests := NewBasicTestSuite(conf)
297+
if schelpers.IsV1alpha2(config.Version) {
298+
basicTests.ApplySelector(config.Selector)
299+
}
299300

300301
basicTests.Run(context.TODO())
301302
logs, err := ioutil.ReadAll(logReadWriter)
@@ -313,10 +314,11 @@ func RunInternalPlugin(pluginType PluginType, config BasicAndOLMPluginConfig, lo
313314
CSV: csv,
314315
CRDsDir: config.CRDsDir,
315316
ProxyPod: proxyPodGlobal,
316-
Version: config.Version,
317-
Selector: config.Selector,
318317
}
319318
olmTests := NewOLMTestSuite(conf)
319+
if schelpers.IsV1alpha2(config.Version) {
320+
olmTests.ApplySelector(config.Selector)
321+
}
320322

321323
olmTests.Run(context.TODO())
322324
logs, err := ioutil.ReadAll(logReadWriter)
@@ -354,12 +356,13 @@ func ListInternalPlugin(pluginType PluginType, config BasicAndOLMPluginConfig) (
354356

355357
switch pluginType {
356358
case BasicOperator:
357-
conf := BasicTestConfig{
358-
Version: config.Version,
359-
Selector: config.Selector,
360-
}
359+
conf := BasicTestConfig{}
361360
basicTests := NewBasicTestSuite(conf)
362361

362+
if schelpers.IsV1alpha2(config.Version) {
363+
basicTests.ApplySelector(config.Selector)
364+
}
365+
363366
basicTests.TestResults = make([]schelpers.TestResult, 0)
364367
for i := 0; i < len(basicTests.Tests); i++ {
365368
result := schelpers.TestResult{}
@@ -370,12 +373,13 @@ func ListInternalPlugin(pluginType PluginType, config BasicAndOLMPluginConfig) (
370373
}
371374
suites = append(suites, *basicTests)
372375
case OLMIntegration:
373-
conf := OLMTestConfig{
374-
Version: config.Version,
375-
Selector: config.Selector,
376-
}
376+
conf := OLMTestConfig{}
377377
olmTests := NewOLMTestSuite(conf)
378378

379+
if schelpers.IsV1alpha2(config.Version) {
380+
olmTests.ApplySelector(config.Selector)
381+
}
382+
379383
olmTests.TestResults = make([]schelpers.TestResult, 0)
380384
for i := 0; i < len(olmTests.Tests); i++ {
381385
result := schelpers.TestResult{}

0 commit comments

Comments
 (0)