The bed resolves an artifact the way the builder would
It pre-builds these images and stocks them, which is the lab standing in for the builder — so it must do what the builder does and replace the artifact with the reference the machine holds. Without it the unresolved field travels to the machine and the whole declaration is refused.
This commit is contained in:
@@ -66,7 +66,7 @@ import {
|
||||
bootstrapBinaryPath, hostBinaryPath, placeBootstrap, BOOTSTRAP_PATH, HOST_PATH,
|
||||
} from "../../src/lifecycle/place.ts";
|
||||
import { labIsUsable, destroyAll, substrateBundle, onTheMachine } from "./harness.ts";
|
||||
import type { HeldImage } from "../../src/pinning.ts";
|
||||
import { referenceFor, type HeldImage } from "../../src/pinning.ts";
|
||||
|
||||
const capability = await labIsUsable();
|
||||
const binary = hostBinaryPath();
|
||||
@@ -359,11 +359,29 @@ function bundleFor(images: HeldImage[]): string {
|
||||
function loadManifest(name: string): { manifest: string; broker: boolean } {
|
||||
const path = resolve(catalogDir, name, "module.json");
|
||||
const m = JSON.parse(readFileSync(path, "utf8")) as {
|
||||
resources?: { type: string; image?: string; ports?: string[] }[];
|
||||
resources?: { type: string; image?: string; artifact?: string; ports?: string[] }[];
|
||||
};
|
||||
const remap = REMAP[name] ?? {};
|
||||
for (const r of m.resources ?? []) {
|
||||
if (r.type !== "container") continue;
|
||||
// **A container naming an artifact is a module the mesh builds, and this bed does not build.**
|
||||
// It pre-builds the same images on the workstation and stocks them, which is the lab standing
|
||||
// in for the builder — so it does here what the builder does: replace the artifact with the
|
||||
// reference the machine actually holds. Without this the unresolved field travels to the
|
||||
// machine, whose declaration language has no such field, and the whole declaration is refused.
|
||||
//
|
||||
// The repository is `mesh-runtime-<module>`, which is not a guess: it is what this repository's
|
||||
// own `scripts/build-module-runtime.sh <module>` produces and what the scenarios stock by name.
|
||||
if (typeof r.artifact === "string" && typeof r.image !== "string") {
|
||||
const reference = referenceFor(held, `mesh-runtime-${name}`);
|
||||
assert.ok(reference,
|
||||
`${name} declares the "${r.artifact}" artifact and this scenario stocked no ` +
|
||||
`mesh-runtime-${name}. The mesh would have to build it, and this bed does not build — ` +
|
||||
`add it to the machine's images: in the scenario, or build it with ` +
|
||||
`scripts/build-module-runtime.sh ${name}`);
|
||||
r.image = reference;
|
||||
delete r.artifact;
|
||||
}
|
||||
if (typeof r.image === "string") r.image = pinned(r.image);
|
||||
if (Array.isArray(r.ports)) r.ports = r.ports.map((p) => remap[p] ?? p);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user