-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): implement chart install, uninstall and upgrade commands (#454
- Loading branch information
1 parent
bf7f6ff
commit 70fd199
Showing
6 changed files
with
271 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import {BaseCommand} from "./base.mjs"; | ||
import chalk from "chalk"; | ||
import * as core from "../core/index.mjs"; | ||
import * as flags from "./flags.mjs"; | ||
|
||
|
||
export const ChartCommand = class ChartCommand extends BaseCommand { | ||
chartPath = `${core.constants.FST_HOME_DIR}/full-stack-testing/charts/fullstack-deployment` | ||
releaseName = "fullstack-deployment" | ||
|
||
prepareValuesArg(argv) { | ||
let {valuesFile, mirrorNode, hederaExplorer} = argv | ||
let valuesArg = `--values ${this.chartPath}/values.yaml` | ||
|
||
if (valuesFile) { | ||
valuesArg += ` --values ${valuesFile}` | ||
} | ||
|
||
valuesArg += ` --set hedera-mirror-node.enable=${mirrorNode} --set hedera-explorer.enable=${hederaExplorer}` | ||
|
||
return valuesArg | ||
} | ||
|
||
async install(argv) { | ||
let namespace = argv.namespace | ||
let valuesArg = this.prepareValuesArg(argv) | ||
|
||
await this.runExec(`helm dependency update ${this.chartPath}`) | ||
return await this.chartInstall(namespace, this.releaseName, this.chartPath, valuesArg) | ||
} | ||
|
||
async uninstall(argv) { | ||
let namespace = argv.namespace | ||
|
||
return await this.chartUninstall(namespace, this.releaseName) | ||
} | ||
|
||
async upgrade(argv) { | ||
let namespace = argv.namespace | ||
let valuesArg = this.prepareValuesArg(argv) | ||
|
||
return await this.chartUpgrade(namespace, this.releaseName, this.chartPath, valuesArg) | ||
} | ||
|
||
static getCommandDefinition(chartCmd) { | ||
return { | ||
command: 'chart', | ||
desc: 'Manage FST chart deployment', | ||
builder: yargs => { | ||
return yargs | ||
.command({ | ||
command: 'install', | ||
desc: 'Install FST network deployment chart', | ||
builder: yargs => { | ||
yargs.option('namespace', flags.namespaceFlag) | ||
yargs.option('mirror-node', flags.deployMirrorNode) | ||
yargs.option('hedera-explorer', flags.deployHederaExplorer) | ||
yargs.option('values-file', flags.valuesFile) | ||
}, | ||
handler: argv => { | ||
chartCmd.logger.debug("==== Running 'chart install' ===") | ||
chartCmd.logger.debug(argv) | ||
|
||
chartCmd.install(argv).then(r => { | ||
chartCmd.logger.debug("==== Finished running `chart install`====") | ||
|
||
if (!r) process.exit(1) | ||
}) | ||
|
||
} | ||
}) | ||
.command({ | ||
command: 'uninstall', | ||
desc: 'Uninstall FST network deployment chart', | ||
builder: yargs => { | ||
yargs.option('namespace', flags.namespaceFlag) | ||
}, | ||
handler: argv => { | ||
chartCmd.logger.debug("==== Running 'chart uninstall' ===") | ||
chartCmd.logger.debug(argv) | ||
|
||
chartCmd.uninstall(argv).then(r => { | ||
chartCmd.logger.debug("==== Finished running `chart uninstall`====") | ||
|
||
if (!r) process.exit(1) | ||
}) | ||
|
||
} | ||
}) | ||
.command({ | ||
command: 'upgrade', | ||
desc: 'Refresh existing FST network deployment with new values', | ||
builder: yargs => { | ||
yargs.option('namespace', flags.namespaceFlag) | ||
yargs.option('mirror-node', flags.deployMirrorNode) | ||
yargs.option('hedera-explorer', flags.deployHederaExplorer) | ||
yargs.option('values-file', flags.valuesFile) | ||
}, | ||
handler: argv => { | ||
chartCmd.logger.debug("==== Running 'chart upgrade' ===") | ||
chartCmd.logger.debug(argv) | ||
|
||
chartCmd.upgrade(argv).then(r => { | ||
chartCmd.logger.debug("==== Finished running `chart upgrade`====") | ||
|
||
if (!r) process.exit(1) | ||
}) | ||
|
||
} | ||
}) | ||
.demand(1, 'Select a chart command') | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import * as core from "../core/index.mjs"; | ||
|
||
// list of common flags across commands. command specific flags are defined in the command's module. | ||
export const clusterNameFlag = { | ||
describe: 'Cluster name', | ||
default: core.constants.CLUSTER_NAME, | ||
alias: 'c', | ||
type: 'string' | ||
} | ||
|
||
export const namespaceFlag = { | ||
describe: 'Namespace', | ||
default: core.constants.NAMESPACE_NAME, | ||
alias: 's', | ||
type: 'string' | ||
} | ||
|
||
export const deployMirrorNode = { | ||
describe: 'Deploy mirror node', | ||
default: true, | ||
alias: 'm', | ||
type: 'boolean' | ||
} | ||
|
||
export const deployHederaExplorer = { | ||
describe: 'Deploy hedera explorer', | ||
default: true, | ||
alias: 'x', | ||
type: 'boolean' | ||
} | ||
|
||
export const valuesFile = { | ||
describe: 'Helm chart values file [ to override defaults ]', | ||
default: "", | ||
alias: 'f', | ||
type: 'string' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.