Skip to content

Commit

Permalink
Add a new Reconciler option SkipSchemeSetup, which can be used by u…
Browse files Browse the repository at this point in the history
…sers who prefer their

custom scheme setup over the generic scheme setup currently being done by the reconciler.

Signed-off-by: Moritz Clasmeier <moritz@stackrox.com>
  • Loading branch information
mtesseract committed Feb 7, 2022
1 parent 0d534ef commit 41c90f5
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pkg/reconciler/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ type Reconciler struct {
maxConcurrentReconciles int
reconcilePeriod time.Duration
maxHistory int
skipSchemeSetup bool

annotSetupOnce sync.Once
annotations map[string]struct{}
Expand Down Expand Up @@ -131,7 +132,9 @@ func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
controllerName := fmt.Sprintf("%v-controller", strings.ToLower(r.gvk.Kind))

r.addDefaults(mgr, controllerName)
r.setupScheme(mgr)
if !r.skipSchemeSetup {
r.setupScheme(mgr)
}

c, err := controller.New(controllerName, mgr, controller.Options{Reconciler: r, MaxConcurrentReconciles: r.maxConcurrentReconciles})
if err != nil {
Expand Down Expand Up @@ -257,6 +260,17 @@ func SkipDependentWatches(skip bool) Option {
}
}

// SkipSchemeSetup is an Option that configures whether the the Manager's
// Scheme is to be set up in a generic way as part of the Reconciler setup.
//
// By default, skipping of the scheme setup is disabled.
func SkipSchemeSetup(skip bool) Option {
return func(r *Reconciler) error {
r.skipSchemeSetup = skip
return nil
}
}

// WithMaxConcurrentReconciles is an Option that configures the number of
// concurrent reconciles that the controller will run.
//
Expand Down

0 comments on commit 41c90f5

Please sign in to comment.