Merge pull request #2817 from pikasTech/fix/pac-argo-appproject-bootstrap
修复 PaC bootstrap 的 Argo AppProject 漂移
This commit is contained in:
@@ -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<typeof item> => 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 } {
|
||||
|
||||
Reference in New Issue
Block a user