Skip to content

OCPBUGS-54185: Helm resource list error in console #15084

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

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const HelmChartVersionDropdown: React.FunctionComponent<HelmChartVersionDropdown
if (!chartIndexEntry) {
setFieldValue(
'chartIndexEntry',
getChartIndexEntry(json?.entries, chartName, chartEntries[0].repoName),
getChartIndexEntry(json?.entries, chartName, chartEntries[0]?.repoName),
);
}
setHelmChartRepos(json?.entries);
Expand Down
13 changes: 11 additions & 2 deletions frontend/packages/helm-plugin/src/utils/helm-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export const getChartIndexEntry = (
chartName: string,
chartRepoName: string,
) => {
const repoName = chartRepoName.toLowerCase().split(' ').join('-');
const repoName = chartRepoName?.toLowerCase().split(' ').join('-');
const indexEntry = Object.keys(chartEntries).find((val) =>
val.includes(`${chartName}--${repoName}`),
);
Expand Down Expand Up @@ -311,7 +311,16 @@ export const loadHelmManifestResources = (release: HelmRelease): K8sResourceKind
return [];
}
const manifests = loadAll(release.manifest, null, { schema: DEFAULT_SAFE_SCHEMA, json: true });
return manifests.filter(Boolean);

// Flatten out any "kind: List" items into top-level objects
const flattened = manifests.flatMap((resource) => {
if (resource?.kind === 'List' && Array.isArray(resource.items)) {
return resource.items;
}
return [resource];
});

return flattened.filter(Boolean);
};

export const getChartReadme = (chart: HelmChart): string => {
Expand Down