(ctx context.Context)
| 221 | } |
| 222 | |
| 223 | func (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 { |
nothing calls this directly
no test coverage detected