fix: roll git mirror on config changes (#329)
Co-authored-by: Codex <codex@noreply.local>
This commit is contained in:
@@ -847,8 +847,8 @@ function renderInfraManifest(_node: ControlPlaneNodeSpec, target: ControlPlaneTa
|
||||
manifests.push(
|
||||
service(target.gitMirror.serviceReadName, target.gitMirror.namespace, labels, target.gitMirror.servicePort),
|
||||
service(target.gitMirror.serviceWriteName, target.gitMirror.namespace, labels, target.gitMirror.servicePort),
|
||||
gitMirrorDeployment(target.gitMirror.serviceReadName, target.gitMirror.namespace, labels, target, "read"),
|
||||
gitMirrorDeployment(target.gitMirror.serviceWriteName, target.gitMirror.namespace, labels, target, "write"),
|
||||
gitMirrorDeployment(target.gitMirror.serviceReadName, target.gitMirror.namespace, labels, _node, target, "read"),
|
||||
gitMirrorDeployment(target.gitMirror.serviceWriteName, target.gitMirror.namespace, labels, _node, target, "write"),
|
||||
{
|
||||
apiVersion: "tekton.dev/v1",
|
||||
kind: "Pipeline",
|
||||
@@ -886,7 +886,17 @@ function service(name: string, namespace: string, labels: Record<string, string>
|
||||
};
|
||||
}
|
||||
|
||||
function gitMirrorDeployment(name: string, namespace: string, labels: Record<string, string>, target: ControlPlaneTargetSpec, mode: "read" | "write"): Record<string, unknown> {
|
||||
function gitMirrorConfigHash(node: ControlPlaneNodeSpec, target: ControlPlaneTargetSpec): string {
|
||||
return sha256Short(JSON.stringify({
|
||||
repositories: [{ key: target.id, repository: target.source.repository, sourceBranch: target.source.branch, gitopsBranch: target.gitops.branch }],
|
||||
server: gitMirrorServerJs(),
|
||||
status: gitMirrorStatusShell(),
|
||||
sync: gitMirrorSyncShell(node, target),
|
||||
flush: gitMirrorFlushShell(node, target),
|
||||
}));
|
||||
}
|
||||
|
||||
function gitMirrorDeployment(name: string, namespace: string, labels: Record<string, string>, node: ControlPlaneNodeSpec, target: ControlPlaneTargetSpec, mode: "read" | "write"): Record<string, unknown> {
|
||||
return {
|
||||
apiVersion: "apps/v1",
|
||||
kind: "Deployment",
|
||||
@@ -895,7 +905,10 @@ function gitMirrorDeployment(name: string, namespace: string, labels: Record<str
|
||||
replicas: target.gitMirror.deploymentReplicas,
|
||||
selector: { matchLabels: { "app.kubernetes.io/name": name } },
|
||||
template: {
|
||||
metadata: { labels: { ...labels, "app.kubernetes.io/name": name, "hwlab.pikastech.local/git-mirror-mode": mode } },
|
||||
metadata: {
|
||||
labels: { ...labels, "app.kubernetes.io/name": name, "hwlab.pikastech.local/git-mirror-mode": mode },
|
||||
annotations: { "checksum/config": gitMirrorConfigHash(node, target) },
|
||||
},
|
||||
spec: {
|
||||
containers: [{
|
||||
name: "git-mirror",
|
||||
|
||||
Reference in New Issue
Block a user