Skip to content

Commit

Permalink
operator: enable or disable API services depending on whether OIDC is…
Browse files Browse the repository at this point in the history
… enabled
  • Loading branch information
liouk committed Nov 21, 2024
1 parent 69303eb commit 46287b6
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions pkg/operator/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,7 @@ func prepareOauthAPIServerOperator(
).WithAPIServiceController(
"openshift-apiserver",
"openshift-oauth-apiserver",
func() ([]*apiregistrationv1.APIService, []*apiregistrationv1.APIService, error) {
return apiServices(), nil, nil
},
apiServicesFuncWrapper(authLister, kasLister, kasConfigMapLister),
informerFactories.apiregistrationInformers,
authOperatorInput.apiregistrationv1Client.ApiregistrationV1(),
informerFactories.kubeInformersForNamespaces,
Expand Down Expand Up @@ -884,6 +882,20 @@ func extractOperatorStatus(obj *unstructured.Unstructured, fieldManager string)
return &ret.Status.OperatorStatusApplyConfiguration, nil
}

func apiServicesFuncWrapper(authLister configv1listers.AuthenticationLister, kasLister operatorv1listers.KubeAPIServerLister, kasConfigMapLister corev1listers.ConfigMapLister) func() ([]*apiregistrationv1.APIService, []*apiregistrationv1.APIService, error) {
return func() ([]*apiregistrationv1.APIService, []*apiregistrationv1.APIService, error) {
apiServices := apiServices()
if oidcAvailable, err := common.ExternalOIDCConfigAvailable(authLister, kasLister, kasConfigMapLister); err != nil {
return nil, nil, err
} else if oidcAvailable {
// return apiServices as disabled
return nil, apiServices, nil
}

return apiServices, nil, nil
}
}

func countNodesFuncWrapper(nodeLister corev1listers.NodeLister, authLister configv1listers.AuthenticationLister, kasLister operatorv1listers.KubeAPIServerLister, kasConfigMapLister corev1listers.ConfigMapLister) func(nodeSelector map[string]string) (*int32, error) {
return func(nodeSelector map[string]string) (*int32, error) {
if oidcAvailable, err := common.ExternalOIDCConfigAvailable(authLister, kasLister, kasConfigMapLister); err != nil {
Expand Down

0 comments on commit 46287b6

Please sign in to comment.