Merge pull request #1743 from pikasTech/fix/1742-trans-k3s-download
Pipelines as Code CI / hwlab-web-probe-sentinel-nc01- Success
Pipelines as Code CI / unidesk-host- Success

fix: 恢复 trans k3s download 命令构造
This commit is contained in:
Lyon
2026-07-11 11:26:34 +08:00
committed by GitHub
4 changed files with 41 additions and 1 deletions
+1
View File
@@ -24,6 +24,7 @@ import { readTransSshBackendConfig, type TransSshBackendConfig } from "./trans-c
import { readCliOutputPolicy } from "./output";
import { readHostK8sPublicHost } from "./host-k8s-config";
import {
buildK3sTargetCommand,
buildWindowsPowerShellInvocation,
effectiveApplyPatchV2Invocation,
normalizeSshOperationArgs,
+20
View File
@@ -11,6 +11,7 @@ import {
formatSshStdoutTruncationHint,
formatSshTruncationCompletionSummary,
parseSshInvocation,
remoteCommandForRoute,
sshTruncationCompletionSummary,
sshCaptureBackendPlan,
sshStderrStreamMaxBytes,
@@ -219,6 +220,25 @@ describe("ssh direct argv boundaries and plane diagnostics", () => {
});
});
describe("ssh k3s file transfer command builder", () => {
test("routes download stream commands through the shared k3s target builder", () => {
const invocation = parseSshInvocation(
"NC01:k3s:hwlab:deployment:hwlab-cloud-api",
["download", "/tmp/trace.json", "/tmp/trace.json"],
);
const remoteCommand = remoteCommandForRoute(
invocation.route,
["sh", "-c", "cat -- \"$1\"", "unidesk-download", "/tmp/trace.json"],
);
expect(remoteCommand).toContain("'KUBECONFIG=/etc/rancher/k3s/k3s.yaml'");
expect(remoteCommand).toContain("'kubectl' 'exec' '-n' 'hwlab'");
expect(remoteCommand).toContain("'deployment/hwlab-cloud-api'");
expect(remoteCommand).toContain("'cat -- \"$1\"'");
expect(remoteCommand).toContain("'/tmp/trace.json'");
});
});
describe("ssh host apply-patch fs backend", () => {
test("uses POSIX bulk fs operations for host routes", async () => {
const invocation = parseSshInvocation("D601:/mnt/f/Work/ConStart", ["apply-patch"]);
+1 -1
View File
@@ -1367,7 +1367,7 @@ function buildK3sTargetObjectCommand(action: "get" | "describe", route: ParsedSs
return shellArgv(["env", `KUBECONFIG=${nativeK3sKubeconfig}`, "kubectl", action, "-n", route.namespace, normalizeK3sRouteResource(route.resource), ...args]);
}
function buildK3sTargetCommand(route: ParsedSshRoute, command: string[], options: { stdin?: boolean } = {}): string {
export function buildK3sTargetCommand(route: ParsedSshRoute, command: string[], options: { stdin?: boolean } = {}): string {
return buildK3sExecCommand([...k3sRouteTargetArgs(route), ...(options.stdin === true ? ["--stdin"] : []), "--", ...command]);
}