Skip to content

Commit

Permalink
Register machine actuator to the manager directly
Browse files Browse the repository at this point in the history
Given there is only one actuator to register, the registration
can be done directly without any mediator.
  • Loading branch information
ingvagabund committed Jan 7, 2019
1 parent 745593e commit 50de33e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 72 deletions.
22 changes: 14 additions & 8 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ package main

import (
"flag"
"fmt"

"github.com/golang/glog"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
machineactuator "sigs.k8s.io/cluster-api-provider-aws/pkg/actuators/machine"
"sigs.k8s.io/cluster-api-provider-aws/pkg/apis"
"sigs.k8s.io/cluster-api-provider-aws/pkg/apis/awsproviderconfig/v1alpha1"
awsclient "sigs.k8s.io/cluster-api-provider-aws/pkg/client"
"sigs.k8s.io/cluster-api-provider-aws/pkg/controller"
clusterapis "sigs.k8s.io/cluster-api/pkg/apis"
"sigs.k8s.io/cluster-api/pkg/controller/machine"
"sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/runtime/signals"
Expand Down Expand Up @@ -55,9 +56,12 @@ func main() {
glog.Fatal(err)
}

initActuator(mgr)
// Setup all Controllers
if err := controller.AddToManager(mgr); err != nil {
machineActuator, err := initActuator(mgr)
if err != nil {
glog.Fatal(err)
}

if err := machine.AddWithActuator(mgr, machineActuator); err != nil {
glog.Fatal(err)
}

Expand All @@ -67,10 +71,10 @@ func main() {
glog.Fatal(mgr.Start(signals.SetupSignalHandler()))
}

func initActuator(mgr manager.Manager) {
func initActuator(mgr manager.Manager) (*machineactuator.Actuator, error) {
codec, err := v1alpha1.NewCodec()
if err != nil {
glog.Fatal(err)
return nil, fmt.Errorf("unable to create codec: %v", err)
}

params := machineactuator.ActuatorParams{
Expand All @@ -80,8 +84,10 @@ func initActuator(mgr manager.Manager) {
EventRecorder: mgr.GetRecorder("aws-controller"),
}

machineactuator.MachineActuator, err = machineactuator.NewActuator(params)
actuator, err := machineactuator.NewActuator(params)
if err != nil {
glog.Fatalf("Could not create AWS machine actuator: %v", err)
return nil, fmt.Errorf("could not create AWS machine actuator: %v", err)
}

return actuator, nil
}
3 changes: 0 additions & 3 deletions pkg/actuators/machine/actuator.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ const (
MachineCreationFailed = "MachineCreationFailed"
)

// MachineActuator is a variable used to include the actuator into the machine controller
var MachineActuator *Actuator

// Actuator is the AWS-specific actuator for the Cluster API machine controller
type Actuator struct {
awsClientBuilder awsclient.AwsClientBuilderFuncType
Expand Down
27 changes: 0 additions & 27 deletions pkg/controller/add_machine.go

This file was deleted.

34 changes: 0 additions & 34 deletions pkg/controller/controller.go

This file was deleted.

0 comments on commit 50de33e

Please sign in to comment.