Skip to content

Commit

Permalink
fix: check if setup chart installed or not before network deploy (#799)
Browse files Browse the repository at this point in the history
Signed-off-by: Jeffrey Tang <[email protected]>
  • Loading branch information
JeffreyDallas authored Nov 6, 2024
1 parent 3b98dd6 commit 6930dab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/commands/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,15 @@ export class NetworkCommand extends BaseCommand {
return lease.buildAcquireTask(task)
}
},
{
title: 'Check if cluster setup chart is installed',
task: async (ctx, task) => {
const isChartInstalled = await this.chartManager.isChartInstalled('', constants.SOLO_CLUSTER_SETUP_CHART)
if (!isChartInstalled) {
throw new SoloError(`Chart ${constants.SOLO_CLUSTER_SETUP_CHART} is not installed. Run 'solo cluster setup'`)
}
}
},
{
title: 'Prepare staging directory',
task: (_, parentTask) => {
Expand Down Expand Up @@ -547,7 +556,7 @@ export class NetworkCommand extends BaseCommand {
return yargs
.command({
command: 'deploy',
desc: 'Deploy solo network',
desc: "Deploy solo network. Requires the chart `solo-cluster-setup` to have been installed in the cluster. If it hasn't the following command can be ran: `solo cluster setup`",
builder: (y: any) => flags.setCommandFlags(y, ...NetworkCommand.DEPLOY_FLAGS_LIST),
handler: (argv: any) => {
networkCmd.logger.debug('==== Running \'network deploy\' ===')
Expand Down
3 changes: 3 additions & 0 deletions src/core/chart_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export class ChartManager {
/** List available clusters */
async getInstalledCharts (namespaceName: string) {
try {
if (!namespaceName) {
return await this.helm.list('--all-namespaces --no-headers | awk \'{print $1 " [" $9"]"}\'')
}
return await this.helm.list(`-n ${namespaceName}`, '--no-headers | awk \'{print $1 " [" $9"]"}\'')
} catch (e: Error | any) {
this.logger.showUserError(e)
Expand Down

0 comments on commit 6930dab

Please sign in to comment.