UNPKG

@hashgraph/solo

Version:

An opinionated CLI tool to deploy and manage private Hedera Networks.

90 lines 3.61 kB
import * as helpers from '../../core/helpers.js'; import * as constants from '../../core/constants.js'; import * as ContextFlags from './flags.js'; import { ListrRemoteConfig } from '../../core/config/remote/listr_config_tasks.js'; import { connectConfigBuilder, resetConfigBuilder, setupConfigBuilder } from './configs.js'; import { SoloError } from '../../core/errors.js'; export class ClusterCommandHandlers { parent; tasks; remoteConfigManager; getConfig; constructor(parent, tasks, remoteConfigManager) { this.parent = parent; this.tasks = tasks; this.remoteConfigManager = remoteConfigManager; this.getConfig = parent.getConfig.bind(parent); } async connect(argv) { argv = helpers.addFlagsToArgv(argv, ContextFlags.CONNECT_FLAGS); const action = this.parent.commandActionBuilder([ this.tasks.initialize(argv, connectConfigBuilder.bind(this)), this.parent.setupHomeDirectoryTask(), this.parent.getLocalConfig().promptLocalConfigTask(this.parent.getK8Factory()), this.tasks.selectContext(), ListrRemoteConfig.loadRemoteConfig(this.parent, argv), this.tasks.readClustersFromRemoteConfig(argv), this.tasks.updateLocalConfig(), ], { concurrent: false, rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION, }, 'cluster connect', null); await action(argv, this); return true; } async list(argv) { argv = helpers.addFlagsToArgv(argv, ContextFlags.CONNECT_FLAGS); const action = this.parent.commandActionBuilder([this.tasks.showClusterList()], { concurrent: false, rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION, }, 'cluster list', null); await action(argv, this); return true; } async info(argv) { argv = helpers.addFlagsToArgv(argv, ContextFlags.CONNECT_FLAGS); const action = this.parent.commandActionBuilder([this.tasks.getClusterInfo()], { concurrent: false, rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION, }, 'cluster info', null); await action(argv, this); return true; } async setup(argv) { argv = helpers.addFlagsToArgv(argv, ContextFlags.CONNECT_FLAGS); const action = this.parent.commandActionBuilder([ this.tasks.initialize(argv, setupConfigBuilder.bind(this)), this.tasks.prepareChartValues(argv), this.tasks.installClusterChart(argv), ], { concurrent: false, rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION, }, 'cluster setup', null); try { await action(argv, this); } catch (e) { throw new SoloError('Error on cluster setup', e); } return true; } async reset(argv) { argv = helpers.addFlagsToArgv(argv, ContextFlags.CONNECT_FLAGS); const action = this.parent.commandActionBuilder([ this.tasks.initialize(argv, resetConfigBuilder.bind(this)), this.tasks.acquireNewLease(argv), this.tasks.uninstallClusterChart(argv), ], { concurrent: false, rendererOptions: constants.LISTR_DEFAULT_RENDERER_OPTION, }, 'cluster reset', null); try { await action(argv, this); } catch (e) { throw new SoloError('Error on cluster reset', e); } return true; } } //# sourceMappingURL=handlers.js.map