UNPKG

@catladder/cli

Version:

Panter cli tool for cloud CI/CD and DevOps

43 lines (42 loc) 1.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.commandPauseProject = void 0; const child_process_promise_1 = require("child-process-promise"); const defineCommand_1 = require("../../../core/defineCommand"); const projects_1 = require("../../../utils/projects"); const autocompletions_1 = require("../../../apps/cli/commands/project/utils/autocompletions"); const availability_1 = require("../../availability"); exports.commandPauseProject = (0, defineCommand_1.defineCommand)({ name: "project k8s pause", description: "halts all running pods (scales to 0)", group: "project", isAvailable: (0, availability_1.hasDeployType)("kubernetes"), inputs: { envComponent: { type: "string", message: "environment:component", positional: true, choices: async () => (0, autocompletions_1.envAndComponents)() } }, execute: async ctx => { const envComponent = await ctx.get("envComponent"); const namespace = await (0, projects_1.getProjectNamespace)(envComponent); const shouldContinue = await ctx.confirm("This will STOP all running pods. You will need to manually scale back up or re-deploy. Continue? 🤔 "); if (!shouldContinue) { return; } const fullCommand = `kubectl scale statefulset,deployment --all --replicas=0 --namespace=${namespace}`; const { stdout } = await (0, child_process_promise_1.exec)(fullCommand, { env: { ...process.env, DEBUG: "" } }); ctx.log(stdout); } });