fix(plugin): share kubernetes shell quoting helper

This commit is contained in:
Dotta
2026-05-13 13:01:39 -05:00
committed by Chris Farhood
parent 58d1b19206
commit 713fb6eb4e
3 changed files with 6 additions and 9 deletions
@@ -13,6 +13,7 @@
import { Exec } from "@kubernetes/client-node";
import { PassThrough } from "node:stream";
import type { KubeConfig } from "@kubernetes/client-node";
import { shellQuoteArg } from "./shell-utils.js";
type WebSocketLike = {
close(): void;
@@ -27,10 +28,6 @@ export interface ExecInPodResult {
stderr: string;
}
function shQuoteArg(arg: string): string {
return "'" + arg.replace(/'/g, "'\\''") + "'";
}
export async function execInPod(
kc: KubeConfig,
namespace: string,
@@ -50,7 +47,7 @@ export async function execInPod(
: null;
const stdinStream: PassThrough | null = stdinPayload ? new PassThrough() : null;
const effectiveCommand = stdinPayload
? ["/bin/sh", "-c", `head -c ${stdinPayload.length} | ${command.map(shQuoteArg).join(" ")}`]
? ["/bin/sh", "-c", `head -c ${stdinPayload.length} | ${command.map(shellQuoteArg).join(" ")}`]
: command;
let stdoutData = "";