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

Bug 1781105: reject the internal objects when creating from CSV #3729

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions frontend/packages/operator-lifecycle-manager/src/dev-catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ import { ClusterServiceVersionKind } from './types';
import { referenceForProvidedAPI, providedAPIsFor } from './components';
import * as operatorLogo from './operator.svg';

const isInternal = (crd: { name: string }): boolean => {
const internalOpListString = _.get(
crd,
['csv', 'metadata', 'annotations', 'operators.operatorframework.io/internal-objects'],
'[]',
);
try {
const internalOpList = JSON.parse(internalOpListString); // JSON.parse fails if incorrect annotation structure
return internalOpList.some((op) => op === crd.name);
} catch {
/* eslint-disable-next-line no-console */
console.error('Failed to parse CSV annotation: Invalid JSON structure');
return false;
}
};
export const normalizeClusterServiceVersions = (
clusterServiceVersions: ClusterServiceVersionKind[],
): K8sResourceKind[] => {
Expand All @@ -24,6 +39,8 @@ export const normalizeClusterServiceVersions = (
: all.concat([cur]),
[],
)
// remove internal CRDs
.filter((crd) => !isInternal(crd))
.map((desc) => ({
// NOTE: Faking a real k8s object to avoid fetching all CRDs
obj: {
Expand Down
10 changes: 1 addition & 9 deletions frontend/public/components/catalog/catalog-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,7 @@ export class CatalogListPage extends React.Component<CatalogListPageProps, Catal
...projectTemplateItems,
];

//blacklisting all CRDs with annotation 'operators.operatorframework.io/internal-object' set to true
const filteredItems = _.reject(items, [
'obj',
'metadata',
'annotations',
'operators.operatorframework.io/internal-object',
]);

return _.sortBy(filteredItems, 'tileName');
return _.sortBy(items, 'tileName');
}

normalizeClusterServiceClasses(serviceClasses) {
Expand Down