Compare commits
No commits in common. "e349bc7cadf0ce967b72ed8e56ae766e39eb2fec" and "908283526230f7daca724e334d50f78dd6884344" have entirely different histories.
e349bc7cad
...
9082835262
4 changed files with 27 additions and 10 deletions
18
fcnet.conflist
Normal file
18
fcnet.conflist
Normal 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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
import { execFile as _execFile } from "node:child_process";
|
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 { join } from "node:path";
|
||||||
import { tar2squashfs } from "./tar2squashfs.js";
|
import { tar2squashfs } from "./tar2squashfs.js";
|
||||||
import { subtle } from "node:crypto";
|
import { subtle } from "node:crypto";
|
||||||
|
@ -10,7 +10,7 @@ type RegistrySecret = string;
|
||||||
const getToken = memoizeDownloader(_getToken);
|
const getToken = memoizeDownloader(_getToken);
|
||||||
let squashfsDownloads = new Map<string, Promise<string>>();
|
let squashfsDownloads = new Map<string, Promise<string>>();
|
||||||
|
|
||||||
const cacheDir = "cache/";
|
const tmpDir = "cache/";
|
||||||
// {
|
// {
|
||||||
// const image = "gitea.nulo.in/nulo/zulip-checkin-cyborg";
|
// const image = "gitea.nulo.in/nulo/zulip-checkin-cyborg";
|
||||||
// const tag = "latest";
|
// const tag = "latest";
|
||||||
|
@ -27,7 +27,7 @@ export function parseImageRef(ref: string): { image: string; tag: string } {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function downloadImage(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);
|
const manifest = await getManifest(image, tag);
|
||||||
|
|
||||||
// sanity check
|
// sanity check
|
||||||
|
@ -75,8 +75,7 @@ async function saveSquashfs(
|
||||||
let p = squashfsDownloads.get(key);
|
let p = squashfsDownloads.get(key);
|
||||||
if (!p) {
|
if (!p) {
|
||||||
p = (async () => {
|
p = (async () => {
|
||||||
const output = join(cacheDir, key);
|
const output = join(tmpDir, key);
|
||||||
const progressFile = output + ".downloading";
|
|
||||||
try {
|
try {
|
||||||
await access(output);
|
await access(output);
|
||||||
// ya está cacheado
|
// ya está cacheado
|
||||||
|
@ -93,7 +92,7 @@ async function saveSquashfs(
|
||||||
const res = await getBlob(image, layer.digest);
|
const res = await getBlob(image, layer.digest);
|
||||||
return res.body!;
|
return res.body!;
|
||||||
});
|
});
|
||||||
await tar2squashfs(layerStreams, progressFile, [
|
await tar2squashfs(layerStreams, output, [
|
||||||
{
|
{
|
||||||
content: configJson,
|
content: configJson,
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -104,7 +103,6 @@ async function saveSquashfs(
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
await rename(progressFile, output);
|
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -48,9 +48,7 @@ export async function tar2squashfs(streams, output, extraFiles) {
|
||||||
p.pipe(child.stdin);
|
p.pipe(child.stdin);
|
||||||
p.on("error", console.error);
|
p.on("error", console.error);
|
||||||
|
|
||||||
// We reverse the arrays because mksquashfs ignores files if they already exist,
|
for (const streamP of streams) {
|
||||||
// so we leave the last layers first so they are the ones used instead of the last ones
|
|
||||||
for (const streamP of [...streams].reverse()) {
|
|
||||||
const stream = await streamP;
|
const stream = await streamP;
|
||||||
const ex = extract();
|
const ex = extract();
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"checkJs": true,
|
"checkJs": true,
|
||||||
|
"lib": ["es2023"],
|
||||||
|
"module": "Node16",
|
||||||
|
"target": "es2022",
|
||||||
"noEmit": true
|
"noEmit": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue