forked from mtusi2026/mtusi2026lab7
Prepare verified laboratory 7 implementation and evidence
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { writeFile } from "node:fs/promises";
|
||||
import { resolve } from "node:path";
|
||||
import { root, run, requireThat, safeFailure } from "./runtime";
|
||||
try {
|
||||
const ref = "openbao/openbao:2.7.2",
|
||||
repo = "openbao/openbao";
|
||||
const index = JSON.parse(
|
||||
(await run(["docker", "buildx", "imagetools", "inspect", ref, "--raw"]))
|
||||
.out,
|
||||
);
|
||||
const digest = index.manifests?.find(
|
||||
(x: any) =>
|
||||
x.platform?.os === "linux" && x.platform?.architecture === "amd64",
|
||||
)?.digest;
|
||||
requireThat(/^sha256:[a-f0-9]{64}$/.test(digest), "NO_AMD64_MANIFEST");
|
||||
const manifest = JSON.parse(
|
||||
(
|
||||
await run([
|
||||
"docker",
|
||||
"buildx",
|
||||
"imagetools",
|
||||
"inspect",
|
||||
repo + "@" + digest,
|
||||
"--raw",
|
||||
])
|
||||
).out,
|
||||
);
|
||||
const bytes = manifest.layers.reduce(
|
||||
(sum: number, layer: any) => sum + layer.size,
|
||||
0,
|
||||
);
|
||||
await writeFile(
|
||||
resolve(root, "OPENBAO-IMAGE.json"),
|
||||
JSON.stringify(
|
||||
{
|
||||
ref,
|
||||
image: repo + "@" + digest,
|
||||
compressed_bytes: bytes,
|
||||
platform: "linux/amd64",
|
||||
},
|
||||
null,
|
||||
2,
|
||||
) + "\n",
|
||||
);
|
||||
console.log(JSON.stringify({ ref, compressed_bytes: bytes, digest }));
|
||||
} catch (e) {
|
||||
safeFailure(e);
|
||||
}
|
||||
Reference in New Issue
Block a user