func CreateControllerContext(ctx context.Context, cfg *config.Config, kubeClientBuilder clientbuilder.ControllerClientBuilder) (ControllerContext, error) {

	versionedClient := kubeClientBuilder.ClientOrDie("shared-informers")
	sharedInformers := kubeInformer.NewSharedInformerFactory(versionedClient, ResyncPeriod(cfg)())

	// If apiserver is not running we should wait for some time and fail only then. This is particularly
	// important when we start apiserver and controller manager at the same time.
	if err := genericcontrollermanager.WaitForAPIServer(versionedClient, 10*time.Second); err != nil {
		return ControllerContext{}, fmt.Errorf("failed to wait for apiserver being healthy: %v", err)
	}

	// Use a discovery client capable of being refreshed.
	discoveryClient := kubeClientBuilder.DiscoveryClientOrDie("controller-discovery")
	cachedClient := cacheddiscovery.NewMemCacheClient(discoveryClient)
	restMapper := restmapper.NewDeferredDiscoveryRESTMapper(cachedClient)
	go wait.Until(func() {
		restMapper.Reset()
	}, 30*time.Second, ctx.Done())

	availableResources, err := GetAvailableResources(kubeClientBuilder)
	if err != nil {
		return ControllerContext{}, err
	}

	// create etcd informers
	etcdClient := etcdClientSet.NewForConfigOrDie(kubeClientBuilder.ConfigOrDie("kstone-etcd-operator"))
	etcdInformers := etcdInformer.NewSharedInformerFactory(etcdClient, ResyncPeriod(cfg)())

	// create TApp informers
	tappClient := tAppClientSet.NewForConfigOrDie(kubeClientBuilder.ConfigOrDie("kstone-etcd-operator"))
	tappInformers := tAppInformer.NewSharedInformerFactory(tappClient, ResyncPeriod(cfg)())

	controllerContext := ControllerContext{
		KubeClientBuilder:       kubeClientBuilder,
		KubeInformerFactory:     sharedInformers,
		EtcdInformerFactory:     etcdInformers,
		TAppInformerFactory:     tappInformers,
		Config:                  *cfg,
		RESTMapper:              restMapper,
		AvailableResources:      availableResources,
		InformersStarted:        make(chan struct{}),
		ResyncPeriod:            ResyncPeriod(cfg),
		ControllerStartInterval: cfg.Generic.ControllerStartInterval,
		TAppClient:              tappClient,
		EtcdClient:              etcdClient,
	}

	return controllerContext, nil
}
// CreateControllerContext creates a context struct containing references to resources needed by the controllers.
CreateControllerContext creates a context struct containing references to resources needed by the controllers.
// CreateControllerContext creates a context struct containing references to resources needed by the controllers .
func CreateControllerContext(ctx context.Context, cfg *config.Config, kubeClientBuilder clientbuilder.ControllerClientBuilder) (ControllerContext, error) {
	versionedClient := kubeClientBuilder.ClientOrDie("shared-informers")
	sharedInformers := kubeInformer.NewSharedInformerFactory(versionedClient, ResyncPeriod(cfg)())
	if err := genericcontrollermanager.WaitForAPIServer(versionedClient, 10*time.Second); err != nil {
		return ControllerContext{}, fmt.Errorf("failed to wait for apiserver being healthy: %v", err)
	}
	discoveryClient := kubeClientBuilder.DiscoveryClientOrDie("controller-discovery")
	cachedClient := cacheddiscovery.NewMemCacheClient(discoveryClient)
	restMapper := restmapper.NewDeferredDiscoveryRESTMapper(cachedClient)
	go wait.Until(func() {
		restMapper.Reset()
	}, 30*time.Second, ctx.Done())
	availableResources, err := GetAvailableResources(kubeClientBuilder)
	if err != nil {
		return ControllerContext{}, err
	}
	etcdClient := etcdClientSet.NewForConfigOrDie(kubeClientBuilder.ConfigOrDie("kstone-etcd-operator"))
	etcdInformers := etcdInformer.NewSharedInformerFactory(etcdClient, ResyncPeriod(cfg)())
	tappClient := tAppClientSet.NewForConfigOrDie(kubeClientBuilder.ConfigOrDie("kstone-etcd-operator"))
	tappInformers := tAppInformer.NewSharedInformerFactory(tappClient, ResyncPeriod(cfg)())
	controllerContext := ControllerContext{
		KubeClientBuilder:       kubeClientBuilder,
		KubeInformerFactory:     sharedInformers,
		EtcdInformerFactory:     etcdInformers,
		TAppInformerFactory:     tappInformers,
		Config:                  *cfg,
		RESTMapper:              restMapper,
		AvailableResources:      availableResources,
		InformersStarted:        make(chan struct{}),
		ResyncPeriod:            ResyncPeriod(cfg),
		ControllerStartInterval: cfg.Generic.ControllerStartInterval,
		TAppClient:              tappClient,
		EtcdClient:              etcdClient,
	}
	return controllerContext, nil
}
func CreateControllerContext ( ctx context . Context , cfg * config . Config , kubeClientBuilder clientbuilder . ControllerClientBuilder ) ( ControllerContext , error ) { versionedClient := kubeClientBuilder . ClientOrDie ( " " ) sharedInformers := kubeInformer . NewSharedInformerFactory ( versionedClient , ResyncPeriod ( cfg ) ( ) ) if err := genericcontrollermanager . WaitForAPIServer ( versionedClient , 10 * time . Second ) ; err != nil { return ControllerContext { } , fmt . Errorf ( " " , err ) } discoveryClient := kubeClientBuilder . DiscoveryClientOrDie ( " " ) cachedClient := cacheddiscovery . NewMemCacheClient ( discoveryClient ) restMapper := restmapper . NewDeferredDiscoveryRESTMapper ( cachedClient ) go wait . Until ( func ( ) { restMapper . Reset ( ) } , 30 * time . Second , ctx . Done ( ) ) availableResources , err := GetAvailableResources ( kubeClientBuilder ) if err != nil { return ControllerContext { } , err } etcdClient := etcdClientSet . NewForConfigOrDie ( kubeClientBuilder . ConfigOrDie ( " " ) ) etcdInformers := etcdInformer . NewSharedInformerFactory ( etcdClient , ResyncPeriod ( cfg ) ( ) ) tappClient := tAppClientSet . NewForConfigOrDie ( kubeClientBuilder . ConfigOrDie ( " " ) ) tappInformers := tAppInformer . NewSharedInformerFactory ( tappClient , ResyncPeriod ( cfg ) ( ) ) controllerContext := ControllerContext { KubeClientBuilder : kubeClientBuilder , KubeInformerFactory : sharedInformers , EtcdInformerFactory : etcdInformers , TAppInformerFactory : tappInformers , Config : * cfg , RESTMapper : restMapper , AvailableResources : availableResources , InformersStarted : make ( chan struct { } ) , ResyncPeriod : ResyncPeriod ( cfg ) , ControllerStartInterval : cfg . Generic . ControllerStartInterval , TAppClient : tappClient , EtcdClient : etcdClient , } return controllerContext , nil }
CreateControllerContext creates a context struct containing references to resources needed by the controllers.
CreateControllerContext creates a context struct containing references to resources needed by the controllers .
// If apiserver is not running we should wait for some time and fail only then. This is particularly // important when we start apiserver and controller manager at the same time. // Use a discovery client capable of being refreshed. // create etcd informers // create TApp informers