fix: 注入PikaOA受控数据库地址

This commit is contained in:
Codex
2026-07-16 03:19:58 +02:00
parent 97bf7f2786
commit 1805094428
2 changed files with 8 additions and 1 deletions
@@ -138,6 +138,8 @@ describe("PikaOA test PaC renderer", () => {
expect(manifest).toContain("name: initializer");
expect(manifest).not.toContain("kind: Secret");
expect(manifest).toContain("secretName: pikaoa-test-runtime");
expect(manifest.match(/name: DATABASE_URL/gu)).toHaveLength(3);
expect(manifest.match(/key: DATABASE_URL/gu)).toHaveLength(3);
expect(manifest).toContain("image: __PIKAOA_API_IMAGE__");
expect(manifest).toContain("pikaoa.unidesk.io/source-commit: __PIKAOA_SOURCE_COMMIT__");
expect(script).toContain('s|__PIKAOA_SOURCE_COMMIT__|$SOURCE_COMMIT|g');
+6 -1
View File
@@ -96,7 +96,10 @@ export function renderPikaoaTestRuntimeManifest(
name: "initializer", image: context.initializerImage, imagePullPolicy: target.source.pullPolicy,
command: target.initializer.command,
resources: target.runtime.resources.initializer,
env: [{ name: "PIKAOA_CONFIG", value: "/etc/pikaoa/pikaoa.yaml" }],
env: [
{ name: "PIKAOA_CONFIG", value: "/etc/pikaoa/pikaoa.yaml" },
{ name: "DATABASE_URL", valueFrom: { secretKeyRef: { name: target.runtime.secretName, key: target.database.connection.targetKey } } },
],
volumeMounts: [{ name: "runtime", mountPath: "/etc/pikaoa", readOnly: true }],
}],
volumes: [{ name: "runtime", secret: { secretName: target.runtime.secretName, items: [{ key: "pikaoa.yaml", path: "pikaoa.yaml" }] } }],
@@ -106,6 +109,7 @@ export function renderPikaoaTestRuntimeManifest(
},
deployment(target, context, "api", context.apiImage, apiSelector, target.runtime.apiPort, prometheusPodLabels, commonPodAnnotations(target.observability.apiMetricsPath, target.runtime.apiPort), [
{ name: "PIKAOA_CONFIG", value: "/etc/pikaoa/pikaoa.yaml" },
{ name: "DATABASE_URL", valueFrom: { secretKeyRef: { name: target.runtime.secretName, key: target.database.connection.targetKey } } },
{ name: "PIKAOA_SESSION_SECRET", valueFrom: { secretKeyRef: { name: target.runtime.secretName, key: target.runtime.sessionSecret.targetKey } } },
{ name: "PIKAOA_BOOTSTRAP_ADMIN_USERNAME", value: target.runtime.administrator.username },
{ name: "PIKAOA_BOOTSTRAP_ADMIN_PASSWORD", valueFrom: { secretKeyRef: { name: target.runtime.secretName, key: target.runtime.administrator.password.targetKey } } },
@@ -114,6 +118,7 @@ export function renderPikaoaTestRuntimeManifest(
], target.probes.apiLivenessPath, target.probes.apiReadinessPath),
deployment(target, context, "worker", context.workerImage, workerSelector, target.runtime.workerMetricsPort, prometheusPodLabels, commonPodAnnotations(target.observability.workerMetricsPath, target.runtime.workerMetricsPort), [
{ name: "PIKAOA_CONFIG", value: "/etc/pikaoa/pikaoa.yaml" },
{ name: "DATABASE_URL", valueFrom: { secretKeyRef: { name: target.runtime.secretName, key: target.database.connection.targetKey } } },
], target.probes.workerLivenessPath, target.probes.workerReadinessPath),
deployment(target, context, "web", context.webImage, webSelector, target.runtime.webPort, {}, {}, [
{ name: target.runtime.webApiUpstreamEnv, value: `http://${target.runtime.apiServiceName}.${context.namespace}.svc.cluster.local:${target.runtime.apiPort}` },