Skip to content

Commit 4721965

Browse files
perdasilvaopenshift-cherrypick-robot
authored andcommitted
make plugin e2e tests skippable
Signed-off-by: perdasilva <[email protected]>
1 parent 2fbb6fb commit 4721965

File tree

9 files changed

+39
-6
lines changed

9 files changed

+39
-6
lines changed

staging/operator-lifecycle-manager/pkg/controller/operators/olm/downstream_csv_labeler.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import (
55
"fmt"
66

77
"github.com/operator-framework/api/pkg/operators/v1alpha1"
8+
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/olm/plugins"
89
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
910
"github.com/sirupsen/logrus"
1011
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1112
)
1213

14+
const CsvLabelerPluginId plugins.PluginID = "csv-labeler-plugin"
1315
const labelSyncerLabelKey = ""
1416

1517
func NewCSVLabelSyncerLabeler(client operatorclient.ClientInterface, logger *logrus.Logger) *CSVLabelSyncerLabeler {

staging/operator-lifecycle-manager/pkg/controller/operators/olm/downstream_plugins.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ import (
55
)
66

77
func init() {
8-
operatorPlugInFactoryFuncs = []plugins.OperatorPlugInFactoryFunc{
8+
operatorPlugInFactoryFuncs = plugins.OperatorPlugInFactoryMap{
99
// labels unlabeled non-payload openshift-* csv namespaces with
1010
// security.openshift.io/scc.podSecurityLabelSync: true
11-
plugins.NewCsvNamespaceLabelerPluginFunc,
11+
CsvLabelerPluginId: plugins.NewCsvNamespaceLabelerPluginFunc,
1212
}
1313
}
14+
15+
func IsPluginEnabled(pluginID plugins.PluginID) bool {
16+
_, ok := operatorPlugInFactoryFuncs[pluginID]
17+
return ok
18+
}

staging/operator-lifecycle-manager/pkg/controller/operators/olm/operator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ var (
6464

6565
// this unexported operator plugin slice provides an entrypoint for
6666
// downstream to inject its own plugins to augment the controller behavior
67-
var operatorPlugInFactoryFuncs []plugins.OperatorPlugInFactoryFunc
67+
var operatorPlugInFactoryFuncs plugins.OperatorPlugInFactoryMap
6868

6969
type Operator struct {
7070
queueinformer.Operator

staging/operator-lifecycle-manager/pkg/controller/operators/olm/plugins/operator_plugin.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import (
1010
"github.com/sirupsen/logrus"
1111
)
1212

13+
type PluginID string
14+
type OperatorPlugInFactoryMap map[PluginID]OperatorPlugInFactoryFunc
15+
1316
// HostOperator is an extensible and observable operator that hosts the plug-in, i.e. which the plug-in is extending
1417
type HostOperator interface {
1518
queueinformer.ObservableOperator

staging/operator-lifecycle-manager/test/e2e/downstream_csv_namespace_labeler_plugin_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
. "github.com/onsi/ginkgo/v2"
88
. "github.com/onsi/gomega"
99
"github.com/operator-framework/api/pkg/operators/v1alpha1"
10+
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/olm"
1011
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/olm/plugins"
1112
"github.com/operator-framework/operator-lifecycle-manager/test/e2e/ctx"
1213
"github.com/operator-framework/operator-lifecycle-manager/test/e2e/util"
@@ -31,6 +32,10 @@ var _ = Describe("CSV Namespace Labeler Plugin", func() {
3132
})
3233

3334
It("should not label non openshift- namespaces", func() {
35+
if !olm.IsPluginEnabled(olm.CsvLabelerPluginId) {
36+
Skip("csv labeler plugin is disabled")
37+
}
38+
3439
// create namespace with operator group
3540
testNamespace = SetupGeneratedTestNamespace(genName("csv-ns-labeler-"))
3641

@@ -46,6 +51,10 @@ var _ = Describe("CSV Namespace Labeler Plugin", func() {
4651
})
4752

4853
It("should label a non-payload openshift- namespace", func() {
54+
if !olm.IsPluginEnabled(olm.CsvLabelerPluginId) {
55+
Skip("csv labeler plugin is disabled")
56+
}
57+
4958
// create namespace with operator group
5059
testNamespace = SetupGeneratedTestNamespace(genName("openshift-csv-ns-labeler-"))
5160

@@ -61,6 +70,10 @@ var _ = Describe("CSV Namespace Labeler Plugin", func() {
6170
})
6271

6372
It("should relabel a non-payload openshift- namespace containing csvs if the label is deleted", func() {
73+
if !olm.IsPluginEnabled(olm.CsvLabelerPluginId) {
74+
Skip("csv labeler plugin is disabled")
75+
}
76+
6477
// create namespace with operator group
6578
testNamespace = SetupGeneratedTestNamespace(genName("openshift-csv-ns-labeler-"))
6679

vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/olm/downstream_csv_labeler.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/olm/downstream_plugins.go

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/olm/operator.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/olm/plugins/operator_plugin.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)