Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CONSOLE-3758: add support for new features annotations while preserv… #13183

Merged
merged 1 commit into from Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -83,7 +83,16 @@ export enum OperatorHubCSVAnnotationKey {
infrastructureFeatures = 'operators.openshift.io/infrastructure-features',
validSubscription = 'operators.openshift.io/valid-subscription',
tags = 'tags',
disconnected = 'features.operators.openshift.io/disconnected',
fipsCompliant = 'features.operators.openshift.io/fips-compliant',
proxyAware = 'features.operators.openshift.io/proxy-aware',
cnf = 'features.operators.openshift.io/cnf',
cni = 'features.operators.openshift.io/cni',
csi = 'features.operators.openshift.io/csi',
tlsProfiles = 'features.operators.openshift.io/tls-profiles',
tokenAuthAWS = 'features.operators.openshift.io/token-auth-aws',
tokenAuthAzure = 'features.operators.openshift.io/token-auth-azure',
tokenAuthGCP = 'features.operators.openshift.io/token-auth-gcp',
}

export type OperatorHubCSVAnnotations = {
Expand All @@ -102,7 +111,16 @@ export type OperatorHubCSVAnnotations = {
[OperatorHubCSVAnnotationKey.infrastructureFeatures]?: string;
[OperatorHubCSVAnnotationKey.validSubscription]?: string;
[OperatorHubCSVAnnotationKey.tags]?: string[];
[OperatorHubCSVAnnotationKey.disconnected]?: string;
[OperatorHubCSVAnnotationKey.fipsCompliant]?: string;
[OperatorHubCSVAnnotationKey.proxyAware]?: string;
[OperatorHubCSVAnnotationKey.cnf]?: string;
[OperatorHubCSVAnnotationKey.cni]?: string;
[OperatorHubCSVAnnotationKey.csi]?: string;
[OperatorHubCSVAnnotationKey.tlsProfiles]?: string;
[OperatorHubCSVAnnotationKey.tokenAuthAWS]?: string;
[OperatorHubCSVAnnotationKey.tokenAuthAzure]?: string;
[OperatorHubCSVAnnotationKey.tokenAuthGCP]?: string;
} & ObjectMetadata['annotations'];

type OperatorHubSpec = {
Expand Down
Expand Up @@ -151,11 +151,6 @@ export const OperatorHubList: React.FC<OperatorHubListProps> = ({
[],
);

// TODO remove lodash and implement using Array.prototye.reduce
const infraFeatures = _.uniq(
_.compact(_.map(parsedInfraFeatures, (key) => InfraFeatures[key])),
);

const {
certifiedLevel,
healthIndex,
Expand All @@ -164,7 +159,18 @@ export const OperatorHubList: React.FC<OperatorHubListProps> = ({
createdAt,
support,
capabilities: capabilityLevel,
[OperatorHubCSVAnnotationKey.disconnected]: disconnected,
[OperatorHubCSVAnnotationKey.fipsCompliant]: fipsCompliant,
[OperatorHubCSVAnnotationKey.proxyAware]: proxyAware,
[OperatorHubCSVAnnotationKey.cnf]: cnf,
[OperatorHubCSVAnnotationKey.cni]: cni,
[OperatorHubCSVAnnotationKey.csi]: csi,
// tlsProfiles requires addtional changes
// [OperatorHubCSVAnnotationKey.tlsProfiles]: tlsProfiles,
[OperatorHubCSVAnnotationKey.tokenAuthAWS]: tokenAuthAWS,
// tokenAuthAzure and tokenAuthGCP require additional changes
// [OperatorHubCSVAnnotationKey.tokenAuthAzure]: tokenAuthAzure,
// [OperatorHubCSVAnnotationKey.tokenAuthGCP]: tokenAuthGCP,
[OperatorHubCSVAnnotationKey.actionText]: marketplaceActionText,
[OperatorHubCSVAnnotationKey.remoteWorkflow]: marketplaceRemoteWorkflow,
[OperatorHubCSVAnnotationKey.supportWorkflow]: marketplaceSupportWorkflow,
Expand All @@ -179,13 +185,34 @@ export const OperatorHubList: React.FC<OperatorHubListProps> = ({

const auth = loaded && authentication?.data;

// FIXME: this is a temporary hack and should be fixed as part of
// a refactor to include the new style of infrastructure features
// tracked in PORTENABLE-525
let infrastructureFeatures: InfraFeatures[] = parsedInfraFeatures.map(
(key) => InfraFeatures[key],
);

const featuresAnnotationsObjects = [
{ key: InfraFeatures.Disconnected, value: disconnected },
{ key: InfraFeatures.FipsMode, value: fipsCompliant },
{ key: InfraFeatures.Proxy, value: proxyAware },
{ key: InfraFeatures.cnf, value: cnf },
{ key: InfraFeatures.cni, value: cni },
{ key: InfraFeatures.csi, value: csi },
];

featuresAnnotationsObjects.forEach(({ key, value }) => {
if (value === 'false') {
// override existing operators.openshift.io/infrastructure-features annotation value
infrastructureFeatures = infrastructureFeatures.filter((feature) => feature !== key);
} else if (value === 'true') {
infrastructureFeatures.push(key);
}
});

if (tokenAuthAWS === 'true' && isAWSSTSCluster(cloudCredential, infra, auth)) {
infraFeatures.push(shortLivedTokenAuth);
infrastructureFeatures.push(InfraFeatures[shortLivedTokenAuth]);
}

const infraFeatures = _.uniq(_.compact(infrastructureFeatures));

const clusterServiceVersion =
loaded &&
clusterServiceVersionFor(
Expand Down