Skip to content

Commit

Permalink
Reduce the indirection by directly referencing controllers (#694)
Browse files Browse the repository at this point in the history
  • Loading branch information
alenkacz authored Aug 13, 2019
1 parent 6fab360 commit eddf74b
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 107 deletions.
2 changes: 1 addition & 1 deletion cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func main() {

// Setup all Controllers
log.Info("Setting up controller")
if err := controller.AddToManager(mgr); err != nil {
if err := controller.AddControllersToManager(mgr); err != nil {
log.Error(err, "unable to register controllers to the manager")
os.Exit(1)
}
Expand Down
25 changes: 0 additions & 25 deletions pkg/controller/add_instance.go

This file was deleted.

25 changes: 0 additions & 25 deletions pkg/controller/add_operator.go

This file was deleted.

25 changes: 0 additions & 25 deletions pkg/controller/add_operatorversion.go

This file was deleted.

25 changes: 0 additions & 25 deletions pkg/controller/add_planexecution.go

This file was deleted.

19 changes: 14 additions & 5 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,24 @@ limitations under the License.
package controller

import (
"github.com/kudobuilder/kudo/pkg/controller/instance"
"github.com/kudobuilder/kudo/pkg/controller/operator"
"github.com/kudobuilder/kudo/pkg/controller/operatorversion"
"github.com/kudobuilder/kudo/pkg/controller/planexecution"
"sigs.k8s.io/controller-runtime/pkg/manager"
)

// AddToManagerFuncs is a list of functions to add all Controllers to the Manager
var AddToManagerFuncs []func(manager.Manager) error
// AddControllerToManagerFuncs is a list of functions to add all Controllers to the Manager
var AddControllerToManagerFuncs = []func(manager.Manager) error{
planexecution.Add,
instance.Add,
operator.Add,
operatorversion.Add,
}

// AddToManager adds all Controllers to the Manager
func AddToManager(m manager.Manager) error {
for _, f := range AddToManagerFuncs {
// AddControllersToManager adds all Controllers to the Manager
func AddControllersToManager(m manager.Manager) error {
for _, f := range AddControllerToManagerFuncs {
if err := f(m); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/test/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func (h *Harness) RunKUDO() error {
return err
}

if err = controller.AddToManager(mgr); err != nil {
if err = controller.AddControllersToManager(mgr); err != nil {
return err
}

Expand Down

0 comments on commit eddf74b

Please sign in to comment.