@catladder/cli
Version:
Panter cli tool for cloud CI/CD and DevOps
46 lines (45 loc) • 1.39 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.commandKubePortForward = void 0;
const defineCommand_1 = require("../../core/defineCommand");
const k8sApi_1 = require("../../k8sApi");
const portForward_1 = require("../../kubernetes/portForward");
exports.commandKubePortForward = (0, defineCommand_1.defineCommand)({
name: "k8s port-forward",
description: "start port-forwarding",
group: "general",
inputs: {
namespace: {
type: "string",
message: "kubernetes namespace",
positional: true
},
podName: {
type: "string",
message: "Which pod? 🤔",
choices: async ctx => {
const namespace = await ctx.get("namespace");
const k8sApi = (0, k8sApi_1.getk8sApi)();
const res = await k8sApi.listNamespacedPod(namespace);
return res.body.items.map(i => i.metadata.name);
}
},
localPort: {
type: "number",
message: "Local port: "
},
remotePort: {
type: "number",
message: "Remote port: "
}
},
execute: async ctx => {
const namespace = await ctx.get("namespace");
const podName = await ctx.get("podName");
const localPort = await ctx.get("localPort");
const remotePort = await ctx.get("remotePort");
return (0, portForward_1.startKubePortForward)(podName, localPort, remotePort, namespace);
}
});