Files
kuber/command/restart.ts
T

38 lines
1.1 KiB
TypeScript

import { defineCommand } from "citty";
import { Listr } from "listr2";
import { assertManagedNamespace } from "../lib/apply";
import {
getProject,
listManagedDeployments,
restartDeployment,
} from "../lib/shared";
export const restart = defineCommand({
meta: {
name: "restart",
description: "Roll out a restart for managed deployments",
},
async run() {
await assertManagedNamespace(getProject());
const deployments = await listManagedDeployments();
await new Listr([
{
title: "Restart 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: () => restartDeployment(deployment.metadata!.name!),
})),
{ concurrent: false, exitOnError: true },
);
},
},
]).run();
},
});