fix: use k8s git mirror source snapshots
This commit is contained in:
@@ -42,7 +42,7 @@ import { pathValue } from "./render";
|
||||
import { startAsyncAgentRunJob } from "./rest-bridge";
|
||||
import { collectLaneSecretSources, readSecretSourceValue, restartYamlLaneScript, secretSyncScript } from "./secrets";
|
||||
import { capture, captureJsonPayload, compactCapture, isGitSha, stringOrNull } from "./utils";
|
||||
import { yamlLaneSourceBootstrapProbeScript } from "./yaml-lane";
|
||||
import { yamlLaneK3sSourceStatusScript, yamlLaneSourceBootstrapProbeScript } from "./yaml-lane";
|
||||
|
||||
export function renderNextObjectLines(next: Record<string, unknown>): string[] {
|
||||
return Object.values(next)
|
||||
@@ -409,18 +409,34 @@ export async function triggerCurrent(config: UniDeskConfig, options: TriggerOpti
|
||||
|
||||
export async function triggerCurrentYamlLane(config: UniDeskConfig, options: TriggerOptions, target: { configPath: string; spec: AgentRunLaneSpec }): Promise<Record<string, unknown>> {
|
||||
const spec = target.spec;
|
||||
const probe = await capture(config, spec.nodeRoute, ["sh", "--", yamlLaneSourceBootstrapProbeScript(spec)]);
|
||||
const probe = spec.source.statusMode === "k3s-git-mirror"
|
||||
? await capture(config, spec.nodeKubeRoute, ["sh", "--", yamlLaneK3sSourceStatusScript(spec)])
|
||||
: await capture(config, spec.nodeRoute, ["sh", "--", yamlLaneSourceBootstrapProbeScript(spec)]);
|
||||
const source = captureJsonPayload(probe);
|
||||
const sourceCommit = stringOrNull(source.sourceCommit);
|
||||
const remoteBranchExists = source.remoteBranchExists === true;
|
||||
const pipelineRun = sourceCommit !== null && isGitSha(sourceCommit) ? agentRunPipelineRunName(spec, sourceCommit) : null;
|
||||
const placeholderImage = sourceCommit === null ? null : placeholderAgentRunImage(spec, sourceCommit);
|
||||
const renderedFiles = placeholderImage === null ? [] : renderAgentRunGitopsFiles(spec, { sourceCommit, image: placeholderImage });
|
||||
const plan = {
|
||||
node: spec.nodeId,
|
||||
lane: spec.lane,
|
||||
version: spec.version,
|
||||
source: {
|
||||
const sourcePlan = spec.source.statusMode === "k3s-git-mirror"
|
||||
? {
|
||||
statusMode: spec.source.statusMode,
|
||||
sourceAuthority: spec.source.sourceAuthority,
|
||||
sourceSnapshot: spec.source.sourceSnapshot,
|
||||
repository: spec.source.repository,
|
||||
branch: spec.source.branch,
|
||||
remoteBranchExists,
|
||||
remoteBranchCommit: stringOrNull(source.remoteBranchCommit),
|
||||
sourceCommit,
|
||||
sourceRef: stringOrNull(source.sourceRef),
|
||||
sourceStageRef: stringOrNull(source.sourceStageRef),
|
||||
snapshotPresent: source.snapshotPresent === true,
|
||||
degradedReason: stringOrNull(source.degradedReason),
|
||||
next: source.snapshotPresent === true ? null : `bun scripts/cli.ts agentrun git-mirror sync --node ${spec.nodeId} --lane ${spec.lane} --confirm --wait`,
|
||||
valuesPrinted: false,
|
||||
}
|
||||
: {
|
||||
statusMode: spec.source.statusMode,
|
||||
workspace: spec.source.workspace,
|
||||
remote: spec.source.remote,
|
||||
branch: spec.source.branch,
|
||||
@@ -429,7 +445,13 @@ export async function triggerCurrentYamlLane(config: UniDeskConfig, options: Tri
|
||||
bootstrapPollSeconds: spec.source.bootstrapPollSeconds,
|
||||
remoteBranchExists,
|
||||
sourceCommit,
|
||||
},
|
||||
valuesPrinted: false,
|
||||
};
|
||||
const plan = {
|
||||
node: spec.nodeId,
|
||||
lane: spec.lane,
|
||||
version: spec.version,
|
||||
source: sourcePlan,
|
||||
deploymentFormat: spec.deployment.format,
|
||||
deploymentTruth: "config/agentrun.yaml",
|
||||
removedServiceDeployJson: true,
|
||||
|
||||
Reference in New Issue
Block a user