Skip to content

Commit

Permalink
Merge branch '588-use-prompts-and-show-progress-status-for-cluster-co…
Browse files Browse the repository at this point in the history
…mmands' into 588-chart-cmd
  • Loading branch information
leninmehedy committed Dec 1, 2023
2 parents 7f9fd68 + c2bdffa commit 3e1de0b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
22 changes: 9 additions & 13 deletions fullstack-network-manager/src/commands/cluster.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ export class ClusterCommand extends BaseCommand {
title: 'Initialize',
task: async (ctx, task) => {
const cachedConfig = await self.configManager.setupConfig(argv)
self.logger.debug('Setup cached config', { cachedConfig, argv })

// extract config values
const clusterName = self.configManager.flagValue(cachedConfig, flags.clusterName)
Expand Down Expand Up @@ -228,6 +229,8 @@ export class ClusterCommand extends BaseCommand {
deployCertManagerCRDs: await prompts.promptDeployCertManagerCRDs(task, deployCertManagerCRDs, namespaces)
}

self.logger.debug('Prepare ctx.config', { config: ctx.config, argv })

ctx.isChartInstalled = await this.chartManager.isChartInstalled(ctx.config.namespace, constants.CHART_FST_SETUP_NAME)
}
},
Expand Down Expand Up @@ -334,8 +337,7 @@ export class ClusterCommand extends BaseCommand {
desc: 'Create a cluster',
builder: y => flags.setCommandFlags(y, flags.clusterName, flags.namespace),
handler: argv => {
clusterCmd.logger.debug("==== Running 'cluster create' ===")
clusterCmd.logger.debug(argv)
clusterCmd.logger.debug("==== Running 'cluster create' ===", { argv })

clusterCmd.create(argv).then(r => {
clusterCmd.logger.debug('==== Finished running `cluster create`====')
Expand All @@ -352,8 +354,7 @@ export class ClusterCommand extends BaseCommand {
desc: 'Delete a cluster',
builder: y => flags.setCommandFlags(y, flags.clusterName),
handler: argv => {
clusterCmd.logger.debug("==== Running 'cluster delete' ===")
clusterCmd.logger.debug(argv)
clusterCmd.logger.debug("==== Running 'cluster delete' ===", { argv })

clusterCmd.delete(argv).then(r => {
clusterCmd.logger.debug('==== Finished running `cluster delete`====')
Expand All @@ -369,8 +370,7 @@ export class ClusterCommand extends BaseCommand {
command: 'list',
desc: 'List all clusters',
handler: argv => {
clusterCmd.logger.debug("==== Running 'cluster list' ===")
clusterCmd.logger.debug(argv)
clusterCmd.logger.debug("==== Running 'cluster list' ===", { argv })

clusterCmd.showClusterList().then(r => {
clusterCmd.logger.debug('==== Finished running `cluster list`====')
Expand All @@ -387,9 +387,7 @@ export class ClusterCommand extends BaseCommand {
desc: 'Get cluster info',
builder: y => flags.setCommandFlags(y, flags.clusterName),
handler: argv => {
clusterCmd.logger.debug("==== Running 'cluster info' ===")
clusterCmd.logger.debug(argv)

clusterCmd.logger.debug("==== Running 'cluster info' ===", { argv })
clusterCmd.getClusterInfo(argv).then(r => {
clusterCmd.logger.debug('==== Finished running `cluster info`====')

Expand All @@ -414,8 +412,7 @@ export class ClusterCommand extends BaseCommand {
flags.deployCertManagerCRDs
),
handler: argv => {
clusterCmd.logger.debug("==== Running 'cluster setup' ===")
clusterCmd.logger.debug(argv)
clusterCmd.logger.debug("==== Running 'cluster setup' ===", { argv })

clusterCmd.setup(argv).then(r => {
clusterCmd.logger.debug('==== Finished running `cluster setup`====')
Expand All @@ -435,8 +432,7 @@ export class ClusterCommand extends BaseCommand {
flags.namespace
),
handler: argv => {
clusterCmd.logger.debug("==== Running 'cluster reset' ===")
clusterCmd.logger.debug(argv)
clusterCmd.logger.debug("==== Running 'cluster reset' ===", { argv })

clusterCmd.reset(argv).then(r => {
clusterCmd.logger.debug('==== Finished running `cluster reset`====')
Expand Down
1 change: 1 addition & 0 deletions fullstack-network-manager/src/commands/flags.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export const allFlags = [
deployPrometheusStack,
deployMinio,
deployEnvoyGateway,
deployCertManager,
deployCertManagerCRDs,
releaseTag,
cacheDir,
Expand Down
4 changes: 2 additions & 2 deletions fullstack-network-manager/src/commands/prompts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export async function promptDeployEnvoyGateway (task, input) {

export async function promptDeployCertManager (task, input) {
try {
if (input === undefined) {
if (typeof input !== 'boolean') {
input = await task.prompt(ListrEnquirerPromptAdapter).run({
type: 'toggle',
default: flags.deployCertManager.definition.default,
Expand All @@ -272,7 +272,7 @@ export async function promptDeployCertManager (task, input) {

export async function promptDeployCertManagerCRDs (task, input) {
try {
if (input === undefined) {
if (typeof input !== 'boolean') {
input = await task.prompt(ListrEnquirerPromptAdapter).run({
type: 'toggle',
default: flags.deployCertManagerCRDs.definition.default,
Expand Down
2 changes: 1 addition & 1 deletion fullstack-network-manager/src/core/config_manager.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class ConfigManager {
}

hasFlag (config, flag) {
return !!config.flags[flag.name]
return config.flags[flag.name] !== undefined
}

flagValue (config, flag) {
Expand Down

0 comments on commit 3e1de0b

Please sign in to comment.