Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce the indirection by directly referencing controllers #694

Merged
merged 1 commit into from
Aug 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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