Skip to content

Commit 1264b81

Browse files
committed
Add olm operator plug-in framework
Signed-off-by: perdasilva <[email protected]> Upstream-repository: perdasilva Upstream-commit: 0b015f83409cc1513668d1820051168cc3f2f0f9
1 parent a1f2f4b commit 1264b81

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ var (
6060
ErrAPIServiceOwnerConflict = errors.New("unable to adopt APIService")
6161
)
6262

63+
// this unexported operator plugin slice provides and entrypoint for
64+
// downstream to inject its own plugins to augment the controller behavior
65+
var operatorPlugIns []OperatorPlugin
66+
6367
type Operator struct {
6468
queueinformer.Operator
6569

@@ -90,6 +94,7 @@ type Operator struct {
9094
clientAttenuator *scoped.ClientAttenuator
9195
serviceAccountQuerier *scoped.UserDefinedServiceAccountQuerier
9296
clientFactory clients.Factory
97+
plugins []OperatorPlugin
9398
}
9499

95100
func NewOperator(ctx context.Context, options ...OperatorOption) (*Operator, error) {
@@ -147,6 +152,7 @@ func newOperatorWithConfig(ctx context.Context, config *operatorConfig) (*Operat
147152
serviceAccountQuerier: scoped.NewUserDefinedServiceAccountQuerier(config.logger, config.externalClient),
148153
clientFactory: clients.NewFactory(config.restConfig),
149154
protectedCopiedCSVNamespaces: config.protectedCopiedCSVNamespaces,
155+
plugins: operatorPlugIns,
150156
}
151157

152158
// Set up syncing for namespace-scoped resources
@@ -587,6 +593,13 @@ func newOperatorWithConfig(ctx context.Context, config *operatorConfig) (*Operat
587593
OverridesBuilderFunc: overridesBuilderFunc.GetDeploymentInitializer,
588594
}
589595

596+
// initialize plugins
597+
for _, plugin := range op.plugins {
598+
if err := plugin.Init(ctx, config, op); err != nil {
599+
return nil, fmt.Errorf("error initializing plugin: %s", err)
600+
}
601+
}
602+
590603
return op, nil
591604
}
592605

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package olm
2+
3+
import "context"
4+
5+
// OperatorPlugin provides a simple interface
6+
// that can be used to extend the olm operator's functionality
7+
type OperatorPlugin interface {
8+
Init(ctx context.Context, config *operatorConfig, operator *Operator) error
9+
}

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

Lines changed: 13 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/operator_plugin.go

Lines changed: 9 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)