// New returns a new controller that publishes a "router-certs" secret in the
// openshift-config-managed namespace with all in-use default certificates.
New returns a new controller that publishes a "router-certs" secret in the
openshift-config-managed namespace with all in-use default certificates.
// New returns a new controller that publishes a " router - certs " secret in the // openshift - config - managed namespace with all in - use default certificates .
func New(mgr manager.Manager, operatorNamespace, operandNamespace string) (runtimecontroller.Controller, error) {
	operatorCache := mgr.GetCache()
	reconciler := &reconciler{
		client:            mgr.GetClient(),
		cache:             operatorCache,
		recorder:          mgr.GetEventRecorderFor(controllerName),
		operatorNamespace: operatorNamespace,
		operandNamespace:  operandNamespace,
	}
	c, err := runtimecontroller.New(controllerName, mgr, runtimecontroller.Options{Reconciler: reconciler})
	if err != nil {
		return nil, err
	}
	if err := operatorCache.IndexField(&operatorv1.IngressController{}, "defaultCertificateName", func(o runtime.Object) []string {
		secret := controller.RouterEffectiveDefaultCertificateSecretName(o.(*operatorv1.IngressController), operandNamespace)
		return []string{secret.Name}
	}); err != nil {
		return nil, fmt.Errorf("failed to create index for ingresscontroller: %v", err)
	}
	secretsInformer, err := operatorCache.GetInformer(&corev1.Secret{})
	if err != nil {
		return nil, fmt.Errorf("failed to create informer for secrets: %v", err)
	}
	if err := c.Watch(&source.Informer{Informer: secretsInformer}, &handler.EnqueueRequestsFromMapFunc{ToRequests: handler.ToRequestsFunc(reconciler.secretToIngressController)}, predicate.Funcs{
		CreateFunc:  func(e event.CreateEvent) bool { return reconciler.secretIsInUse(e.Meta) },
		DeleteFunc:  func(e event.DeleteEvent) bool { return reconciler.secretIsInUse(e.Meta) },
		UpdateFunc:  func(e event.UpdateEvent) bool { return reconciler.secretIsInUse(e.MetaNew) },
		GenericFunc: func(e event.GenericEvent) bool { return reconciler.secretIsInUse(e.Meta) },
	}); err != nil {
		return nil, err
	}
	if err := c.Watch(&source.Kind{Type: &operatorv1.IngressController{}}, &handler.EnqueueRequestForObject{}, predicate.Funcs{
		CreateFunc:  func(e event.CreateEvent) bool { return reconciler.hasSecret(e.Meta, e.Object) },
		DeleteFunc:  func(e event.DeleteEvent) bool { return reconciler.hasSecret(e.Meta, e.Object) },
		UpdateFunc:  func(e event.UpdateEvent) bool { return reconciler.secretChanged(e.ObjectOld, e.ObjectNew) },
		GenericFunc: func(e event.GenericEvent) bool { return reconciler.hasSecret(e.Meta, e.Object) },
	}); err != nil {
		return nil, err
	}
	return c, nil
}
func New ( mgr manager . Manager , operatorNamespace , operandNamespace string ) ( runtimecontroller . Controller , error ) { operatorCache := mgr . GetCache ( ) reconciler := & reconciler { client : mgr . GetClient ( ) , cache : operatorCache , recorder : mgr . GetEventRecorderFor ( controllerName ) , operatorNamespace : operatorNamespace , operandNamespace : operandNamespace , } c , err := runtimecontroller . New ( controllerName , mgr , runtimecontroller . Options { Reconciler : reconciler } ) if err != nil { return nil , err } if err := operatorCache . IndexField ( & operatorv1 . IngressController { } , " " , func ( o runtime . Object ) [ ] string { secret := controller . RouterEffectiveDefaultCertificateSecretName ( o . ( * operatorv1 . IngressController ) , operandNamespace ) return [ ] string { secret . Name } } ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } secretsInformer , err := operatorCache . GetInformer ( & corev1 . Secret { } ) if err != nil { return nil , fmt . Errorf ( " " , err ) } if err := c . Watch ( & source . Informer { Informer : secretsInformer } , & handler . EnqueueRequestsFromMapFunc { ToRequests : handler . ToRequestsFunc ( reconciler . secretToIngressController ) } , predicate . Funcs { CreateFunc : func ( e event . CreateEvent ) bool { return reconciler . secretIsInUse ( e . Meta ) } , DeleteFunc : func ( e event . DeleteEvent ) bool { return reconciler . secretIsInUse ( e . Meta ) } , UpdateFunc : func ( e event . UpdateEvent ) bool { return reconciler . secretIsInUse ( e . MetaNew ) } , GenericFunc : func ( e event . GenericEvent ) bool { return reconciler . secretIsInUse ( e . Meta ) } , } ) ; err != nil { return nil , err } if err := c . Watch ( & source . Kind { Type : & operatorv1 . IngressController { } } , & handler . EnqueueRequestForObject { } , predicate . Funcs { CreateFunc : func ( e event . CreateEvent ) bool { return reconciler . hasSecret ( e . Meta , e . Object ) } , DeleteFunc : func ( e event . DeleteEvent ) bool { return reconciler . hasSecret ( e . Meta , e . Object ) } , UpdateFunc : func ( e event . UpdateEvent ) bool { return reconciler . secretChanged ( e . ObjectOld , e . ObjectNew ) } , GenericFunc : func ( e event . GenericEvent ) bool { return reconciler . hasSecret ( e . Meta , e . Object ) } , } ) ; err != nil { return nil , err } return c , nil }
New returns a new controller that publishes a "router-certs" secret in the
openshift-config-managed namespace with all in-use default certificates.
New returns a new controller that publishes a " router - certs " secret in the openshift - config - managed namespace with all in - use default certificates .
// Index ingresscontrollers over the default certificate name so that // secretIsInUse and secretToIngressController can look up // ingresscontrollers that reference the secret.