MCPcopy Create free account
hub / github.com/devfile/devworkspace-operator / main

Function main

main.go:97–240  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

95}
96
97func main() {
98 var metricsAddr string
99 var enableLeaderElection bool
100 flag.StringVar(&metricsAddr, "metrics-addr", ":8443", "The address the metric endpoint binds to.")
101 flag.BoolVar(&enableLeaderElection, "enable-leader-election", false,
102 "Enable leader election for controller manager. "+
103 "Enabling this will ensure there is only one active controller manager.")
104 flag.Parse()
105
106 ctrl.SetLogger(zap.New(zap.UseDevMode(config.GetDevModeEnabled())))
107
108 // Print versions
109 setupLog.Info(fmt.Sprintf("Operator Version: %s", version.Version))
110 setupLog.Info(fmt.Sprintf("Go Version: %s", runtime.Version()))
111 setupLog.Info(fmt.Sprintf("Go OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH))
112 setupLog.Info(fmt.Sprintf("Commit: %s", version.Commit))
113 setupLog.Info(fmt.Sprintf("BuildTime: %s", version.BuildTime))
114
115 if err := kubesync.InitializeDeserializer(scheme); err != nil {
116 setupLog.Error(err, "failed to initialized Kubernetes objects decoder")
117 }
118
119 cacheFunc, err := cache.GetCacheFunc()
120 if err != nil {
121 setupLog.Error(err, "failed to set up objects cache")
122 os.Exit(1)
123 }
124
125 mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
126 Scheme: scheme,
127 Metrics: metricsserver.Options{
128 BindAddress: metricsAddr,
129 FilterProvider: filters.WithAuthenticationAndAuthorization,
130 SecureServing: true,
131 },
132 WebhookServer: ctrl_webhook.NewServer(ctrl_webhook.Options{
133 Port: 9443,
134 }),
135 HealthProbeBindAddress: ":6789",
136 LeaderElection: enableLeaderElection,
137 LeaderElectionID: "8d217f93.devfile.io",
138 NewCache: cacheFunc,
139 })
140 if err != nil {
141 setupLog.Error(err, "unable to start manager")
142 os.Exit(1)
143 }
144 if err = setupControllerConfig(mgr); err != nil {
145 setupLog.Error(err, "unable to read controller configuration")
146 os.Exit(1)
147 }
148
149 nonCachingClient, err := client.New(mgr.GetConfig(), client.Options{Scheme: scheme})
150 if err != nil {
151 setupLog.Error(err, "unable to initialize non-caching client")
152 os.Exit(1)
153 }
154

Callers

nothing calls this directly

Calls 4

GetCacheFuncFunction · 0.92
setupControllerConfigFunction · 0.85
ErrorMethod · 0.45
SetupWithManagerMethod · 0.45

Tested by

no test coverage detected