MCPcopy
hub / github.com/dapr/dapr / Start

Method Start

pkg/operator/operator.go:223–333  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

221}
222
223func (o *operator) Start(ctx context.Context) error {
224 log.Info("Dapr Operator is starting")
225
226 /*
227 Make sure to set `ENABLE_WEBHOOKS=false` when we run locally.
228 */
229 enableConversionWebhooks := !strings.EqualFold(os.Getenv("ENABLE_WEBHOOKS"), "false")
230 if enableConversionWebhooks {
231 err := ctrl.NewWebhookManagedBy(o.mgr).
232 For(&subscriptionsapiV1alpha1.Subscription{}).
233 Complete()
234 if err != nil {
235 return fmt.Errorf("unable to create webhook Subscriptions v1alpha1: %w", err)
236 }
237 err = ctrl.NewWebhookManagedBy(o.mgr).
238 For(&subapi.Subscription{}).
239 Complete()
240 if err != nil {
241 return fmt.Errorf("unable to create webhook Subscriptions v2alpha1: %w", err)
242 }
243 }
244
245 caBundleCh := make(chan []byte)
246
247 runner := concurrency.NewRunnerManager(
248 o.secProvider.Run,
249 func(ctx context.Context) error {
250 // Wait for webhook certificates to be ready before starting the manager.
251 _, rErr := o.secProvider.Handler(ctx)
252 if rErr != nil {
253 return rErr
254 }
255 o.secHealthz.Ready()
256 return o.mgr.Start(ctx)
257 },
258 func(ctx context.Context) error {
259 if rErr := o.apiServer.Ready(ctx); rErr != nil {
260 return fmt.Errorf("API server did not become ready in time: %w", rErr)
261 }
262 o.apiServerHealthz.Ready()
263 log.Infof("Dapr Operator started")
264 <-ctx.Done()
265 return nil
266 },
267 func(ctx context.Context) error {
268 if !enableConversionWebhooks {
269 <-ctx.Done()
270 return nil
271 }
272 sec, rErr := o.secProvider.Handler(ctx)
273 if rErr != nil {
274 return rErr
275 }
276 sec.WatchTrustAnchors(ctx, caBundleCh)
277 return nil
278 },
279 func(ctx context.Context) error {
280 if !enableConversionWebhooks {

Callers

nothing calls this directly

Calls 15

ErrorfMethod · 0.80
InfofMethod · 0.80
GetConfigMethod · 0.80
GetCacheMethod · 0.80
ErrMethod · 0.80
HandlerMethod · 0.65
ReadyMethod · 0.65
StartMethod · 0.65
WatchTrustAnchorsMethod · 0.65
CurrentTrustAnchorsMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected