fix: compact branch follower list status
This commit is contained in:
@@ -572,10 +572,11 @@ async function buildStatus(registry: BranchFollowerRegistry, options: ParsedOpti
|
||||
const shouldLive = wantsLive && options.inCluster;
|
||||
const selected = selectFollowers(registry, options, { includeDisabled: true });
|
||||
const followers = [];
|
||||
const detailedFollowers = options.followerId !== null || options.full;
|
||||
for (const follower of selected) {
|
||||
const stored = k8s.stateByFollower[follower.id] ?? {};
|
||||
const live = shouldLive && follower.enabled ? await readAdapterStatus(registry, follower, options) : null;
|
||||
followers.push(mergeFollowerStatus(registry, follower, stored, live, shouldLive));
|
||||
followers.push(mergeFollowerStatus(registry, follower, stored, live, shouldLive, detailedFollowers));
|
||||
}
|
||||
return {
|
||||
ok: k8s.ok && followers.every((item) => item.ok !== false),
|
||||
@@ -1808,6 +1809,7 @@ function mergeFollowerStatus(
|
||||
stored: Record<string, unknown>,
|
||||
live: AdapterSummary | null,
|
||||
liveRequested: boolean,
|
||||
detailed: boolean,
|
||||
): Record<string, unknown> {
|
||||
const storedSource = asOptionalRecord(stored.source);
|
||||
const storedTarget = asOptionalRecord(stored.target);
|
||||
@@ -1816,7 +1818,7 @@ function mergeFollowerStatus(
|
||||
const targetSha = live?.targetSha ?? stringOrNull(storedTarget?.targetSha);
|
||||
const lastTriggeredSha = live?.lastTriggeredSha ?? stringOrNull(stored.lastTriggeredSha);
|
||||
const lastSucceededSha = live?.lastSucceededSha ?? stringOrNull(stored.lastSucceededSha);
|
||||
return {
|
||||
const summary: Record<string, unknown> = {
|
||||
ok: live === null ? true : live.ok,
|
||||
id: follower.id,
|
||||
enabled: follower.enabled,
|
||||
@@ -1826,7 +1828,6 @@ function mergeFollowerStatus(
|
||||
repository: follower.source.repository,
|
||||
branch: follower.source.branch,
|
||||
observedSha,
|
||||
snapshotPrefix: follower.source.snapshotPrefix,
|
||||
},
|
||||
target: {
|
||||
node: follower.target.node,
|
||||
@@ -1839,12 +1840,21 @@ function mergeFollowerStatus(
|
||||
lastSucceededSha,
|
||||
pipelineRun: live?.pipelineRun ?? stringOrNull(stored.pipelineRun),
|
||||
inFlightJob: live?.inFlightJob ?? stringOrNull(stored.inFlightJob),
|
||||
budgetSource: follower.budgets,
|
||||
updatedAt: stringOrNull(stored.updatedAt),
|
||||
stateConfigMap: registry.controller.stateConfigMapName,
|
||||
live: liveRequested,
|
||||
message: live?.message ?? stringOrNull(stored.decision) ?? "no controller state yet",
|
||||
timings: live === null ? storedFollowerTimingsForStatus(follower, asOptionalRecord(stored.timings), phase, observedSha) : buildFollowerTimings(follower, live, undefined, asOptionalRecord(stored.timings), phase),
|
||||
drilldown: `bun scripts/cli.ts cicd branch-follower status --follower ${follower.id} --live`,
|
||||
};
|
||||
if (!detailed) return summary;
|
||||
return {
|
||||
...summary,
|
||||
source: {
|
||||
...asOptionalRecord(summary.source),
|
||||
snapshotPrefix: follower.source.snapshotPrefix,
|
||||
},
|
||||
budgetSource: follower.budgets,
|
||||
stateConfigMap: registry.controller.stateConfigMapName,
|
||||
warnings: Array.isArray(stored.warnings) ? stored.warnings.slice(0, 6) : [],
|
||||
next: followerNextCommands(follower),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user