func StartControllers(ctx ControllerContext) error {
	if !config.Datadog.GetBool("admission_controller.enabled") {
		log.Info("Admission controller is disabled")
		return nil
	}

	certConfig := secret.NewCertConfig(
		config.Datadog.GetDuration("admission_controller.certificate.expiration_threshold")*time.Hour,
		config.Datadog.GetDuration("admission_controller.certificate.validity_bound")*time.Hour)
	secretConfig := secret.NewConfig(
		common.GetResourcesNamespace(),
		config.Datadog.GetString("admission_controller.certificate.secret_name"),
		config.Datadog.GetString("admission_controller.service_name"),
		certConfig)
	secretController := secret.NewController(
		ctx.Client,
		ctx.SecretInformers.Core().V1().Secrets(),
		ctx.IsLeaderFunc,
		secretConfig,
	)

	nsSelectorEnabled, err := useNamespaceSelector(ctx.DiscoveryClient)
	if err != nil {
		return err
	}

	v1Enabled, err := useAdmissionV1(ctx.DiscoveryClient)
	if err != nil {
		return err
	}

	webhookConfig := webhook.NewConfig(v1Enabled, nsSelectorEnabled)
	webhookController := webhook.NewController(
		ctx.Client,
		ctx.SecretInformers.Core().V1().Secrets(),
		ctx.WebhookInformers.Admissionregistration(),
		ctx.IsLeaderFunc,
		webhookConfig,
	)

	go secretController.Run(ctx.StopCh)
	go webhookController.Run(ctx.StopCh)

	ctx.SecretInformers.Start(ctx.StopCh)
	ctx.WebhookInformers.Start(ctx.StopCh)

	informers := map[apiserver.InformerName]cache.SharedInformer{
		apiserver.SecretsInformer: ctx.SecretInformers.Core().V1().Secrets().Informer(),
	}

	if v1Enabled {
		informers[apiserver.WebhooksInformer] = ctx.WebhookInformers.Admissionregistration().V1().MutatingWebhookConfigurations().Informer()
	} else {
		informers[apiserver.WebhooksInformer] = ctx.WebhookInformers.Admissionregistration().V1beta1().MutatingWebhookConfigurations().Informer()
	}

	return apiserver.SyncInformers(informers)
}
// StartControllers starts the secret and webhook controllers
StartControllers starts the secret and webhook controllers
// StartControllers starts the secret and webhook controllers
func StartControllers(ctx ControllerContext) error {
	if !config.Datadog.GetBool("admission_controller.enabled") {
		log.Info("Admission controller is disabled")
		return nil
	}
	certConfig := secret.NewCertConfig(
		config.Datadog.GetDuration("admission_controller.certificate.expiration_threshold")*time.Hour,
		config.Datadog.GetDuration("admission_controller.certificate.validity_bound")*time.Hour)
	secretConfig := secret.NewConfig(
		common.GetResourcesNamespace(),
		config.Datadog.GetString("admission_controller.certificate.secret_name"),
		config.Datadog.GetString("admission_controller.service_name"),
		certConfig)
	secretController := secret.NewController(
		ctx.Client,
		ctx.SecretInformers.Core().V1().Secrets(),
		ctx.IsLeaderFunc,
		secretConfig,
	)
	nsSelectorEnabled, err := useNamespaceSelector(ctx.DiscoveryClient)
	if err != nil {
		return err
	}
	v1Enabled, err := useAdmissionV1(ctx.DiscoveryClient)
	if err != nil {
		return err
	}
	webhookConfig := webhook.NewConfig(v1Enabled, nsSelectorEnabled)
	webhookController := webhook.NewController(
		ctx.Client,
		ctx.SecretInformers.Core().V1().Secrets(),
		ctx.WebhookInformers.Admissionregistration(),
		ctx.IsLeaderFunc,
		webhookConfig,
	)
	go secretController.Run(ctx.StopCh)
	go webhookController.Run(ctx.StopCh)
	ctx.SecretInformers.Start(ctx.StopCh)
	ctx.WebhookInformers.Start(ctx.StopCh)
	informers := map[apiserver.InformerName]cache.SharedInformer{
		apiserver.SecretsInformer: ctx.SecretInformers.Core().V1().Secrets().Informer(),
	}
	if v1Enabled {
		informers[apiserver.WebhooksInformer] = ctx.WebhookInformers.Admissionregistration().V1().MutatingWebhookConfigurations().Informer()
	} else {
		informers[apiserver.WebhooksInformer] = ctx.WebhookInformers.Admissionregistration().V1beta1().MutatingWebhookConfigurations().Informer()
	}
	return apiserver.SyncInformers(informers)
}
func StartControllers ( ctx ControllerContext ) error { if ! config . Datadog . GetBool ( " " ) { log . Info ( " " ) return nil } certConfig := secret . NewCertConfig ( config . Datadog . GetDuration ( " " ) * time . Hour , config . Datadog . GetDuration ( " " ) * time . Hour ) secretConfig := secret . NewConfig ( common . GetResourcesNamespace ( ) , config . Datadog . GetString ( " " ) , config . Datadog . GetString ( " " ) , certConfig ) secretController := secret . NewController ( ctx . Client , ctx . SecretInformers . Core ( ) . V1 ( ) . Secrets ( ) , ctx . IsLeaderFunc , secretConfig , ) nsSelectorEnabled , err := useNamespaceSelector ( ctx . DiscoveryClient ) if err != nil { return err } v1Enabled , err := useAdmissionV1 ( ctx . DiscoveryClient ) if err != nil { return err } webhookConfig := webhook . NewConfig ( v1Enabled , nsSelectorEnabled ) webhookController := webhook . NewController ( ctx . Client , ctx . SecretInformers . Core ( ) . V1 ( ) . Secrets ( ) , ctx . WebhookInformers . Admissionregistration ( ) , ctx . IsLeaderFunc , webhookConfig , ) go secretController . Run ( ctx . StopCh ) go webhookController . Run ( ctx . StopCh ) ctx . SecretInformers . Start ( ctx . StopCh ) ctx . WebhookInformers . Start ( ctx . StopCh ) informers := map [ apiserver . InformerName ] cache . SharedInformer { apiserver . SecretsInformer : ctx . SecretInformers . Core ( ) . V1 ( ) . Secrets ( ) . Informer ( ) , } if v1Enabled { informers [ apiserver . WebhooksInformer ] = ctx . WebhookInformers . Admissionregistration ( ) . V1 ( ) . MutatingWebhookConfigurations ( ) . Informer ( ) } else { informers [ apiserver . WebhooksInformer ] = ctx . WebhookInformers . Admissionregistration ( ) . V1beta1 ( ) . MutatingWebhookConfigurations ( ) . Informer ( ) } return apiserver . SyncInformers ( informers ) }
StartControllers starts the secret and webhook controllers
StartControllers starts the secret and webhook controllers