MCPcopy Create free account
hub / github.com/coderanger/migrations-operator / main

Function main

main.go:52–96  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

50}
51
52func main() {
53 var metricsAddr string
54 var enableLeaderElection bool
55 flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.")
56 flag.BoolVar(&enableLeaderElection, "enable-leader-election", false,
57 "Enable leader election for controller manager. "+
58 "Enabling this will ensure there is only one active controller manager.")
59 flag.Parse()
60
61 ctrl.SetLogger(zap.New(zap.UseDevMode(true)))
62
63 mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
64 Scheme: scheme,
65 MetricsBindAddress: metricsAddr,
66 Port: 9443,
67 LeaderElection: enableLeaderElection,
68 LeaderElectionID: "8aa440e1.coderanger.net",
69 })
70 if err != nil {
71 setupLog.Error(err, "unable to start manager")
72 os.Exit(1)
73 }
74
75 controllers := []func(ctrl.Manager) error{
76 controllers.Migrator,
77 webhook.InitInjector,
78 http.APIServer,
79 }
80
81 for _, controller := range controllers {
82 err = controller(mgr)
83 if err != nil {
84 // TODO Don't use relect.
85 name := goruntime.FuncForPC(reflect.ValueOf(controller).Pointer()).Name()
86 setupLog.Error(err, "unable to create controller", "controller", name)
87 os.Exit(1)
88 }
89 }
90
91 setupLog.Info("starting manager")
92 if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
93 setupLog.Error(err, "problem running manager")
94 os.Exit(1)
95 }
96}

Callers

nothing calls this directly

Calls 1

StartMethod · 0.80

Tested by

no test coverage detected