@@ -13,7 +13,13 @@ import { Timestamp } from '@console/shared/src/components/datetime/Timestamp';
1313import { ExternalLink } from '@console/shared/src/components/links/ExternalLink' ;
1414import { iconFor } from '../components' ;
1515import { subscriptionFor } from '../components/operator-group' ;
16- import { InstalledState , OLMAnnotation , CSVAnnotations } from '../components/operator-hub/index' ;
16+ import {
17+ InstalledState ,
18+ OLMAnnotation ,
19+ CSVAnnotations ,
20+ InfrastructureFeature ,
21+ TokenizedAuthProvider ,
22+ } from '../components/operator-hub/index' ;
1723import {
1824 OperatorVersionSelect ,
1925 OperatorChannelSelect ,
@@ -87,7 +93,6 @@ export const useOperatorCatalogItems = () => {
8793
8894 const [ updateChannel , setUpdateChannel ] = React . useState ( '' ) ;
8995 const [ updateVersion , setUpdateVersion ] = React . useState ( '' ) ;
90- const [ tokenizedAuth , setTokenizedAuth ] = React . useState ( null ) ;
9196
9297 const loaded = React . useMemo (
9398 ( ) =>
@@ -131,16 +136,6 @@ export const useOperatorCatalogItems = () => {
131136 const clusterIsAzureWIF = isAzureWIFCluster ( cloudCredentials , infrastructure , authentication ) ;
132137 const clusterIsGCPWIF = isGCPWIFCluster ( cloudCredentials , infrastructure , authentication ) ;
133138
134- React . useEffect ( ( ) => {
135- if ( clusterIsAWSSTS ) {
136- setTokenizedAuth ( 'AWS' ) ;
137- } else if ( clusterIsAzureWIF ) {
138- setTokenizedAuth ( 'Azure' ) ;
139- } else if ( clusterIsGCPWIF ) {
140- setTokenizedAuth ( 'GCP' ) ;
141- }
142- } , [ clusterIsAWSSTS , clusterIsAzureWIF , clusterIsGCPWIF ] ) ;
143-
144139 const items = React . useMemo ( ( ) => {
145140 if ( ! loaded || loadError ) {
146141 return [ ] ;
@@ -212,14 +207,35 @@ export const useOperatorCatalogItems = () => {
212207 const imgUrl = iconFor ( pkg ) ;
213208 const type = 'operator' ;
214209
210+ // Compute tokenizedAuth per operator based on its infrastructureFeatures
211+ // Only set tokenizedAuth if both the cluster supports it AND the operator supports it
212+ // (i.e., the operator's CSV annotations don't have token-auth-aws/azure/gcp=false)
213+ let operatorTokenizedAuth : TokenizedAuthProvider | undefined ;
214+ if ( clusterIsAWSSTS && infrastructureFeatures . includes ( InfrastructureFeature . TokenAuth ) ) {
215+ operatorTokenizedAuth = 'AWS' ;
216+ } else if (
217+ clusterIsAzureWIF &&
218+ infrastructureFeatures . includes ( InfrastructureFeature . TokenAuth )
219+ ) {
220+ operatorTokenizedAuth = 'Azure' ;
221+ } else if (
222+ clusterIsGCPWIF &&
223+ infrastructureFeatures . includes ( InfrastructureFeature . TokenAuthGCP )
224+ ) {
225+ operatorTokenizedAuth = 'GCP' ;
226+ }
227+
215228 // Build install parameters URL
216- const installParamsURL = new URLSearchParams ( {
229+ const installParams : Record < string , string > = {
217230 pkg : pkg . metadata . name ,
218231 catalog : catalogSource ,
219232 catalogNamespace : catalogSourceNamespace ,
220233 targetNamespace : namespace ,
221- tokenizedAuth,
222- } ) . toString ( ) ;
234+ } ;
235+ if ( operatorTokenizedAuth ) {
236+ installParams . tokenizedAuth = operatorTokenizedAuth ;
237+ }
238+ const installParamsURL = new URLSearchParams ( installParams ) . toString ( ) ;
223239
224240 const installLink = `/operatorhub/subscribe?${ installParamsURL } ` ;
225241 const uninstallLink = subscription
@@ -446,7 +462,6 @@ export const useOperatorCatalogItems = () => {
446462 t ,
447463 updateChannel ,
448464 updateVersion ,
449- tokenizedAuth ,
450465 ] ) ;
451466
452467 return [ items , loaded ] ;
0 commit comments