fix: configure JD01 workspace git proxy
This commit is contained in:
+19
-1
@@ -22,6 +22,7 @@ import {
|
||||
type SshRemoteCommandExecutor,
|
||||
type SshRemoteCommandStreamHandlers,
|
||||
} from "./ssh-file-transfer";
|
||||
import { readTransHostProxyEnvRule, type TransHostProxyEnvRule } from "./trans-host-proxy";
|
||||
|
||||
export interface ParsedSshArgs {
|
||||
remoteCommand: string | null;
|
||||
@@ -1064,7 +1065,8 @@ export function parseSshInvocation(target: string, args: string[]): ParsedSshInv
|
||||
if ((operationArgs[0] ?? "") === "k3s") {
|
||||
throw new Error(`ssh k3s shorthand is unsupported; use route syntax instead: trans ${route.providerId}:k3s ${operationArgs.slice(1).join(" ")}`.trim());
|
||||
}
|
||||
return { providerId: route.providerId, route, parsed: parseSshArgs(operationArgs, route.raw) };
|
||||
const parsed = parseSshArgs(operationArgs, route.raw);
|
||||
return { providerId: route.providerId, route, parsed: withTransHostProxyEnv(route, parsed) };
|
||||
}
|
||||
|
||||
export function parseSshRoute(target: string): ParsedSshRoute {
|
||||
@@ -2428,6 +2430,22 @@ function shellScriptStdinPrefix(): string {
|
||||
return `${shellScriptPrelude()}\n`;
|
||||
}
|
||||
|
||||
function withTransHostProxyEnv(route: ParsedSshRoute, parsed: ParsedSshArgs): ParsedSshArgs {
|
||||
if (route.plane !== "host" || parsed.remoteCommand === null) return parsed;
|
||||
const rule = readTransHostProxyEnvRule(route.providerId);
|
||||
if (rule === null || rule.applyTo !== "host-posix-commands") return parsed;
|
||||
return { ...parsed, remoteCommand: `${transHostProxyEnvPrelude(rule)}; ${parsed.remoteCommand}` };
|
||||
}
|
||||
|
||||
function transHostProxyEnvPrelude(rule: TransHostProxyEnvRule): string {
|
||||
const envFile = shellQuote(rule.envFile);
|
||||
return [
|
||||
`UNIDESK_TRANS_HOST_PROXY_ENV=${envFile}`,
|
||||
'if [ -f "$UNIDESK_TRANS_HOST_PROXY_ENV" ]; then set -a; . "$UNIDESK_TRANS_HOST_PROXY_ENV"; unidesk_trans_host_proxy_env_rc=$?; set +a; [ "$unidesk_trans_host_proxy_env_rc" -eq 0 ] || exit "$unidesk_trans_host_proxy_env_rc"; fi',
|
||||
`export UNIDESK_TRANS_HOST_PROXY_ENV_SOURCE=${shellQuote(rule.configPathLabel)}`,
|
||||
].join("; ");
|
||||
}
|
||||
|
||||
function buildShellCommand(args: string[], shell: "sh" | "bash", commandName: string): ParsedSshArgs {
|
||||
const scriptArgs: string[] = [];
|
||||
for (let index = 0; index < args.length; index += 1) {
|
||||
|
||||
Reference in New Issue
Block a user