Files
kuber/command/stop.ts
T

34 lines
1.0 KiB
TypeScript

import { defineCommand } from "citty";
import { Listr } from "listr2";
import { assertManagedNamespace } from "../lib/apply";
import { getProject, listManagedDeployments, scaleDeployment } from "../lib/shared";
export const stop = defineCommand({
meta: {
name: "stop",
description: "Scale managed deployments to zero",
},
async run() {
await assertManagedNamespace(getProject());
const deployments = await listManagedDeployments();
await new Listr([
{
title: "Scale deployments",
skip: () =>
deployments.length > 0 ? false : "No managed deployments found",
task: (_ctx, task) => {
task.output = `${deployments.length} deployments queued`;
return task.newListr(
deployments.map((deployment) => ({
title: `Deployment ${deployment.metadata?.name}`,
task: () => scaleDeployment(deployment.metadata!.name!, 0),
})),
{ concurrent: false, exitOnError: true },
);
},
},
]).run();
},
});