Merge pull request #1730 from pikasTech/fix/1728-sentinel-gitops-flush
fix: 为 sentinel closeout 启用 GitOps mirror flush
This commit is contained in:
@@ -237,6 +237,8 @@ templates:
|
||||
pipelineRunPrefix: "hwlab-web-probe-sentinel-${nodeLower}"
|
||||
argoNamespace: argocd
|
||||
argoApplication: "hwlab-web-probe-sentinel-${nodeLower}"
|
||||
closeoutGitOpsMirrorFlush: true
|
||||
closeoutGitOpsMirrorLane: v03
|
||||
hwlabV03:
|
||||
id: "hwlab-${nodeLower}-v03"
|
||||
repositoryRef: "hwlab-${nodeLower}-v03"
|
||||
|
||||
@@ -184,7 +184,7 @@ export async function runPlatformInfraPipelinesAsCodeCommand(config: UniDeskConf
|
||||
if (action === "plan") {
|
||||
const options = parseCommonOptions(args.slice(1));
|
||||
const result = plan(options);
|
||||
return options.json || options.full || options.raw ? result : renderPlan(result);
|
||||
return options.full || options.raw ? result : options.json ? compactPlanJson(result) : renderPlan(result);
|
||||
}
|
||||
if (action === "apply") {
|
||||
const options = parseApplyOptions(args.slice(1));
|
||||
@@ -351,7 +351,7 @@ function parseConsumer(consumer: Record<string, unknown>, path: string, defaultR
|
||||
automated: y.booleanField(argoBootstrap, "automated", `${path}.argoBootstrap`),
|
||||
},
|
||||
repositoryRef: typeof consumer.repositoryRef === "string" && consumer.repositoryRef.length > 0 ? consumer.repositoryRef : defaultRepositoryRef,
|
||||
closeoutGitOpsMirrorFlush: consumer.closeoutGitOpsMirrorFlush === undefined ? false : y.booleanField(consumer, "closeoutGitOpsMirrorFlush", path),
|
||||
closeoutGitOpsMirrorFlush: y.booleanField(consumer, "closeoutGitOpsMirrorFlush", path),
|
||||
closeoutGitOpsMirrorLane: consumer.closeoutGitOpsMirrorLane === undefined ? null : y.enumField(consumer, "closeoutGitOpsMirrorLane", path, ["v02", "v03"] as const),
|
||||
};
|
||||
}
|
||||
@@ -428,6 +428,7 @@ function plan(options: CommonOptions): Record<string, unknown> {
|
||||
release: pac.release,
|
||||
repository: repositorySummary(repository),
|
||||
consumer,
|
||||
closeout: closeoutDeclaration(pac, consumer),
|
||||
secrets,
|
||||
policy: policyChecks(repository),
|
||||
next: nextCommands(target.id, consumer.id, pac.defaults.consumerId),
|
||||
@@ -475,6 +476,7 @@ async function status(config: UniDeskConfig, options: CommonOptions): Promise<Re
|
||||
target: targetSummary(target),
|
||||
config: compactConfigSummary(pac, consumer, repository),
|
||||
consumer,
|
||||
closeout: closeoutDeclaration(pac, consumer),
|
||||
coverage: consumerCoverage(pac, target.id),
|
||||
summary,
|
||||
remote: parsed === null ? compactCapture(result, { full: true }) : options.raw ? parsed : undefined,
|
||||
@@ -1049,6 +1051,7 @@ function configSummary(pac: PacConfig, consumer: PacConsumer, repository: PacRep
|
||||
path: configLabel,
|
||||
metadata: pac.metadata,
|
||||
release: pac.release,
|
||||
closeout: pac.closeout,
|
||||
gitea: { configRef: pac.gitea.configRef, internalBaseUrl: pac.gitea.internalBaseUrl, webhookBranch: pac.gitea.webhook.branch },
|
||||
display: pac.display,
|
||||
repositories: pac.repositories.map(repositorySummary),
|
||||
@@ -1063,6 +1066,7 @@ function compactConfigSummary(pac: PacConfig, consumer: PacConsumer, repository:
|
||||
return {
|
||||
path: configLabel,
|
||||
releaseVersion: pac.release.version,
|
||||
closeout: pac.closeout,
|
||||
repository: repository.name,
|
||||
providerType: repository.providerType,
|
||||
sourceUrl: repository.cloneUrl,
|
||||
@@ -1074,6 +1078,19 @@ function compactConfigSummary(pac: PacConfig, consumer: PacConsumer, repository:
|
||||
};
|
||||
}
|
||||
|
||||
function closeoutDeclaration(pac: PacConfig, consumer: PacConsumer): Record<string, unknown> {
|
||||
const config = pac.closeout.gitOpsMirrorFlush;
|
||||
return {
|
||||
enabled: config.enabled,
|
||||
configured: consumer.closeoutGitOpsMirrorFlush,
|
||||
required: config.enabled && consumer.closeoutGitOpsMirrorFlush,
|
||||
lane: consumer.closeoutGitOpsMirrorLane ?? consumer.lane,
|
||||
waitTimeoutSeconds: config.waitTimeoutSeconds,
|
||||
maxAttempts: config.maxAttempts,
|
||||
valuesPrinted: false,
|
||||
};
|
||||
}
|
||||
|
||||
function repositorySummary(repository: PacRepository): Record<string, unknown> {
|
||||
return {
|
||||
id: repository.id,
|
||||
@@ -1120,6 +1137,43 @@ function nextCommands(targetId: string, consumerId: string, defaultConsumerId: s
|
||||
};
|
||||
}
|
||||
|
||||
function compactPlanJson(result: Record<string, unknown>): Record<string, unknown> {
|
||||
const config = record(result.config);
|
||||
const consumer = record(result.consumer);
|
||||
return {
|
||||
ok: result.ok === true,
|
||||
action: result.action,
|
||||
mutation: false,
|
||||
target: result.target,
|
||||
config: {
|
||||
path: config.path,
|
||||
metadata: config.metadata,
|
||||
release: config.release,
|
||||
closeout: config.closeout,
|
||||
gitea: config.gitea,
|
||||
display: config.display,
|
||||
valuesPrinted: false,
|
||||
},
|
||||
repository: result.repository,
|
||||
consumer: {
|
||||
id: consumer.id,
|
||||
node: consumer.node,
|
||||
lane: consumer.lane,
|
||||
namespace: consumer.namespace,
|
||||
pipeline: consumer.pipeline,
|
||||
pipelineRunPrefix: consumer.pipelineRunPrefix,
|
||||
argoNamespace: consumer.argoNamespace,
|
||||
argoApplication: consumer.argoApplication,
|
||||
repositoryRef: consumer.repositoryRef,
|
||||
},
|
||||
closeout: result.closeout,
|
||||
secrets: result.secrets,
|
||||
policy: result.policy,
|
||||
next: result.next,
|
||||
valuesPrinted: false,
|
||||
};
|
||||
}
|
||||
|
||||
function compactStatusJson(result: Record<string, unknown>): Record<string, unknown> {
|
||||
const consumer = record(result.consumer);
|
||||
return {
|
||||
@@ -1135,6 +1189,7 @@ function compactStatusJson(result: Record<string, unknown>): Record<string, unkn
|
||||
pipeline: consumer.pipeline,
|
||||
argoApplication: consumer.argoApplication,
|
||||
},
|
||||
closeout: result.closeout,
|
||||
summary: compactStatusSummary(record(result.summary)),
|
||||
next: result.next,
|
||||
valuesPrinted: false,
|
||||
@@ -1286,6 +1341,7 @@ function renderPlan(result: Record<string, unknown>): RenderedCliResult {
|
||||
const config = record(result.config);
|
||||
const repository = record(result.repository);
|
||||
const consumer = record(result.consumer);
|
||||
const closeout = record(result.closeout);
|
||||
const secrets = arrayRecords(result.secrets);
|
||||
const policy = arrayRecords(result.policy);
|
||||
const lines = [
|
||||
@@ -1300,6 +1356,16 @@ function renderPlan(result: Record<string, unknown>): RenderedCliResult {
|
||||
["cd", "Argo", stringValue(consumer.argoApplication)],
|
||||
]),
|
||||
"",
|
||||
"CLOSEOUT",
|
||||
...table(["GLOBAL_ENABLED", "CONSUMER_CONFIGURED", "REQUIRED", "LANE", "WAIT_S", "MAX_ATTEMPTS"], [[
|
||||
boolText(closeout.enabled),
|
||||
boolText(closeout.configured),
|
||||
boolText(closeout.required),
|
||||
stringValue(closeout.lane),
|
||||
stringValue(closeout.waitTimeoutSeconds),
|
||||
stringValue(closeout.maxAttempts),
|
||||
]]),
|
||||
"",
|
||||
"SECRETS",
|
||||
...table(["ID", "PRESENT", "FINGERPRINT", "VALUES"], secrets.map((item) => [stringValue(item.id), boolText(item.present), stringValue(item.fingerprint), "false"])),
|
||||
"",
|
||||
@@ -1334,6 +1400,7 @@ function renderApply(result: Record<string, unknown>): RenderedCliResult {
|
||||
function renderStatus(result: Record<string, unknown>): RenderedCliResult {
|
||||
const summary = record(result.summary);
|
||||
const consumer = record(result.consumer);
|
||||
const closeout = record(result.closeout);
|
||||
const coverage = arrayRecords(result.coverage);
|
||||
const latest = record(summary.latestPipelineRun);
|
||||
const taskRuns = arrayRecords(summary.taskRuns);
|
||||
@@ -1354,6 +1421,16 @@ function renderStatus(result: Record<string, unknown>): RenderedCliResult {
|
||||
...table(["CONSUMER", "READY", "CRD", "CONTROLLER", "WEBHOOKS", "REPO_URL"], [[stringValue(consumer.id), boolText(summary.ready), boolText(summary.crdPresent), stringValue(summary.controllerReady), stringValue(summary.webhookCount), short(stringValue(repository.url), 56)]]),
|
||||
` repository-condition: ${compactLine(stringValue(summary.repositoryCondition))}`,
|
||||
"",
|
||||
"CLOSEOUT",
|
||||
...table(["GLOBAL_ENABLED", "CONSUMER_CONFIGURED", "REQUIRED", "LANE", "WAIT_S", "MAX_ATTEMPTS"], [[
|
||||
boolText(closeout.enabled),
|
||||
boolText(closeout.configured),
|
||||
boolText(closeout.required),
|
||||
stringValue(closeout.lane),
|
||||
stringValue(closeout.waitTimeoutSeconds),
|
||||
stringValue(closeout.maxAttempts),
|
||||
]]),
|
||||
"",
|
||||
"GITEA HOOKS",
|
||||
...(webhooks.length === 0 ? ["-"] : table(["HOOK", "ACTIVE", "EVENTS", "URL"], webhooks.map((item) => [stringValue(item.id), boolText(item.active), Array.isArray(item.events) ? item.events.join(",") : stringValue(item.events), short(stringValue(item.url), 56)]))),
|
||||
"",
|
||||
|
||||
Reference in New Issue
Block a user