From 07e03ec89f861117b8038c6937d982a442a75942 Mon Sep 17 00:00:00 2001 From: pikastech Date: Tue, 21 Jul 2026 22:54:09 +0200 Subject: [PATCH] fix: reconcile PaC Argo projects during bootstrap --- .../src/platform-infra-pipelines-as-code.ts | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/scripts/src/platform-infra-pipelines-as-code.ts b/scripts/src/platform-infra-pipelines-as-code.ts index d1f7c94a..0c5c8d92 100644 --- a/scripts/src/platform-infra-pipelines-as-code.ts +++ b/scripts/src/platform-infra-pipelines-as-code.ts @@ -381,6 +381,7 @@ export async function runPlatformInfraPipelinesAsCodeCommand(config: UniDeskConf return options.json || options.full || options.raw ? result : renderApply(result); } if (action === "bootstrap") { + if (args.slice(1).includes("--help") || args.slice(1).includes("-h")) return help("platform-bootstrap"); const options = parseApplyOptions(args.slice(1)); const result = await bootstrap(config, options); return options.full || options.raw ? result : options.json ? projectPacBootstrapResult(result) : renderPacBootstrap(result); @@ -2671,16 +2672,35 @@ function runnerServiceAccountManifest(consumer: PacConsumer): string { function argoBootstrapManifest(consumer: PacConsumer): string { const bootstrap = consumer.argoBootstrap; if (bootstrap === null) return ""; + const labels = { + "app.kubernetes.io/managed-by": "unidesk", + "app.kubernetes.io/part-of": pacPartOf(consumer.id), + }; + const project = bootstrap.project === "default" ? null : { + apiVersion: "argoproj.io/v1alpha1", + kind: "AppProject", + metadata: { + name: bootstrap.project, + namespace: consumer.argoNamespace, + labels, + }, + spec: { + sourceRepos: [bootstrap.repoUrl], + destinations: [{ + server: "https://kubernetes.default.svc", + namespace: bootstrap.destinationNamespace, + }], + clusterResourceWhitelist: [{ group: "*", kind: "*" }], + namespaceResourceWhitelist: [{ group: "*", kind: "*" }], + }, + }; const application = { apiVersion: "argoproj.io/v1alpha1", kind: "Application", metadata: { name: consumer.argoApplication, namespace: consumer.argoNamespace, - labels: { - "app.kubernetes.io/managed-by": "unidesk", - "app.kubernetes.io/part-of": pacPartOf(consumer.id), - }, + labels, }, spec: { project: bootstrap.project, @@ -2699,7 +2719,10 @@ function argoBootstrapManifest(consumer: PacConsumer): string { } : undefined, }, }; - return `${Bun.YAML.stringify(application).trim()}\n`; + return `${[project, application] + .filter((item): item is NonNullable => item !== null) + .map((item) => Bun.YAML.stringify(item).trim()) + .join("\n---\n")}\n`; } function parseLinePair(path: string, usernameLine: number, passwordLine: number): { username: string; password: string } {