Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Commit

Permalink
don't bother watching if we would never pass the predicates
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Morsing committed Sep 24, 2019
1 parent b8d4204 commit 7d66c77
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pkg/controller/gittrackobject/gittrackobject_controller.go
Expand Up @@ -113,17 +113,20 @@ func add(mgr manager.Manager, r reconcile.Reconciler, opts *reconcileGitTrackObj
}

// Watch for changes to GitTrackObject
predicate := []predicate.Predicate(nil)
var predicate []predicate.Predicate
if opts.clusterGitTrackMode == farosflags.CGTMExcludeNamespaced {
predicate = append(predicate, utils.NewOwnerIsNotClusterGitTrackPredicate(mgr.GetClient()))
}
if opts.gitTrackMode == farosflags.GTMDisabled {
predicate = append(predicate, utils.NewOwnerIsNotGitTrackPredicate(mgr.GetClient()))
}

err = c.Watch(&source.Kind{Type: &farosv1alpha1.GitTrackObject{}}, &handler.EnqueueRequestForObject{}, predicate...)
if err != nil {
return err
// don't bother putting a watch on gittrackobjects if we are entirely disabled
if len(predicate) != 2 {
err = c.Watch(&source.Kind{Type: &farosv1alpha1.GitTrackObject{}}, &handler.EnqueueRequestForObject{}, predicate...)
if err != nil {
return err
}
}

if opts.clusterGitTrackMode != farosflags.CGTMDisabled {
Expand Down

0 comments on commit 7d66c77

Please sign in to comment.