Skip to content

Commit

Permalink
Refactor Submariner controller start logic
Browse files Browse the repository at this point in the history
to match the new framework criteria.

Signed-off-by: Janki Chhatbar <[email protected]>
  • Loading branch information
Jaanki authored and skitt committed Aug 25, 2022
1 parent 1952e1e commit 72d91fd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 53 deletions.
44 changes: 0 additions & 44 deletions controllers/controllers.go

This file was deleted.

28 changes: 19 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ import (
"os"
"runtime"

operatorclient "github.com/openshift/cluster-dns-operator/pkg/operator/client"
"github.com/operator-framework/operator-lib/leader"
"github.com/operator-framework/operator-sdk/pkg/k8sutil"
kubemetrics "github.com/operator-framework/operator-sdk/pkg/kube-metrics"
sdkVersion "github.com/operator-framework/operator-sdk/version"
"github.com/pkg/errors"
"github.com/submariner-io/admiral/pkg/log/kzerolog"
"github.com/submariner-io/submariner-operator/api/v1alpha1"
"github.com/submariner-io/submariner-operator/controllers"
"github.com/submariner-io/submariner-operator/controllers/servicediscovery"
"github.com/submariner-io/submariner-operator/controllers/submariner"
"github.com/submariner-io/submariner-operator/pkg/crd"
Expand All @@ -47,6 +47,7 @@ import (
apiruntime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/intstr"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
_ "k8s.io/client-go/plugin/pkg/client/auth"
Expand Down Expand Up @@ -159,14 +160,6 @@ func main() {
os.Exit(1)
}

log.Info("Registering Components.")

// Setup all Controllers
if err := controllers.AddToManager(mgr); err != nil {
log.Error(err, "")
os.Exit(1)
}

if err = serveCRMetrics(cfg); err != nil {
log.Info("Could not generate and serve custom resource metrics", "error", err.Error())
}
Expand All @@ -185,13 +178,30 @@ func main() {

createServiceMonitors(ctx, cfg, servicePorts, namespace)

log.Info("Registering Components.")

// Setup all Controllers
if err = (&submariner.BrokerReconciler{
Client: mgr.GetClient(),
Config: mgr.GetConfig(),
}).SetupWithManager(mgr); err != nil {
log.Error(err, "unable to create controller", "controller", "Broker")
os.Exit(1)
}

generalClient, _ := operatorclient.NewClient(mgr.GetConfig())

if err = submariner.NewReconciler(&submariner.Config{
ScopedClient: mgr.GetClient(),
GeneralClient: generalClient,
RestConfig: mgr.GetConfig(),
Scheme: mgr.GetScheme(),
DynClient: dynamic.NewForConfigOrDie(mgr.GetConfig()),
}).SetupWithManager(mgr); err != nil {
log.Error(err, "unable to create controller", "controller", "Submariner")
os.Exit(1)
}

if err = (&servicediscovery.Reconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Expand Down

0 comments on commit 72d91fd

Please sign in to comment.