feat: add v02 device-pod env reuse boot path
This commit is contained in:
@@ -24,6 +24,7 @@ const digestPattern = /^sha256:[a-f0-9]{64}$/;
|
||||
const commitPattern = /^[a-f0-9]{7,40}$/;
|
||||
|
||||
const publishReadyStatuses = new Set(["published", "reused"]);
|
||||
const v02EnvReuseRuntimeMode = "env-reuse-git-mirror-checkout";
|
||||
|
||||
const v02RuntimeServiceIds = Object.freeze([
|
||||
"hwlab-cloud-api",
|
||||
@@ -202,23 +203,50 @@ function artifactCatalogSkeleton({ args, target, registryPrefix = defaultRegistr
|
||||
},
|
||||
allowedProfiles: [environment],
|
||||
forbiddenProfiles: args.lane === "v02" ? ["dev", "prod"] : ["prod"],
|
||||
services: serviceIdsForLane(args.lane).map((serviceId) => ({
|
||||
serviceId,
|
||||
commitId: target.imageTag,
|
||||
sourceCommitId: target.commitId,
|
||||
image: targetImage(serviceId, target.imageTag, registryPrefix),
|
||||
imageTag: target.imageTag,
|
||||
digest: "not_published",
|
||||
publishState: "skeleton-only",
|
||||
profile: environment,
|
||||
namespace,
|
||||
healthPath: "/health/live",
|
||||
sourceState: "source-present",
|
||||
publishEnabled: true,
|
||||
artifactRequired: true,
|
||||
artifactScope: "required",
|
||||
notPublishedReason: "publish_not_run"
|
||||
}))
|
||||
services: serviceIdsForLane(args.lane).map((serviceId) => catalogSkeletonService({ args, serviceId, target, registryPrefix, environment, namespace }))
|
||||
};
|
||||
}
|
||||
|
||||
function catalogSkeletonService({ args, serviceId, target, registryPrefix, environment, namespace }) {
|
||||
const base = {
|
||||
serviceId,
|
||||
commitId: target.imageTag,
|
||||
sourceCommitId: target.commitId,
|
||||
image: targetImage(serviceId, target.imageTag, registryPrefix),
|
||||
imageTag: target.imageTag,
|
||||
digest: "not_published",
|
||||
publishState: "skeleton-only",
|
||||
profile: environment,
|
||||
namespace,
|
||||
healthPath: "/health/live",
|
||||
sourceState: "source-present",
|
||||
publishEnabled: true,
|
||||
artifactRequired: true,
|
||||
artifactScope: "required",
|
||||
notPublishedReason: "publish_not_run"
|
||||
};
|
||||
if (args.lane !== "v02" || serviceId !== "hwlab-device-pod") return base;
|
||||
const environmentImage = targetImage(`${serviceId}-env`, `env-${String(target.commitId).slice(0, 12)}`, registryPrefix);
|
||||
return {
|
||||
...base,
|
||||
image: environmentImage,
|
||||
imageTag: parseTaggedImage(environmentImage, `${serviceId} environment image`).tag,
|
||||
runtimeMode: v02EnvReuseRuntimeMode,
|
||||
envReuse: true,
|
||||
environmentImage,
|
||||
environmentDigest: "not_published",
|
||||
environmentInputHash: null,
|
||||
bootRepo: "git@github.com:pikasTech/HWLAB.git",
|
||||
bootCommit: target.commitId,
|
||||
bootSh: `deploy/runtime/boot/${serviceId}.sh`,
|
||||
codeInputHash: null,
|
||||
bootEnvEvidence: {
|
||||
env: {
|
||||
HWLAB_BOOT_REPO: "git@github.com:pikasTech/HWLAB.git",
|
||||
HWLAB_BOOT_COMMIT: target.commitId,
|
||||
HWLAB_BOOT_SH: `deploy/runtime/boot/${serviceId}.sh`
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -343,6 +371,18 @@ function publishRecordsFromReport(report, target, serviceIds = SERVICE_IDS) {
|
||||
repositoryDigest: service.repositoryDigest ?? `${image.repository}@${service.digest}`,
|
||||
componentCommitId: service.componentCommitId ?? null,
|
||||
componentInputHash: service.componentInputHash ?? null,
|
||||
runtimeMode: service.runtimeMode ?? "service-image",
|
||||
envReuse: service.envReuse === true,
|
||||
envChanged: service.envChanged ?? null,
|
||||
codeChanged: service.codeChanged ?? null,
|
||||
environmentImage: service.environmentImage ?? null,
|
||||
environmentDigest: service.environmentDigest ?? null,
|
||||
environmentInputHash: service.environmentInputHash ?? null,
|
||||
codeInputHash: service.codeInputHash ?? null,
|
||||
bootRepo: service.bootRepo ?? null,
|
||||
bootCommit: service.bootCommit ?? null,
|
||||
bootSh: service.bootSh ?? null,
|
||||
bootEnvEvidence: service.bootEnvEvidence ?? null,
|
||||
dockerfileHash: service.dockerfileHash ?? null,
|
||||
baseImageReference: service.baseImageReference ?? null,
|
||||
baseImageDigest: service.baseImageDigest ?? null,
|
||||
@@ -390,8 +430,14 @@ function refreshDocuments({ deploy, catalog, target, publishRecords, serviceInve
|
||||
const inventory = inventoryByService.get(serviceId);
|
||||
const required = requiredIds.has(serviceId);
|
||||
const publishRecord = records?.get(serviceId) ?? null;
|
||||
const image = publishRecord?.image ?? targetImage(serviceId, target.imageTag, registryPrefix);
|
||||
const imageTag = publishRecord?.imageTag ?? target.imageTag;
|
||||
const envReuse = publishRecord?.runtimeMode === v02EnvReuseRuntimeMode
|
||||
|| publishRecord?.envReuse === true
|
||||
|| catalogService.runtimeMode === v02EnvReuseRuntimeMode
|
||||
|| catalogService.envReuse === true;
|
||||
const fallbackEnvTag = `env-${String(publishRecord?.environmentInputHash ?? catalogService.environmentInputHash ?? target.commitId).slice(0, 12)}`;
|
||||
const fallbackImage = envReuse ? targetImage(`${serviceId}-env`, fallbackEnvTag, registryPrefix) : targetImage(serviceId, target.imageTag, registryPrefix);
|
||||
const image = publishRecord?.image ?? publishRecord?.environmentImage ?? fallbackImage;
|
||||
const imageTag = publishRecord?.imageTag ?? parseTaggedImage(image, `${serviceId} catalog image`).tag;
|
||||
const serviceCommitId = shortCommitForRecord(publishRecord, target);
|
||||
|
||||
catalogService.commitId = serviceCommitId;
|
||||
@@ -402,6 +448,18 @@ function refreshDocuments({ deploy, catalog, target, publishRecords, serviceInve
|
||||
catalogService.digest = publishRecord?.digest ?? "not_published";
|
||||
catalogService.componentCommitId = publishRecord?.componentCommitId ?? catalogService.componentCommitId ?? null;
|
||||
catalogService.componentInputHash = publishRecord?.componentInputHash ?? catalogService.componentInputHash ?? null;
|
||||
catalogService.runtimeMode = publishRecord?.runtimeMode ?? catalogService.runtimeMode ?? "service-image";
|
||||
catalogService.envReuse = envReuse;
|
||||
catalogService.envChanged = publishRecord?.envChanged ?? catalogService.envChanged ?? null;
|
||||
catalogService.codeChanged = publishRecord?.codeChanged ?? catalogService.codeChanged ?? null;
|
||||
catalogService.environmentImage = publishRecord?.environmentImage ?? (envReuse ? image : catalogService.environmentImage ?? null);
|
||||
catalogService.environmentDigest = publishRecord?.environmentDigest ?? catalogService.environmentDigest ?? null;
|
||||
catalogService.environmentInputHash = publishRecord?.environmentInputHash ?? catalogService.environmentInputHash ?? null;
|
||||
catalogService.codeInputHash = publishRecord?.codeInputHash ?? catalogService.codeInputHash ?? null;
|
||||
catalogService.bootRepo = publishRecord?.bootRepo ?? catalogService.bootRepo ?? null;
|
||||
catalogService.bootCommit = publishRecord?.bootCommit ?? target.commitId;
|
||||
catalogService.bootSh = publishRecord?.bootSh ?? catalogService.bootSh ?? null;
|
||||
catalogService.bootEnvEvidence = publishRecord?.bootEnvEvidence ?? catalogService.bootEnvEvidence ?? null;
|
||||
catalogService.dockerfileHash = publishRecord?.dockerfileHash ?? catalogService.dockerfileHash ?? null;
|
||||
catalogService.baseImageReference = publishRecord?.baseImageReference ?? catalogService.baseImageReference ?? null;
|
||||
catalogService.baseImageDigest = publishRecord?.baseImageDigest ?? catalogService.baseImageDigest ?? null;
|
||||
@@ -425,6 +483,12 @@ function refreshDocuments({ deploy, catalog, target, publishRecords, serviceInve
|
||||
digest: catalogService.digest,
|
||||
componentCommitId: catalogService.componentCommitId,
|
||||
componentInputHash: catalogService.componentInputHash,
|
||||
runtimeMode: catalogService.runtimeMode,
|
||||
environmentDigest: catalogService.environmentDigest ?? null,
|
||||
environmentInputHash: catalogService.environmentInputHash ?? null,
|
||||
codeInputHash: catalogService.codeInputHash ?? null,
|
||||
bootCommit: catalogService.bootCommit ?? null,
|
||||
bootSh: catalogService.bootSh ?? null,
|
||||
dockerfileHash: catalogService.dockerfileHash,
|
||||
ciAffected: catalogService.ciAffected,
|
||||
ciReason: catalogService.ciReason,
|
||||
|
||||
Reference in New Issue
Block a user