Compare commits

..

No commits in common. "e349bc7cadf0ce967b72ed8e56ae766e39eb2fec" and "908283526230f7daca724e334d50f78dd6884344" have entirely different histories.

4 changed files with 27 additions and 10 deletions

18
fcnet.conflist Normal file
View file

@ -0,0 +1,18 @@
{
"name": "fcnet",
"cniVersion": "0.4.0",
"plugins": [
{
"type": "ptp",
"ipMasq": true,
"ipam": {
"type": "host-local",
"subnet": "192.168.127.0/24",
"resolvConf": "/etc/resolv.conf"
}
},
{
"type": "tc-redirect-tap"
}
]
}

View file

@ -1,5 +1,5 @@
import { execFile as _execFile } from "node:child_process";
import { access, mkdir, open, rename, writeFile } from "node:fs/promises";
import { access, mkdir, open, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { tar2squashfs } from "./tar2squashfs.js";
import { subtle } from "node:crypto";
@ -10,7 +10,7 @@ type RegistrySecret = string;
const getToken = memoizeDownloader(_getToken);
let squashfsDownloads = new Map<string, Promise<string>>();
const cacheDir = "cache/";
const tmpDir = "cache/";
// {
// const image = "gitea.nulo.in/nulo/zulip-checkin-cyborg";
// const tag = "latest";
@ -27,7 +27,7 @@ export function parseImageRef(ref: string): { image: string; tag: string } {
}
export async function downloadImage(image: string, tag: string) {
await mkdir(cacheDir, { recursive: true });
await mkdir(tmpDir, { recursive: true });
const manifest = await getManifest(image, tag);
// sanity check
@ -75,8 +75,7 @@ async function saveSquashfs(
let p = squashfsDownloads.get(key);
if (!p) {
p = (async () => {
const output = join(cacheDir, key);
const progressFile = output + ".downloading";
const output = join(tmpDir, key);
try {
await access(output);
// ya está cacheado
@ -93,7 +92,7 @@ async function saveSquashfs(
const res = await getBlob(image, layer.digest);
return res.body!;
});
await tar2squashfs(layerStreams, progressFile, [
await tar2squashfs(layerStreams, output, [
{
content: configJson,
headers: {
@ -104,7 +103,6 @@ async function saveSquashfs(
},
},
]);
await rename(progressFile, output);
}
return output;
})();

View file

@ -48,9 +48,7 @@ export async function tar2squashfs(streams, output, extraFiles) {
p.pipe(child.stdin);
p.on("error", console.error);
// We reverse the arrays because mksquashfs ignores files if they already exist,
// so we leave the last layers first so they are the ones used instead of the last ones
for (const streamP of [...streams].reverse()) {
for (const streamP of streams) {
const stream = await streamP;
const ex = extract();

View file

@ -3,6 +3,9 @@
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"lib": ["es2023"],
"module": "Node16",
"target": "es2022",
"noEmit": true
}
}