Merge pull request #2280 from pikasTech/issue-2274-opencode-apk-proxy

fix: honor opencode host-route apk proxy
This commit is contained in:
Lyon
2026-06-30 12:04:40 +08:00
committed by GitHub
3 changed files with 35 additions and 1 deletions
-1
View File
@@ -346,7 +346,6 @@ lanes:
model: deepseek-v4-flash
smallModel: deepseek-v4-flash
baseURL: https://opencode.ai/zen/go/v1
apkProxyURL: http://sub2api-egress-proxy.platform-infra.svc.cluster.local:10808
npm: '@ai-sdk/openai-compatible'
apiKeyEnv: OPENCODE_DSFLASH_GO_API_KEY
apiKeySecretRef: hwlab-code-agent-provider/opencode-api-key
+2
View File
@@ -5682,6 +5682,8 @@ function opencodePositiveInteger(value, fallback, label) {
function opencodeEgressProxyUrlForProfile(deploy, profile) {
const proxy = deploy?.lanes?.[profile]?.gitMirror?.egressProxy;
if (!proxy || proxy.required === false) return "";
const proxyUrl = configString(proxy.proxyUrl);
if (proxyUrl) return proxyUrl;
const serviceName = configString(proxy.serviceName);
const namespace = configString(proxy.namespace) || "platform-infra";
const port = Number(proxy.port);
+33
View File
@@ -4,6 +4,7 @@ import { mkdir, mkdtemp, readFile, readdir, rm, writeFile } from "node:fs/promis
import os from "node:os";
import path from "node:path";
import test from "node:test";
import vm from "node:vm";
function taskByName(pipeline, name) {
const task = pipeline.spec.tasks.find((item) => item.name === name);
@@ -97,6 +98,38 @@ async function runtimeNoopDecision(gitopsPromoteScript, { oldRuntime, newRuntime
}
}
function extractNamedFunction(source, name) {
const start = source.indexOf(`function ${name}`);
assert.notEqual(start, -1, `missing function ${name}`);
const bodyStart = source.indexOf("{", start);
assert.notEqual(bodyStart, -1, `missing function body for ${name}`);
let depth = 0;
for (let index = bodyStart; index < source.length; index += 1) {
const char = source[index];
if (char === "{") depth += 1;
else if (char === "}") {
depth -= 1;
if (depth === 0) return source.slice(start, index + 1);
}
}
assert.fail(`unterminated function ${name}`);
}
test("opencode APK proxy prefers explicit gitMirror proxyUrl", async () => {
const source = await readFile("scripts/gitops-render.mjs", "utf8");
const context = {};
vm.runInNewContext(`${extractNamedFunction(source, "configString")}
${extractNamedFunction(source, "opencodeEgressProxyUrlForProfile")}
globalThis.result = {
hostRoute: opencodeEgressProxyUrlForProfile({ lanes: { v03: { gitMirror: { egressProxy: { required: true, proxyUrl: "http://10.42.0.1:10808", namespace: "platform-infra", serviceName: "jd01-host-proxy", port: 10808 } } } } }, "v03"),
serviceFallback: opencodeEgressProxyUrlForProfile({ lanes: { v03: { gitMirror: { egressProxy: { required: true, namespace: "platform-infra", serviceName: "sub2api-egress-proxy", port: 10808 } } } } }, "v03"),
disabled: opencodeEgressProxyUrlForProfile({ lanes: { v03: { gitMirror: { egressProxy: { required: false, proxyUrl: "http://10.42.0.1:10808" } } } } }, "v03")
};`, context, { filename: "gitops-render-opencode-proxy.test.mjs" });
assert.equal(context.result.hostRoute, "http://10.42.0.1:10808");
assert.equal(context.result.serviceFallback, "http://sub2api-egress-proxy.platform-infra.svc.cluster.local:10808");
assert.equal(context.result.disabled, "");
});
test("v02 render follows TypeScript runtime checks and does not self-patch bootstrap RBAC", async () => {
const outDir = await mkdtemp(path.join(os.tmpdir(), "hwlab-v02-render-test-"));
try {