logical.groupShapefunctionno test imports itfunction groupShape(d: Obj, getent: string | undefined): JsonValue | undefinedA group from the line of getent group, or nothing where there is none.
What a command printed, read in the shape a requirement declares: pure functions from the text of getent, stat, id, systemctl, dpkg-query and a file to the value that desired of the requirement would equal were the machine as declared, and nothing where the resource is not there. A field the requirement does not declare is not read, so that a requirement that says less is satisfied by more. Nothing here runs a program.
import { userShape } from "./shapes.ts";
userShape({ name: "ada", shell: "/bin/bash" }, "ada:x:1000:1000:Ada:/home/ada:/bin/bash\n", "ada sudo\n"); // { name: "ada", shell: "/bin/bash" }logical.groupShapefunctionno test imports itfunction groupShape(d: Obj, getent: string | undefined): JsonValue | undefinedA group from the line of getent group, or nothing where there is none.
logical.userShapefunctionno test imports itfunction userShape(d: Obj, passwd: string | undefined, groupsOf: string | undefined): JsonValue | undefinedA user from the line of getent passwd and the output of id -nG: only the fields the requirement declares, and of the groups it names only those the user is in, in the order it names them.
logical.Stattypeno test imports ittype Stat = { readonly type: string; readonly owner: string; readonly group: string; readonly mode: string };The kind of a file as stat -c %F says it, with its owner, group and mode (%a).
logical.parseStatfunctionno test imports itfunction parseStat(text: string): Stat | undefinedstat -c '%F|%U|%G|%a' read.
logical.pathShapefunctionno test imports itfunction pathShape(kind: "directory" | "file", d: Obj, stat: Stat | undefined, content: string | undefined): JsonValue | undefinedA file or a directory from its stat and, for a file, its content: the path, and the content, owner, group and mode as far as the requirement declares them (a mode is written as long as the requirement writes it).
logical.serviceShapefunctionno test imports itfunction serviceShape(d: Obj, active: string, enabled: string): JsonValueA service: whether it is running (systemctl is-active says active) and whether it starts at boot (is-enabled says enabled). A service is always there to ask about.
logical.keyShapefunctionno test imports itfunction keyShape(d: Obj, fileText: string | undefined): JsonValue | undefinedA key: the requirement itself where the key file has the line, and nothing where it has not.
logical.packageShapefunctionno test imports itfunction packageShape(d: Obj, dpkg: string | undefined): JsonValue | undefinedA package from dpkg-query -W -f '${db:Status-Abbrev}|${Version}': there where its status says installed (ii), with its version where the requirement names one.
logical.rpmPackageShapefunctionno test imports itfunction rpmPackageShape(d: Obj, rpm: string | undefined): JsonValue | undefinedA package of an rpm family from rpm -q --qf '%{VERSION}-%{RELEASE}': the version it prints where it is installed (the command fails, and there is nothing to read, where it is not), with the version of the requirement where it names one.
logical.pacmanPackageShapefunctionno test imports itfunction pacmanPackageShape(d: Obj, pacman: string | undefined): JsonValue | undefinedA package of Arch from pacman -Q name, which prints name version where it is installed.
logical.settingShapefunctionno test imports itfunction settingShape(name: string, text: string | undefined): JsonValue | undefinedA setting of the system from the file that holds it: the time zone is where /etc/localtime points (after zoneinfo/), the keyboard layout is XKBLAYOUT of /etc/default/keyboard and the locale is LANG of /etc/default/locale.
logical.keyFileOffunctionno test imports itfunction keyFileOf(d: Obj): stringThe path a key file is at: the requirement's own, or the account's .ssh/authorized_keys.
logical.settingFileOffunctionno test imports itfunction settingFileOf(family: string, name: string): string | undefinedThe file a setting is read from on a family: the time zone is the link /etc/localtime everywhere; the locale is LANG of /etc/default/locale on Debian and /etc/locale.conf elsewhere; the keyboard layout is XKBLAYOUT of /etc/default/keyboard on Debian only (the other families keep a console keymap of another name, which is not the same fact).
groupShapefunctionfunction groupShape(d: Obj, getent: string | undefined): JsonValue | undefinedA group from the line of getent group, or nothing where there is none.
userShapefunctionfunction userShape(d: Obj, passwd: string | undefined, groupsOf: string | undefined): JsonValue | undefinedA user from the line of getent passwd and the output of id -nG: only the fields the requirement declares, and of the groups it names only those the user is in, in the order it names them.
Stattypeno test imports ittype Stat = { readonly type: string; readonly owner: string; readonly group: string; readonly mode: string };The kind of a file as stat -c %F says it, with its owner, group and mode (%a).
parseStatfunctionfunction parseStat(text: string): Stat | undefinedstat -c '%F|%U|%G|%a' read.
pathShapefunctionfunction pathShape(kind: "directory" | "file", d: Obj, stat: Stat | undefined, content: string | undefined): JsonValue | undefinedA file or a directory from its stat and, for a file, its content: the path, and the content, owner, group and mode as far as the requirement declares them (a mode is written as long as the requirement writes it).
serviceShapefunctionfunction serviceShape(d: Obj, active: string, enabled: string): JsonValueA service: whether it is running (systemctl is-active says active) and whether it starts at boot (is-enabled says enabled). A service is always there to ask about.
keyShapefunctionfunction keyShape(d: Obj, fileText: string | undefined): JsonValue | undefinedA key: the requirement itself where the key file has the line, and nothing where it has not.
packageShapefunctionfunction packageShape(d: Obj, dpkg: string | undefined): JsonValue | undefinedA package from dpkg-query -W -f '${db:Status-Abbrev}|${Version}': there where its status says installed (ii), with its version where the requirement names one.
rpmPackageShapefunctionfunction rpmPackageShape(d: Obj, rpm: string | undefined): JsonValue | undefinedA package of an rpm family from rpm -q --qf '%{VERSION}-%{RELEASE}': the version it prints where it is installed (the command fails, and there is nothing to read, where it is not), with the version of the requirement where it names one.
pacmanPackageShapefunctionfunction pacmanPackageShape(d: Obj, pacman: string | undefined): JsonValue | undefinedA package of Arch from pacman -Q name, which prints name version where it is installed.
settingShapefunctionfunction settingShape(name: string, text: string | undefined): JsonValue | undefinedA setting of the system from the file that holds it: the time zone is where /etc/localtime points (after zoneinfo/), the keyboard layout is XKBLAYOUT of /etc/default/keyboard and the locale is LANG of /etc/default/locale.
keyFileOffunctionfunction keyFileOf(d: Obj): stringThe path a key file is at: the requirement's own, or the account's .ssh/authorized_keys.
settingFileOffunctionfunction settingFileOf(family: string, name: string): string | undefinedThe file a setting is read from on a family: the time zone is the link /etc/localtime everywhere; the locale is LANG of /etc/default/locale on Debian and /etc/locale.conf elsewhere; the keyboard layout is XKBLAYOUT of /etc/default/keyboard on Debian only (the other families keep a console keymap of another name, which is not the same fact).