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

Remove constructor interface #652

Merged
merged 2 commits into from
Apr 13, 2018
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
20 changes: 8 additions & 12 deletions cmd/ela-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,14 @@ func main() {
if err != nil {
glog.Fatalf("Error loading controller config: %v", err)
}
// Add new controllers here.
ctors := []controller.Constructor{
configuration.NewController,
revision.NewController,
route.NewController,
service.NewController,
}

// Build all of our controllers, with the clients constructed above.
controllers := make([]controller.Interface, 0, len(ctors))
for _, ctor := range ctors {
controllers = append(controllers, ctor(kubeClient, elaClient, kubeInformerFactory, elaInformerFactory, cfg, *controllerConfig))
// Add new controllers to this array.
controllers := []controller.Interface{
configuration.NewController(kubeClient, elaClient, kubeInformerFactory, elaInformerFactory, cfg, *controllerConfig),
revision.NewController(kubeClient, elaClient, kubeInformerFactory, elaInformerFactory, cfg, *controllerConfig),
route.NewController(kubeClient, elaClient, kubeInformerFactory, elaInformerFactory, cfg, *controllerConfig),
service.NewController(kubeClient, elaClient, kubeInformerFactory, elaInformerFactory, cfg, *controllerConfig),
}

go kubeInformerFactory.Start(stopCh)
Expand All @@ -103,8 +99,8 @@ func main() {
go func(ctrlr controller.Interface) {
// We don't expect this to return until stop is called,
// but if it does, propagate it back.
if err := ctrlr.Run(threadsPerController, stopCh); err != nil {
glog.Fatalf("Error running controller: %v", err)
if runErr := ctrlr.Run(threadsPerController, stopCh); runErr != nil {
glog.Fatalf("Error running controller: %v", runErr)
}
}(ctrlr)
}
Expand Down
7 changes: 0 additions & 7 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,15 @@ limitations under the License.
package controller

import (
kubeinformers "k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"

clientset "github.com/elafros/elafros/pkg/client/clientset/versioned"
elascheme "github.com/elafros/elafros/pkg/client/clientset/versioned/scheme"
informers "github.com/elafros/elafros/pkg/client/informers/externalversions"
)

type Interface interface {
Run(threadiness int, stopCh <-chan struct{}) error
}

type Constructor func(kubernetes.Interface, clientset.Interface, kubeinformers.SharedInformerFactory, informers.SharedInformerFactory, *rest.Config, Config) Interface

func init() {
// Add ela types to the default Kubernetes Scheme so Events can be
// logged for ela types.
Expand Down