fix hwlab d601 global proxy git mirror wiring (#565)
Co-authored-by: Codex <codex@noreply.local>
This commit is contained in:
@@ -56,9 +56,13 @@ nodes:
|
|||||||
endpoint: 127.0.0.1:5000
|
endpoint: 127.0.0.1:5000
|
||||||
egressProxy:
|
egressProxy:
|
||||||
mode: k8s-service-cluster-ip
|
mode: k8s-service-cluster-ip
|
||||||
|
clientName: d601-global-proxy
|
||||||
namespace: platform-infra
|
namespace: platform-infra
|
||||||
serviceName: sub2api-egress-proxy
|
serviceName: sub2api-egress-proxy
|
||||||
port: 10808
|
port: 10808
|
||||||
|
sourceRef: platform-infra/master-vpn-subscription.env
|
||||||
|
sourceKey: MASTER_VPN_SUBSCRIPTION_URL
|
||||||
|
sourceType: subscription-url
|
||||||
noProxy:
|
noProxy:
|
||||||
- localhost
|
- localhost
|
||||||
- 127.0.0.1
|
- 127.0.0.1
|
||||||
@@ -109,6 +113,9 @@ targets:
|
|||||||
flushJobPrefix: git-mirror-hwlab-d601-v03-flush-manual
|
flushJobPrefix: git-mirror-hwlab-d601-v03-flush-manual
|
||||||
readUrl: http://git-mirror-http.devops-infra.svc.cluster.local/pikasTech/HWLAB.git
|
readUrl: http://git-mirror-http.devops-infra.svc.cluster.local/pikasTech/HWLAB.git
|
||||||
writeUrl: http://git-mirror-write.devops-infra.svc.cluster.local/pikasTech/HWLAB.git
|
writeUrl: http://git-mirror-write.devops-infra.svc.cluster.local/pikasTech/HWLAB.git
|
||||||
|
egressProxy:
|
||||||
|
mode: node-global
|
||||||
|
required: true
|
||||||
tekton:
|
tekton:
|
||||||
pipelineName: hwlab-d601-v03-ci-image-publish
|
pipelineName: hwlab-d601-v03-ci-image-publish
|
||||||
serviceAccountName: hwlab-d601-v03-tekton-runner
|
serviceAccountName: hwlab-d601-v03-tekton-runner
|
||||||
|
|||||||
@@ -40,12 +40,21 @@ interface ArgoOptions {
|
|||||||
|
|
||||||
interface ControlPlaneEgressProxySpec {
|
interface ControlPlaneEgressProxySpec {
|
||||||
mode: "k8s-service-cluster-ip";
|
mode: "k8s-service-cluster-ip";
|
||||||
|
clientName: string;
|
||||||
namespace: string;
|
namespace: string;
|
||||||
serviceName: string;
|
serviceName: string;
|
||||||
port: number;
|
port: number;
|
||||||
|
sourceRef: string;
|
||||||
|
sourceKey: string;
|
||||||
|
sourceType: "subscription-url";
|
||||||
noProxy: readonly string[];
|
noProxy: readonly string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ControlPlaneGitMirrorEgressProxySpec {
|
||||||
|
mode: "node-global";
|
||||||
|
required: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
interface ControlPlaneNodeSpec {
|
interface ControlPlaneNodeSpec {
|
||||||
id: string;
|
id: string;
|
||||||
route: string;
|
route: string;
|
||||||
@@ -99,6 +108,7 @@ interface ControlPlaneTargetSpec {
|
|||||||
flushJobPrefix: string;
|
flushJobPrefix: string;
|
||||||
readUrl: string;
|
readUrl: string;
|
||||||
writeUrl: string;
|
writeUrl: string;
|
||||||
|
egressProxy: ControlPlaneGitMirrorEgressProxySpec | null;
|
||||||
};
|
};
|
||||||
tekton: {
|
tekton: {
|
||||||
pipelineName: string;
|
pipelineName: string;
|
||||||
@@ -816,15 +826,30 @@ function execStartPreField(raw: unknown, path: string): readonly (readonly strin
|
|||||||
function egressProxySpec(raw: Record<string, unknown>, path: string): ControlPlaneEgressProxySpec {
|
function egressProxySpec(raw: Record<string, unknown>, path: string): ControlPlaneEgressProxySpec {
|
||||||
const mode = stringField(raw, "mode", path);
|
const mode = stringField(raw, "mode", path);
|
||||||
if (mode !== "k8s-service-cluster-ip") throw new Error(`${path}.mode must be k8s-service-cluster-ip`);
|
if (mode !== "k8s-service-cluster-ip") throw new Error(`${path}.mode must be k8s-service-cluster-ip`);
|
||||||
|
const sourceType = stringField(raw, "sourceType", path);
|
||||||
|
if (sourceType !== "subscription-url") throw new Error(`${path}.sourceType must be subscription-url`);
|
||||||
return {
|
return {
|
||||||
mode,
|
mode,
|
||||||
|
clientName: stringField(raw, "clientName", path),
|
||||||
namespace: stringField(raw, "namespace", path),
|
namespace: stringField(raw, "namespace", path),
|
||||||
serviceName: stringField(raw, "serviceName", path),
|
serviceName: stringField(raw, "serviceName", path),
|
||||||
port: positiveConfigIntegerField(raw, "port", path),
|
port: positiveConfigIntegerField(raw, "port", path),
|
||||||
|
sourceRef: stringField(raw, "sourceRef", path),
|
||||||
|
sourceKey: stringField(raw, "sourceKey", path),
|
||||||
|
sourceType,
|
||||||
noProxy: stringArrayField(raw, "noProxy", path),
|
noProxy: stringArrayField(raw, "noProxy", path),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function gitMirrorEgressProxySpec(raw: Record<string, unknown>, path: string): ControlPlaneGitMirrorEgressProxySpec {
|
||||||
|
const mode = stringField(raw, "mode", path);
|
||||||
|
if (mode !== "node-global") throw new Error(`${path}.mode must be node-global`);
|
||||||
|
return {
|
||||||
|
mode,
|
||||||
|
required: raw.required === undefined ? true : booleanField(raw, "required", path),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function targetSpec(raw: Record<string, unknown>, index: number): ControlPlaneTargetSpec {
|
function targetSpec(raw: Record<string, unknown>, index: number): ControlPlaneTargetSpec {
|
||||||
const path = `targets[${index}]`;
|
const path = `targets[${index}]`;
|
||||||
const source = asRecord(raw.source, `${path}.source`);
|
const source = asRecord(raw.source, `${path}.source`);
|
||||||
@@ -838,6 +863,7 @@ function targetSpec(raw: Record<string, unknown>, index: number): ControlPlaneTa
|
|||||||
const gitMirrorNamespace = stringField(gitMirror, "namespace", `${path}.gitMirror`);
|
const gitMirrorNamespace = stringField(gitMirror, "namespace", `${path}.gitMirror`);
|
||||||
const serviceReadName = stringField(gitMirror, "serviceReadName", `${path}.gitMirror`);
|
const serviceReadName = stringField(gitMirror, "serviceReadName", `${path}.gitMirror`);
|
||||||
const serviceWriteName = stringField(gitMirror, "serviceWriteName", `${path}.gitMirror`);
|
const serviceWriteName = stringField(gitMirror, "serviceWriteName", `${path}.gitMirror`);
|
||||||
|
const gitMirrorEgressProxy = gitMirror.egressProxy === undefined ? null : gitMirrorEgressProxySpec(asRecord(gitMirror.egressProxy, `${path}.gitMirror.egressProxy`), `${path}.gitMirror.egressProxy`);
|
||||||
const sourceRepository = stringField(source, "repository", `${path}.source`);
|
const sourceRepository = stringField(source, "repository", `${path}.source`);
|
||||||
return {
|
return {
|
||||||
id: stringField(raw, "id", path),
|
id: stringField(raw, "id", path),
|
||||||
@@ -863,6 +889,7 @@ function targetSpec(raw: Record<string, unknown>, index: number): ControlPlaneTa
|
|||||||
flushJobPrefix: stringField(gitMirror, "flushJobPrefix", `${path}.gitMirror`),
|
flushJobPrefix: stringField(gitMirror, "flushJobPrefix", `${path}.gitMirror`),
|
||||||
readUrl: optionalStringField(gitMirror, "readUrl", `${path}.gitMirror`) ?? `http://${serviceReadName}.${gitMirrorNamespace}.svc.cluster.local/${sourceRepository}.git`,
|
readUrl: optionalStringField(gitMirror, "readUrl", `${path}.gitMirror`) ?? `http://${serviceReadName}.${gitMirrorNamespace}.svc.cluster.local/${sourceRepository}.git`,
|
||||||
writeUrl: optionalStringField(gitMirror, "writeUrl", `${path}.gitMirror`) ?? `http://${serviceWriteName}.${gitMirrorNamespace}.svc.cluster.local/${sourceRepository}.git`,
|
writeUrl: optionalStringField(gitMirror, "writeUrl", `${path}.gitMirror`) ?? `http://${serviceWriteName}.${gitMirrorNamespace}.svc.cluster.local/${sourceRepository}.git`,
|
||||||
|
egressProxy: gitMirrorEgressProxy,
|
||||||
},
|
},
|
||||||
tekton: {
|
tekton: {
|
||||||
pipelineName: stringField(tekton, "pipelineName", `${path}.tekton`),
|
pipelineName: stringField(tekton, "pipelineName", `${path}.tekton`),
|
||||||
@@ -1175,8 +1202,13 @@ NODE
|
|||||||
}
|
}
|
||||||
|
|
||||||
function gitMirrorProxyPrelude(node: ControlPlaneNodeSpec, target: ControlPlaneTargetSpec): string {
|
function gitMirrorProxyPrelude(node: ControlPlaneNodeSpec, target: ControlPlaneTargetSpec): string {
|
||||||
const proxyHost = node.egressProxy?.serviceName === undefined ? "127.0.0.1" : `${node.egressProxy.serviceName}.${node.egressProxy.namespace}.svc.cluster.local`;
|
if (target.gitMirror.egressProxy?.mode !== "node-global") throw new Error(`targets.${target.id}.gitMirror.egressProxy.mode must be node-global; git-mirror GitHub SSH no longer falls back to localhost`);
|
||||||
const proxyPort = node.egressProxy?.port ?? 10808;
|
if (target.gitMirror.egressProxy.required && node.egressProxy === null) throw new Error(`nodes.${node.id}.egressProxy is required by targets.${target.id}.gitMirror.egressProxy`);
|
||||||
|
if (node.egressProxy === null) throw new Error(`nodes.${node.id}.egressProxy is missing; git-mirror GitHub SSH no longer falls back to localhost`);
|
||||||
|
const proxyHost = `${node.egressProxy.serviceName}.${node.egressProxy.namespace}.svc.cluster.local`;
|
||||||
|
const proxyPort = node.egressProxy.port;
|
||||||
|
const proxyUrl = `http://${proxyHost}:${proxyPort}`;
|
||||||
|
const noProxy = node.egressProxy.noProxy.join(",");
|
||||||
return [
|
return [
|
||||||
"mkdir -p /root/.ssh",
|
"mkdir -p /root/.ssh",
|
||||||
"cp /git-ssh/ssh-privatekey /root/.ssh/id_rsa",
|
"cp /git-ssh/ssh-privatekey /root/.ssh/id_rsa",
|
||||||
@@ -1212,6 +1244,14 @@ function gitMirrorProxyPrelude(node: ControlPlaneNodeSpec, target: ControlPlaneT
|
|||||||
"socket.on('close', () => process.exit(0));",
|
"socket.on('close', () => process.exit(0));",
|
||||||
"NODE_PROXY",
|
"NODE_PROXY",
|
||||||
"chmod 0700 /tmp/hwlab-github-proxy-connect.cjs",
|
"chmod 0700 /tmp/hwlab-github-proxy-connect.cjs",
|
||||||
|
`export HTTP_PROXY=${shQuote(proxyUrl)}`,
|
||||||
|
`export HTTPS_PROXY=${shQuote(proxyUrl)}`,
|
||||||
|
`export ALL_PROXY=${shQuote(proxyUrl)}`,
|
||||||
|
`export http_proxy=${shQuote(proxyUrl)}`,
|
||||||
|
`export https_proxy=${shQuote(proxyUrl)}`,
|
||||||
|
`export all_proxy=${shQuote(proxyUrl)}`,
|
||||||
|
`export NO_PROXY=${shQuote(noProxy)}`,
|
||||||
|
`export no_proxy=${shQuote(noProxy)}`,
|
||||||
`export GIT_SSH_COMMAND=${shQuote(`ssh -i /root/.ssh/id_rsa -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=/root/.ssh/known_hosts -o ConnectTimeout=15 -o ServerAliveInterval=5 -o ServerAliveCountMax=1 -o ProxyCommand='node /tmp/hwlab-github-proxy-connect.cjs ${proxyHost} ${proxyPort} %h %p'`)}`,
|
`export GIT_SSH_COMMAND=${shQuote(`ssh -i /root/.ssh/id_rsa -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=/root/.ssh/known_hosts -o ConnectTimeout=15 -o ServerAliveInterval=5 -o ServerAliveCountMax=1 -o ProxyCommand='node /tmp/hwlab-github-proxy-connect.cjs ${proxyHost} ${proxyPort} %h %p'`)}`,
|
||||||
`repository=${shQuote(target.source.repository)}`,
|
`repository=${shQuote(target.source.repository)}`,
|
||||||
`source_branch=${shQuote(target.source.branch)}`,
|
`source_branch=${shQuote(target.source.branch)}`,
|
||||||
@@ -1411,6 +1451,7 @@ function expectedSummary(node: ControlPlaneNodeSpec, target: ControlPlaneTargetS
|
|||||||
servicePort: target.gitMirror.servicePort,
|
servicePort: target.gitMirror.servicePort,
|
||||||
deploymentReplicas: target.gitMirror.deploymentReplicas,
|
deploymentReplicas: target.gitMirror.deploymentReplicas,
|
||||||
syncConfigMap: target.gitMirror.syncConfigMapName,
|
syncConfigMap: target.gitMirror.syncConfigMapName,
|
||||||
|
egressProxy: target.gitMirror.egressProxy,
|
||||||
statusSummaryKeys: ["localSource", "githubSource", "localGitops", "githubGitops", "pendingFlush", "flushNeeded", "githubInSync"],
|
statusSummaryKeys: ["localSource", "githubSource", "localGitops", "githubGitops", "pendingFlush", "flushNeeded", "githubInSync"],
|
||||||
},
|
},
|
||||||
pipeline: target.tekton.pipelineName,
|
pipeline: target.tekton.pipelineName,
|
||||||
|
|||||||
@@ -239,12 +239,26 @@ interface NodeRuntimeGitMirrorTargetSpec {
|
|||||||
cachePvcName: string;
|
cachePvcName: string;
|
||||||
cacheHostPath: string | null;
|
cacheHostPath: string | null;
|
||||||
secretName: string;
|
secretName: string;
|
||||||
|
syncConfigMapName: string;
|
||||||
syncJobPrefix: string;
|
syncJobPrefix: string;
|
||||||
flushJobPrefix: string;
|
flushJobPrefix: string;
|
||||||
toolsImage: string;
|
toolsImage: string;
|
||||||
sourceRepository: string;
|
sourceRepository: string;
|
||||||
sourceBranch: string;
|
sourceBranch: string;
|
||||||
gitopsBranch: string;
|
gitopsBranch: string;
|
||||||
|
egressProxy: NodeRuntimeGitMirrorEgressProxySpec;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface NodeRuntimeGitMirrorEgressProxySpec {
|
||||||
|
mode: "k8s-service-cluster-ip";
|
||||||
|
clientName: string;
|
||||||
|
namespace: string;
|
||||||
|
serviceName: string;
|
||||||
|
port: number;
|
||||||
|
sourceRef: string;
|
||||||
|
sourceKey: string;
|
||||||
|
sourceType: "subscription-url";
|
||||||
|
noProxy: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const MASTER_ADMIN_API_KEY_KEY = "api-key";
|
const MASTER_ADMIN_API_KEY_KEY = "api-key";
|
||||||
@@ -3228,13 +3242,14 @@ function nodeRuntimeGitMirrorJobManifest(mirror: NodeRuntimeGitMirrorTargetSpec,
|
|||||||
volumes: [
|
volumes: [
|
||||||
{ name: "cache", ...(mirror.cacheHostPath === null ? { persistentVolumeClaim: { claimName: mirror.cachePvcName } } : { hostPath: { path: mirror.cacheHostPath, type: "DirectoryOrCreate" } }) },
|
{ name: "cache", ...(mirror.cacheHostPath === null ? { persistentVolumeClaim: { claimName: mirror.cachePvcName } } : { hostPath: { path: mirror.cacheHostPath, type: "DirectoryOrCreate" } }) },
|
||||||
{ name: "git-ssh", secret: { secretName: mirror.secretName, defaultMode: 0o400 } },
|
{ name: "git-ssh", secret: { secretName: mirror.secretName, defaultMode: 0o400 } },
|
||||||
{ name: "script", configMap: { name: "git-mirror-sync-script", defaultMode: 0o755 } },
|
{ name: "script", configMap: { name: mirror.syncConfigMapName, defaultMode: 0o755 } },
|
||||||
],
|
],
|
||||||
containers: [{
|
containers: [{
|
||||||
name: action,
|
name: action,
|
||||||
image: mirror.toolsImage,
|
image: mirror.toolsImage,
|
||||||
imagePullPolicy: "IfNotPresent",
|
imagePullPolicy: "IfNotPresent",
|
||||||
command: [action === "sync" ? "/script/sync.sh" : "/script/flush.sh"],
|
command: [action === "sync" ? "/script/sync.sh" : "/script/flush.sh"],
|
||||||
|
env: nodeRuntimeGitMirrorProxyEnv(mirror),
|
||||||
volumeMounts: [
|
volumeMounts: [
|
||||||
{ name: "cache", mountPath: "/cache" },
|
{ name: "cache", mountPath: "/cache" },
|
||||||
{ name: "git-ssh", mountPath: "/git-ssh", readOnly: true },
|
{ name: "git-ssh", mountPath: "/git-ssh", readOnly: true },
|
||||||
@@ -3247,6 +3262,22 @@ function nodeRuntimeGitMirrorJobManifest(mirror: NodeRuntimeGitMirrorTargetSpec,
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function nodeRuntimeGitMirrorProxyEnv(mirror: NodeRuntimeGitMirrorTargetSpec): Record<string, string>[] {
|
||||||
|
const proxy = mirror.egressProxy;
|
||||||
|
const proxyUrl = `http://${proxy.serviceName}.${proxy.namespace}.svc.cluster.local:${proxy.port}`;
|
||||||
|
const noProxy = proxy.noProxy.join(",");
|
||||||
|
return [
|
||||||
|
{ name: "HTTP_PROXY", value: proxyUrl },
|
||||||
|
{ name: "HTTPS_PROXY", value: proxyUrl },
|
||||||
|
{ name: "ALL_PROXY", value: proxyUrl },
|
||||||
|
{ name: "http_proxy", value: proxyUrl },
|
||||||
|
{ name: "https_proxy", value: proxyUrl },
|
||||||
|
{ name: "all_proxy", value: proxyUrl },
|
||||||
|
{ name: "NO_PROXY", value: noProxy },
|
||||||
|
{ name: "no_proxy", value: noProxy },
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
function nodeRuntimeControlPlaneStatus(scoped: ReturnType<typeof parseNodeScopedDelegatedOptions>): Record<string, unknown> {
|
function nodeRuntimeControlPlaneStatus(scoped: ReturnType<typeof parseNodeScopedDelegatedOptions>): Record<string, unknown> {
|
||||||
const spec = scoped.spec;
|
const spec = scoped.spec;
|
||||||
const sourceCommitOverride = optionValue(scoped.originalArgs, "--source-commit");
|
const sourceCommitOverride = optionValue(scoped.originalArgs, "--source-commit");
|
||||||
@@ -5831,10 +5862,16 @@ function externalPostgresSecretStatus(spec: HwlabRuntimeLaneSpec, namespaceExist
|
|||||||
function nodeRuntimeGitMirrorTarget(spec: HwlabRuntimeLaneSpec): NodeRuntimeGitMirrorTargetSpec {
|
function nodeRuntimeGitMirrorTarget(spec: HwlabRuntimeLaneSpec): NodeRuntimeGitMirrorTargetSpec {
|
||||||
const configPath = rootPath(HWLAB_NODE_CONTROL_PLANE_CONFIG_PATH);
|
const configPath = rootPath(HWLAB_NODE_CONTROL_PLANE_CONFIG_PATH);
|
||||||
const parsed = record(Bun.YAML.parse(readFileSync(configPath, "utf8")) as unknown);
|
const parsed = record(Bun.YAML.parse(readFileSync(configPath, "utf8")) as unknown);
|
||||||
|
const nodes = record(parsed.nodes);
|
||||||
|
const node = record(nodes[spec.nodeId]);
|
||||||
|
const nodeEgressProxy = nodeRuntimeGitMirrorEgressProxySpec(record(node.egressProxy), `nodes.${spec.nodeId}.egressProxy`);
|
||||||
const targets = Array.isArray(parsed.targets) ? parsed.targets : [];
|
const targets = Array.isArray(parsed.targets) ? parsed.targets : [];
|
||||||
const target = targets.map((item) => record(item)).find((item) => item.node === spec.nodeId && item.lane === spec.lane);
|
const target = targets.map((item) => record(item)).find((item) => item.node === spec.nodeId && item.lane === spec.lane);
|
||||||
if (target === undefined) throw new Error(`no gitMirror target for node=${spec.nodeId} lane=${spec.lane} in ${HWLAB_NODE_CONTROL_PLANE_CONFIG_PATH}`);
|
if (target === undefined) throw new Error(`no gitMirror target for node=${spec.nodeId} lane=${spec.lane} in ${HWLAB_NODE_CONTROL_PLANE_CONFIG_PATH}`);
|
||||||
const gitMirror = record(target.gitMirror);
|
const gitMirror = record(target.gitMirror);
|
||||||
|
const gitMirrorEgressProxy = record(gitMirror.egressProxy);
|
||||||
|
if (stringValue(gitMirrorEgressProxy.mode, "gitMirror.egressProxy.mode") !== "node-global") throw new Error(`gitMirror.egressProxy.mode must be node-global for node=${spec.nodeId} lane=${spec.lane}`);
|
||||||
|
if (gitMirrorEgressProxy.required !== true) throw new Error(`gitMirror.egressProxy.required must be true for node=${spec.nodeId} lane=${spec.lane}`);
|
||||||
const source = record(target.source);
|
const source = record(target.source);
|
||||||
const gitops = record(target.gitops);
|
const gitops = record(target.gitops);
|
||||||
const tekton = record(target.tekton);
|
const tekton = record(target.tekton);
|
||||||
@@ -5849,12 +5886,37 @@ function nodeRuntimeGitMirrorTarget(spec: HwlabRuntimeLaneSpec): NodeRuntimeGitM
|
|||||||
cachePvcName: stringValue(gitMirror.cachePvcName, "gitMirror.cachePvcName"),
|
cachePvcName: stringValue(gitMirror.cachePvcName, "gitMirror.cachePvcName"),
|
||||||
cacheHostPath: optionalStringValue(gitMirror.cacheHostPath, "gitMirror.cacheHostPath"),
|
cacheHostPath: optionalStringValue(gitMirror.cacheHostPath, "gitMirror.cacheHostPath"),
|
||||||
secretName: stringValue(gitMirror.secretName, "gitMirror.secretName"),
|
secretName: stringValue(gitMirror.secretName, "gitMirror.secretName"),
|
||||||
|
syncConfigMapName: stringValue(gitMirror.syncConfigMapName, "gitMirror.syncConfigMapName"),
|
||||||
syncJobPrefix: stringValue(gitMirror.syncJobPrefix, "gitMirror.syncJobPrefix"),
|
syncJobPrefix: stringValue(gitMirror.syncJobPrefix, "gitMirror.syncJobPrefix"),
|
||||||
flushJobPrefix: stringValue(gitMirror.flushJobPrefix, "gitMirror.flushJobPrefix"),
|
flushJobPrefix: stringValue(gitMirror.flushJobPrefix, "gitMirror.flushJobPrefix"),
|
||||||
toolsImage: stringValue(toolsImage.output, "tekton.toolsImage.output"),
|
toolsImage: stringValue(toolsImage.output, "tekton.toolsImage.output"),
|
||||||
sourceRepository: stringValue(source.repository, "source.repository"),
|
sourceRepository: stringValue(source.repository, "source.repository"),
|
||||||
sourceBranch: stringValue(source.branch, "source.branch"),
|
sourceBranch: stringValue(source.branch, "source.branch"),
|
||||||
gitopsBranch: stringValue(gitops.branch, "gitops.branch"),
|
gitopsBranch: stringValue(gitops.branch, "gitops.branch"),
|
||||||
|
egressProxy: nodeEgressProxy,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function nodeRuntimeGitMirrorEgressProxySpec(raw: Record<string, unknown>, path: string): NodeRuntimeGitMirrorEgressProxySpec {
|
||||||
|
const mode = stringValue(raw.mode, `${path}.mode`);
|
||||||
|
if (mode !== "k8s-service-cluster-ip") throw new Error(`${path}.mode must be k8s-service-cluster-ip`);
|
||||||
|
const port = Number(raw.port);
|
||||||
|
if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error(`${path}.port must be a TCP port`);
|
||||||
|
const sourceType = stringValue(raw.sourceType, `${path}.sourceType`);
|
||||||
|
if (sourceType !== "subscription-url") throw new Error(`${path}.sourceType must be subscription-url`);
|
||||||
|
const noProxyRaw = raw.noProxy;
|
||||||
|
if (!Array.isArray(noProxyRaw)) throw new Error(`${path}.noProxy must be an array`);
|
||||||
|
const noProxy = noProxyRaw.map((item, index) => stringValue(item, `${path}.noProxy[${index}]`));
|
||||||
|
return {
|
||||||
|
mode,
|
||||||
|
clientName: stringValue(raw.clientName, `${path}.clientName`),
|
||||||
|
namespace: stringValue(raw.namespace, `${path}.namespace`),
|
||||||
|
serviceName: stringValue(raw.serviceName, `${path}.serviceName`),
|
||||||
|
port,
|
||||||
|
sourceRef: stringValue(raw.sourceRef, `${path}.sourceRef`),
|
||||||
|
sourceKey: stringValue(raw.sourceKey, `${path}.sourceKey`),
|
||||||
|
sourceType,
|
||||||
|
noProxy,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user