diff --git a/deploy/deploy.yaml b/deploy/deploy.yaml index 6bab5d13..0a656ae6 100644 --- a/deploy/deploy.yaml +++ b/deploy/deploy.yaml @@ -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 diff --git a/scripts/gitops-render.mjs b/scripts/gitops-render.mjs index a49aeaac..3c892960 100644 --- a/scripts/gitops-render.mjs +++ b/scripts/gitops-render.mjs @@ -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); diff --git a/scripts/gitops-render.test.ts b/scripts/gitops-render.test.ts index 2411912c..2203888d 100644 --- a/scripts/gitops-render.test.ts +++ b/scripts/gitops-render.test.ts @@ -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 {