Skip to content

Commit

Permalink
Supports multiple Helm repos (#3568)
Browse files Browse the repository at this point in the history
* support multiple helm repos

Signed-off-by: msivasubramaniaan <[email protected]>

* keywords based filtering and fine tune the search

Signed-off-by: msivasubramaniaan <[email protected]>

* made openshift repo always top of the sort

Signed-off-by: msivasubramaniaan <[email protected]>

* removed keywords filtering

Signed-off-by: msivasubramaniaan <[email protected]>

* disabled default helm repo

Signed-off-by: msivasubramaniaan <[email protected]>

* makesure the url on lower case

Signed-off-by: msivasubramaniaan <[email protected]>

* add repo name as dynamic

Signed-off-by: msivasubramaniaan <[email protected]>

* fixed unit test case

Signed-off-by: msivasubramaniaan <[email protected]>

---------

Signed-off-by: msivasubramaniaan <[email protected]>
  • Loading branch information
msivasubramaniaan authored Nov 22, 2023
1 parent 133a1d5 commit aec13a8
Show file tree
Hide file tree
Showing 8 changed files with 194 additions and 132 deletions.
7 changes: 6 additions & 1 deletion src/helm/helm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export async function addHelmRepo(): Promise<CliExitData> {
return await CliChannel.getInstance().executeTool(HelmCommands.addHelmRepo());
}

export async function getHelmRepos(): Promise<CliExitData> {
return await CliChannel.getInstance().executeTool(HelmCommands.getRepos());
}

/**
* Updates the content of all the Helm repos.
*
Expand All @@ -54,11 +58,12 @@ export async function updateHelmRepo(): Promise<CliExitData> {
*/
export async function installHelmChart(
name: string,
repoName: string,
chartName: string,
version: string,
): Promise<CliExitData> {
return await CliChannel.getInstance().executeTool(
HelmCommands.installHelmChart(name, chartName, version),
HelmCommands.installHelmChart(name, repoName, chartName, version),
);
}

Expand Down
10 changes: 8 additions & 2 deletions src/helm/helmCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@ export function updateHelmRepo(): CommandText {
return new CommandText('helm', 'repo update');
}

export function installHelmChart(name: string, chartName: string, version: string): CommandText {
return new CommandText('helm', `install ${name} openshift/${chartName}`, [new CommandOption('--version', version)]);
export function getRepos(): CommandText {
const commandText = new CommandText('helm','repo list')
commandText.addOption(new CommandOption('-o','json'));
return commandText;
}

export function installHelmChart(name: string, repoName: string, chartName: string, version: string): CommandText {
return new CommandText('helm', `install ${name} ${repoName}/${chartName}`, [new CommandOption('--version', version)]);
}

export function unInstallHelmChart(name: string): CommandText {
Expand Down
45 changes: 24 additions & 21 deletions src/webview/helm-chart/app/helmListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*-----------------------------------------------------------------------------------------------*/
import { Box, Button, Chip, Link, Stack, SvgIcon, Typography } from '@mui/material';
import { Box, Button, Chip, Link, Stack, SvgIcon, Tooltip, Typography } from '@mui/material';
import * as React from 'react';
import HelmIcon from '../../../../images/helm/helm.svg';
import { Chart, ChartResponse } from '../helmChartType';
Expand Down Expand Up @@ -39,7 +39,7 @@ export function HelmListItem(props: HelmListItemProps) {
</Box>
) : (
<>
<HelmChartListContent helmChart={props.helmChart} selectedVersion={props.selectedVersion} isDetailedPage={props.isDetailedPage}/>
<HelmChartListContent helmChart={props.helmChart} selectedVersion={props.selectedVersion} isDetailedPage={props.isDetailedPage} />
</>
)}
</>
Expand Down Expand Up @@ -119,7 +119,7 @@ function HelmChartListContent(props: HelmListItemProps) {
textOverflow: 'ellipsis',
}}
>
{capitalizeFirstLetter(props.helmChart.displayName)}
{capitalizeFirstLetter(props.helmChart.displayName || props.helmChart.chartName)}
</Typography>
</Stack>
<Typography
Expand All @@ -130,44 +130,47 @@ function HelmChartListContent(props: HelmListItemProps) {
</Typography>
{props.isDetailedPage &&
<LinkButton
href='https://charts.openshift.io/'
href={props.helmChart.repoURL}
onClick={() => {
VSCodeMessage.postMessage({
action: 'sendTelemetry',
data: {
actionName: 'helmRepoInBrowser',
properties: {
// eslint-disable-next-line camelcase
url: 'https://charts.openshift.io/',
url: props.helmChart.repoURL,
// eslint-disable-next-line camelcase
helmChartName: props.helmChart.displayName,
},
},
});
}} >https://charts.openshift.io/
}} >{props.helmChart.repoURL}
</LinkButton>
}
<Stack direction='row' spacing={1}>
{props.selectedVersion.annotations['charts.openshift.io/providerType'] &&
<Tooltip title={props.helmChart.repoURL}>
<Chip
size='small'
label={props.selectedVersion.annotations['charts.openshift.io/providerType']}
color={'primary'} />
}
{props.selectedVersion.annotations['charts.openshift.io/provider'] ?
label={props.helmChart.repoName}
color={'success'} />
</Tooltip>
{props.selectedVersion.annotations && props.selectedVersion.annotations['charts.openshift.io/providerType'] &&
<Chip
size='small'
label={props.selectedVersion.annotations['charts.openshift.io/provider']}
color={'success'} />
:
props.selectedVersion.maintainers?.length > 0 ?
<Chip
size='small'
label={props.selectedVersion.maintainers[0].name}
color={'success'} />
:
undefined
label={props.selectedVersion.annotations['charts.openshift.io/providerType']}
color={'primary'} />
}
{(props.selectedVersion.keywords && props.selectedVersion.keywords.map((tag, i) => {
if (i >= 2) {
return;
}
return <Chip size="small" label={tag} key={tag} />;
}))}
{(props.selectedVersion.keywords && props.selectedVersion.keywords.length > 2 && (
<Tooltip title={props.selectedVersion.keywords.slice(2).join(', ')}>
<Chip size="small" label="• • •" />
</Tooltip>
))}
<Chip
size='small'
label={props.selectedVersion.version}
Expand Down
1 change: 1 addition & 0 deletions src/webview/helm-chart/app/helmModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ export const HelmModal = React.forwardRef(
action: 'install',
data: {
name: installName,
repoName: props.helmChart.repoName,
chartName: props.helmChart.chartName,
version: selectedVersion.version
}
Expand Down
Loading

0 comments on commit aec13a8

Please sign in to comment.