@@ -16,6 +16,7 @@ import (
1616 operatorv1 "github.com/openshift/api/operator/v1"
1717 routev1 "github.com/openshift/api/route/v1"
1818 configv1listers "github.com/openshift/client-go/config/listers/config/v1"
19+ oauthinformers "github.com/openshift/client-go/oauth/informers/externalversions"
1920 applyoperatorv1 "github.com/openshift/client-go/operator/applyconfigurations/operator/v1"
2021 operatorv1listers "github.com/openshift/client-go/operator/listers/operator/v1"
2122 "github.com/openshift/cluster-authentication-operator/bindata"
@@ -28,6 +29,7 @@ import (
2829 "github.com/openshift/cluster-authentication-operator/pkg/controllers/ingressstate"
2930 "github.com/openshift/cluster-authentication-operator/pkg/controllers/metadata"
3031 "github.com/openshift/cluster-authentication-operator/pkg/controllers/oauthclientscontroller"
32+ "github.com/openshift/cluster-authentication-operator/pkg/controllers/oauthclientsswitchedinformer"
3133 "github.com/openshift/cluster-authentication-operator/pkg/controllers/oauthendpoints"
3234 "github.com/openshift/cluster-authentication-operator/pkg/controllers/payload"
3335 "github.com/openshift/cluster-authentication-operator/pkg/controllers/proxyconfig"
@@ -41,6 +43,7 @@ import (
4143 "github.com/openshift/cluster-authentication-operator/pkg/operator/workload"
4244 "github.com/openshift/library-go/pkg/authentication/bootstrapauthenticator"
4345 "github.com/openshift/library-go/pkg/controller/controllercmd"
46+ "github.com/openshift/library-go/pkg/controller/factory"
4447 workloadcontroller "github.com/openshift/library-go/pkg/operator/apiserver/controller/workload"
4548 apiservercontrollerset "github.com/openshift/library-go/pkg/operator/apiserver/controllerset"
4649 "github.com/openshift/library-go/pkg/operator/certrotation"
@@ -256,10 +259,25 @@ func prepareOauthOperator(
256259 authOperatorInput .eventRecorder ,
257260 )
258261
262+ oauthClientsSwitchedInformer := oauthclientsswitchedinformer .NewSwitchedInformer (
263+ "OAuthClientsInformerWithSwitchController" ,
264+ ctx ,
265+ func () (bool , error ) {
266+ return common .ExternalOIDCConfigAvailable (authLister , kasLister , kasConfigMapLister )
267+ },
268+ oauthinformers .NewSharedInformerFactoryWithOptions (authOperatorInput .oauthClient , 1 * time .Minute ).Oauth ().V1 ().OAuthClients ().Informer (),
269+ 0 ,
270+ []factory.Informer {
271+ informerFactories .operatorInformer .Operator ().V1 ().KubeAPIServers ().Informer (),
272+ informerFactories .operatorConfigInformer .Config ().V1 ().Authentications ().Informer (),
273+ },
274+ authOperatorInput .eventRecorder ,
275+ )
276+
259277 oauthClientsController := oauthclientscontroller .NewOAuthClientsController (
260278 authOperatorInput .authenticationOperatorClient ,
261279 authOperatorInput .oauthClient .OauthV1 ().OAuthClients (),
262- informerFactories . oauthInformers ,
280+ oauthClientsSwitchedInformer ,
263281 informerFactories .namespacedOpenshiftAuthenticationRoutes ,
264282 informerFactories .operatorConfigInformer ,
265283 informerFactories .operatorInformer .Operator ().V1 ().KubeAPIServers (),
@@ -386,6 +404,7 @@ func prepareOauthOperator(
386404 libraryapplyconfiguration .AdaptSyncFn (authOperatorInput .eventRecorder , "TODO-deploymentController" , deploymentController .Sync ),
387405 libraryapplyconfiguration .AdaptSyncFn (authOperatorInput .eventRecorder , "TODO-managementStateController" , managementStateController .Sync ),
388406 libraryapplyconfiguration .AdaptSyncFn (authOperatorInput .eventRecorder , "TODO-metadataController" , metadataController .Sync ),
407+ libraryapplyconfiguration .AdaptSyncFn (authOperatorInput .eventRecorder , "TODO-oauthClientsSwitchedInformerController" , oauthClientsSwitchedInformer .Controller ().Sync ),
389408 libraryapplyconfiguration .AdaptSyncFn (authOperatorInput .eventRecorder , "TODO-oauthClientsController" , oauthClientsController .Sync ),
390409 libraryapplyconfiguration .AdaptSyncFn (authOperatorInput .eventRecorder , "TODO-payloadConfigController" , payloadConfigController .Sync ),
391410 libraryapplyconfiguration .AdaptSyncFn (authOperatorInput .eventRecorder , "TODO-routerCertsController" , routerCertsController .Sync ),
@@ -408,6 +427,7 @@ func prepareOauthOperator(
408427 libraryapplyconfiguration .AdaptRunFn (deploymentController .Run ),
409428 libraryapplyconfiguration .AdaptRunFn (managementStateController .Run ),
410429 libraryapplyconfiguration .AdaptRunFn (metadataController .Run ),
430+ libraryapplyconfiguration .AdaptRunFn (oauthClientsSwitchedInformer .Controller ().Run ),
411431 libraryapplyconfiguration .AdaptRunFn (oauthClientsController .Run ),
412432 libraryapplyconfiguration .AdaptRunFn (payloadConfigController .Run ),
413433 libraryapplyconfiguration .AdaptRunFn (routerCertsController .Run ),
0 commit comments