IF Commons GitHub

sql/cli/server

Written to: 2 requirements: 2 proved, 0 partly, 0 failing, 0 with no test recorded. 0047-arcactl-init FR-004, 0047-arcactl-init FR-005

The server model of arcactl (commons data 0047-arcactl-init FR-004, FR-005): how it runs where no person is there, in a pipeline, a deploy step, a container or a scheduled job. Everything is given by the environment and the arguments; nothing is asked and no file of a home directory is written; a secret is given as a variable or as a file named by <NAME>_FILE (the convention of Docker and Kubernetes secrets), never both. Which model applies is decided by what is said (an option, ARCA_MODE), then by what the environment shows (CI, no terminal), and only then does a person at a terminal get the workstation.

Source: commons/data/sql/cli/server.ts

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

Choseninterfaceno test imports it
interface Chosen

Which model applies, and why.

MemberTypeWhat it is
modeMode
whystring
mayAskconst
const mayAsk: (mode: Mode) => boolean

Whether the command may ask a person a question: only in the workstation mode.

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

mayWriteHomeconst
const mayWriteHome: (mode: Mode) => boolean

What a mode may do: a server writes no file of a home directory and asks no question.

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

Modetypeno test imports it
type Mode = "workstation" | "server";

The two ways arcactl runs.

modeOffunction
function modeOf(argv: readonly string[], env: Readonly<Record<string, string | undefined>>, tty: boolean): Chosen

Chooses the model.

ParameterWhat it is
argvthe arguments
envthe environment
ttywhether input and output are a terminal

Returns: the mode and why

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

Readtypeno test imports it
type Read = (path: string) => string;

Reads a file; a test gives its own.

secretOffunction
function secretOf(env: Readonly<Record<string, string | undefined>>, name: string, read?: Read): Result<string | undefined, string>

A secret given by the environment: the variable NAME, or the file named by NAME_FILE.

ParameterWhat it is
envthe environment
namethe variable's name
readhow a file is read

Returns: the secret (a file's last line ending is not part of it), none where neither is given, or why it cannot be had

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

ServerSettingsinterfaceno test imports it
interface ServerSettings

What a server run is given by its environment.

MemberTypeWhat it is
urlstring | undefined
sealKeystring | undefined
unlockSecretstring | undefined
approvestring | undefinedThe hash of a proposal that a person approved.
log"json" | "text"
serverSettingsfunction
function serverSettings(env: Readonly<Record<string, string | undefined>>, read?: Read | undefined): Result<ServerSettings, readonly string[]>

The secrets and settings of a server run, or every reason they cannot be had.

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

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