@@ -63,7 +63,6 @@ type oauthClientsController struct {
63
63
targetNSConfigLister corev1listers.ConfigMapLister
64
64
featureGatesLister configv1lister.FeatureGateLister
65
65
66
- statusHandler status.StatusHandler
67
66
authStatusHandler status.AuthStatusHandler
68
67
}
69
68
@@ -103,7 +102,6 @@ func NewOAuthClientsController(
103
102
targetNSDeploymentsLister : targetNSDeploymentsInformer .Lister (),
104
103
featureGatesLister : featureGatesInformer .Lister (),
105
104
106
- statusHandler : status .NewStatusHandler (operatorClient ),
107
105
authStatusHandler : status .NewAuthStatusHandler (authentication , api .OpenShiftConsoleName , api .TargetNamespace , api .OpenShiftConsoleOperator ),
108
106
}
109
107
@@ -128,6 +126,8 @@ func NewOAuthClientsController(
128
126
}
129
127
130
128
func (c * oauthClientsController ) sync (ctx context.Context , controllerContext factory.SyncContext ) error {
129
+ statusHandler := status .NewStatusHandler (c .operatorClient )
130
+
131
131
if shouldSync , err := c .handleManaged (ctx ); err != nil {
132
132
return err
133
133
} else if ! shouldSync {
@@ -176,36 +176,43 @@ func (c *oauthClientsController) sync(ctx context.Context, controllerContext fac
176
176
}
177
177
178
178
clientSecret , secErr := c .syncSecret (ctx , operatorConfig , controllerContext .Recorder ())
179
- c . statusHandler .AddConditions (status .HandleProgressingOrDegraded ("OAuthClientSecretSync" , "FailedApply" , secErr ))
179
+ statusHandler .AddConditions (status .HandleProgressingOrDegraded ("OAuthClientSecretSync" , "FailedApply" , secErr ))
180
180
if secErr != nil {
181
181
syncErr = secErr
182
182
break
183
183
}
184
184
185
185
oauthErrReason , oauthErr := c .syncOAuthClient (ctx , clientSecret , consoleURL .String ())
186
- c . statusHandler .AddConditions (status .HandleProgressingOrDegraded ("OAuthClientSync" , oauthErrReason , oauthErr ))
186
+ statusHandler .AddConditions (status .HandleProgressingOrDegraded ("OAuthClientSync" , oauthErrReason , oauthErr ))
187
187
if oauthErr != nil {
188
188
syncErr = oauthErr
189
189
break
190
190
}
191
191
192
192
case configv1 .AuthenticationTypeOIDC :
193
- syncErr = c .syncAuthTypeOIDC (ctx , controllerContext , operatorConfig , authnConfig )
193
+ syncErr = c .syncAuthTypeOIDC (ctx , controllerContext , statusHandler , operatorConfig , authnConfig )
194
194
}
195
195
196
196
// AuthStatusHandler manages fields that are behind the CustomNoUpgrade and TechPreviewNoUpgrade featuregate sets
197
197
// call Apply() only if they are enabled, otherwise server-side apply will complain
198
198
if featureGates .Spec .FeatureSet == configv1 .TechPreviewNoUpgrade || featureGates .Spec .FeatureSet == configv1 .CustomNoUpgrade {
199
199
if err := c .authStatusHandler .Apply (ctx , authnConfig ); err != nil {
200
- c . statusHandler .AddConditions (status .HandleProgressingOrDegraded ("AuthStatusHandler" , "FailedApply" , err ))
201
- return c . statusHandler .FlushAndReturn (err )
200
+ statusHandler .AddConditions (status .HandleProgressingOrDegraded ("AuthStatusHandler" , "FailedApply" , err ))
201
+ return statusHandler .FlushAndReturn (err )
202
202
}
203
203
}
204
204
205
- return c . statusHandler .FlushAndReturn (syncErr )
205
+ return statusHandler .FlushAndReturn (syncErr )
206
206
}
207
207
208
- func (c * oauthClientsController ) syncAuthTypeOIDC (ctx context.Context , controllerContext factory.SyncContext , operatorConfig * operatorv1.Console , authnConfig * configv1.Authentication ) error {
208
+ func (c * oauthClientsController ) syncAuthTypeOIDC (
209
+ ctx context.Context ,
210
+ controllerContext factory.SyncContext ,
211
+ statusHandler status.StatusHandler ,
212
+ operatorConfig * operatorv1.Console ,
213
+ authnConfig * configv1.Authentication ,
214
+ ) error {
215
+
209
216
clientConfig := utilsub .GetOIDCClientConfig (authnConfig )
210
217
if clientConfig == nil {
211
218
c .authStatusHandler .WithCurrentOIDCClient ("" )
@@ -215,8 +222,8 @@ func (c *oauthClientsController) syncAuthTypeOIDC(ctx context.Context, controlle
215
222
216
223
if len (clientConfig .ClientID ) == 0 {
217
224
err := fmt .Errorf ("no ID set on OIDC client" )
218
- c . statusHandler .AddConditions (status .HandleProgressingOrDegraded ("OIDCClientConfig" , "MissingID" , err ))
219
- return c . statusHandler .FlushAndReturn (err )
225
+ statusHandler .AddConditions (status .HandleProgressingOrDegraded ("OIDCClientConfig" , "MissingID" , err ))
226
+ return statusHandler .FlushAndReturn (err )
220
227
}
221
228
c .authStatusHandler .WithCurrentOIDCClient (clientConfig .ClientID )
222
229
@@ -236,7 +243,7 @@ func (c *oauthClientsController) syncAuthTypeOIDC(ctx context.Context, controlle
236
243
if apierrors .IsNotFound (err ) || secretsub .GetSecretString (secret ) != expectedClientSecret {
237
244
secret , _ , err = resourceapply .ApplySecret (ctx , c .secretsClient , controllerContext .Recorder (), secretsub .DefaultSecret (operatorConfig , expectedClientSecret ))
238
245
if err != nil {
239
- c . statusHandler .AddConditions (status .HandleProgressingOrDegraded ("OIDCClientSecretSync" , "FailedApply" , err ))
246
+ statusHandler .AddConditions (status .HandleProgressingOrDegraded ("OIDCClientSecretSync" , "FailedApply" , err ))
240
247
return err
241
248
}
242
249
}
0 commit comments