IF Commons GitHub

physical/assets

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0004-netboot-physical FR-002

The boot files and the installer image on the boot machine: each is fetched once, checked against its pinned SHA-256 and kept; a file that does not match is removed and nothing is served from it. The fetch is a function that is given, so that a test serves made-up files; the check is of the bytes, read in chunks (an installer image is several GB).

import { sha256File } from "./assets.ts";
// await sha256File("/var/lib/netboot/linux")

Source: commons/netboot/src/physical/assets.ts

3 of 10 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

physical.sha256Filefunctionno test imports it
function sha256File(file: string): Promise<string>

A file's SHA-256 in hexadecimal, read in chunks.

physical.Assetstypeno test imports it
type Assets = { readonly files: Readonly<Record<string, string>>; readonly iso?: string };

The files the server holds: the boot files by name, and the installer image.

physical.Fetchtypeno test imports it
type Fetch = (url: string) => Promise<Response>;

Gets the bytes at an address.

physical.ensureAssetsfunctionno test imports it
function ensureAssets(dir: string, pins: BootPins, fetcher?: Fetch, say?: (m: string) => void): Promise<Result<Assets, string>>

Every boot file and the installer image, fetched where they are not held and checked against their pins.

physical.assetStatusfunctionno test imports it
function assetStatus(dir: string, pins: BootPins): Promise<{ readonly ready: readonly string[]; readonly missing: readonly string[]; }>

What of the assets is held and matches its pin, without fetching: the names that are ready and the ones that are not.

sha256Filefunction
function sha256File(file: string): Promise<string>

A file's SHA-256 in hexadecimal, read in chunks.

Imported by 18 tests of the run (18 passed, 0 failed): the library's results

Assetstypeno test imports it
type Assets = { readonly files: Readonly<Record<string, string>>; readonly iso?: string };

The files the server holds: the boot files by name, and the installer image.

Fetchtypeno test imports it
type Fetch = (url: string) => Promise<Response>;

Gets the bytes at an address.

ensureAssetsfunction
function ensureAssets(dir: string, pins: BootPins, fetcher?: Fetch, say?: (m: string) => void): Promise<Result<Assets, string>>

Every boot file and the installer image, fetched where they are not held and checked against their pins.

Imported by 18 tests of the run (18 passed, 0 failed): the library's results

assetStatusfunction
function assetStatus(dir: string, pins: BootPins): Promise<{ readonly ready: readonly string[]; readonly missing: readonly string[]; }>

What of the assets is held and matches its pin, without fetching: the names that are ready and the ones that are not.

Imported by 18 tests of the run (18 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.