Skip to content

Commit 82a6720

Browse files
Merge pull request #15869 from openshift-cherrypick-robot/cherry-pick-15813-to-release-4.20
[release-4.20] OCPBUGS-69917: There should be no role ARN field as token-auth-aws/azure/gcp=false in csv annotations
2 parents 97df484 + 7c37a42 commit 82a6720

File tree

3 files changed

+48
-26
lines changed

3 files changed

+48
-26
lines changed

frontend/packages/operator-lifecycle-manager/src/components/operator-hub/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ export enum ValidSubscriptionValue {
4040
RequiresSeparateSubscription = 'Requires separate subscription',
4141
}
4242

43+
export type TokenizedAuthProvider = 'AWS' | 'Azure' | 'GCP';
44+
4345
export type OperatorHubItem = {
4446
authentication: AuthenticationKind;
4547
catalogSource: string;

frontend/packages/operator-lifecycle-manager/src/components/operator-hub/operator-hub-items.tsx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import {
4141
sourceSort,
4242
validSubscriptionSort,
4343
} from './operator-hub-utils';
44-
import { InfrastructureFeature, OperatorHubItem } from './index';
44+
import { InfrastructureFeature, OperatorHubItem, TokenizedAuthProvider } from './index';
4545

4646
// Scoring and priority code no longer used and will be removed with Operator Hub catalog files cleanup effort
4747
const SCORE = {
@@ -578,7 +578,9 @@ export const OperatorHubTileView: React.FC<OperatorHubTileViewProps> = (props) =
578578
>(userSettingsKey, storeKey, false);
579579
const [updateChannel, setUpdateChannel] = React.useState('');
580580
const [updateVersion, setUpdateVersion] = React.useState('');
581-
const [tokenizedAuth, setTokenizedAuth] = React.useState(null);
581+
const [tokenizedAuth, setTokenizedAuth] = React.useState<TokenizedAuthProvider | undefined>(
582+
undefined,
583+
);
582584
const installVersion = getQueryArgument('version');
583585
const filteredItems = filterByArchAndOS(props.items);
584586

@@ -769,7 +771,7 @@ export const OperatorHubTileView: React.FC<OperatorHubTileViewProps> = (props) =
769771
// reset version and channel state so that switching between operator cards does not carry over previous selections
770772
setUpdateChannel('');
771773
setUpdateVersion('');
772-
setTokenizedAuth('');
774+
setTokenizedAuth(undefined);
773775
};
774776

775777
const openOverlay = (item: OperatorHubItem) => {
@@ -790,21 +792,24 @@ export const OperatorHubTileView: React.FC<OperatorHubTileViewProps> = (props) =
790792
<OperatorHubTile updateChannel={updateChannel} item={item} onClick={openOverlay} />
791793
);
792794

793-
const installParamsURL =
794-
detailsItem &&
795-
detailsItem.obj &&
796-
new URLSearchParams({
795+
let installParamsURL = '';
796+
if (detailsItem && detailsItem.obj) {
797+
const installParams: Record<string, string> = {
797798
pkg: detailsItem.obj.metadata.name,
798799
catalog: detailsItem.catalogSource,
799800
catalogNamespace: detailsItem.catalogSourceNamespace,
800801
targetNamespace: props.namespace,
801802
channel: updateChannel,
802803
version: updateVersion,
803-
tokenizedAuth,
804-
}).toString();
804+
};
805+
if (tokenizedAuth) {
806+
installParams.tokenizedAuth = tokenizedAuth;
807+
}
808+
installParamsURL = new URLSearchParams(installParams).toString();
809+
}
805810

806811
const installLink =
807-
detailsItem && detailsItem.obj && `/operatorhub/subscribe?${installParamsURL.toString()}`;
812+
detailsItem && detailsItem.obj && `/operatorhub/subscribe?${installParamsURL}`;
808813

809814
const uninstallLink = () =>
810815
detailsItem &&

frontend/packages/operator-lifecycle-manager/src/hooks/useOperatorCatalogItems.tsx

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ import { Timestamp } from '@console/shared/src/components/datetime/Timestamp';
1313
import { ExternalLink } from '@console/shared/src/components/links/ExternalLink';
1414
import { iconFor } from '../components';
1515
import { 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';
1723
import {
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

Comments
 (0)