Credentialinterfaceinterface CredentialA password for one place: each of host, port, database and user is exact or *.
| Member | Type | What it is |
|---|---|---|
host | string | |
port | string | |
database | string | |
user | string | |
password | string |
The writers of the files libpq and psql read (commons data 0047-arcactl-init FR-008 to FR-010): .pgpass (the passwords), pg_service.conf (the instances: host, port, database, user, SSL) and .psqlrc (the prompt, the settings and a few helper queries). Each is a managed block (0047 FR-002) planned as a change (FR-003), so what a person wrote in the file is untouched. They are functions of their input and make nothing: the password is given to them and is written only to .pgpass, mode 0600, which libpq ignores where the group or others can read it.
Credentialinterfaceinterface CredentialA password for one place: each of host, port, database and user is exact or *.
| Member | Type | What it is |
|---|---|---|
host | string | |
port | string | |
database | string | |
user | string | |
password | string |
checkCredentialfunctionfunction checkCredential(c: Credential): readonly WriteError[]What is wrong with a credential.
checkInstancefunctionfunction checkInstance(i: Instance): readonly WriteError[]What is wrong with an instance, as a service.
fixModesfunctionfunction fixModes(plan: Plan): readonly string[]Puts right the mode of a password file that libpq would ignore.
Instanceinterfaceinterface InstanceAn instance: what libpq's service file says of it, and what arcactl adds.
| Member | Type | What it is |
|---|---|---|
name | string | |
host? | string | |
port? | number | |
database? | string | |
user? | string | |
sslmode? | string | disable, allow, prefer, require, verify-ca or verify-full. |
schema? | string | The schema the arca tables are in, which the service puts first on the search path. |
Keytypeno test imports ittype Key = Pick<Credential, "host" | "port" | "database" | "user">;The part of a credential that says where it is for.
PgpassChangeinterfaceno test imports itinterface PgpassChangeWhat a change of the credentials is: some set (a new password replaces the one for the same place), some removed.
| Member | Type | What it is |
|---|---|---|
set? | readonly Credential[] | |
remove? | readonly Key[] |
parsePgpassfunctionfunction parsePgpass(text: string): { readonly credentials: readonly Credential[]; readonly other: readonly string[]; }The credentials in a text (the body of a block or a whole file); a comment and a blank line are skipped, and a line that is not one is returned apart.
parseServicesfunctionfunction parseServices(text: string): readonly { readonly name: string; readonly settings: Readonly<Record<string, string>>; }[]The services in a text: each [name] section and its settings.
pgpassLineconstconst pgpassLine: (c: Credential) => stringOne line of .pgpass.
planPgpassfunctionfunction planPgpass(paths: Paths, change: PgpassChange): Result<Plan, readonly WriteError[]>Plans the change of .pgpass.
| Parameter | What it is |
|---|---|
paths | where the files are |
change | the credentials to set and to remove |
Returns: the plan (the file at mode 0600, a warning where a line of the person's own would be read first), or what is wrong
planPsqlfunctionfunction planPsql(paths: Paths): Result<Plan, readonly WriteError[]>Plans the psql files: the one arcactl owns, and a block in the person's psqlrc that includes it.
| Parameter | What it is |
|---|---|
paths | where the files are |
Returns: the plan
planServicesfunctionfunction planServices(paths: Paths, instances: readonly Instance[]): Result<Plan, readonly WriteError[]>Plans the service file for a set of instances: the block holds exactly these.
| Parameter | What it is |
|---|---|
paths | where the files are |
instances | every instance arcactl is to write (none takes the block out) |
Returns: the plan, or what is wrong: an instance that is not valid, or one a person already defined outside the block (libpq reads the first, so the one arcactl wrote would be ignored)
planUndofunctionfunction planUndo(paths: Paths): Result<Plan, readonly WriteError[]>Plans taking away what the writers put in: the block of each file, and the credentials and services of arcactl.
psqlrcBodyconstconst psqlrcBody: () => stringThe file of psql that arcactl owns: the prompt, the settings and the helper queries. It needs psql 15 or later, which has \getenv.
readInstancesfunctionfunction readInstances(paths: Paths): Result<readonly Instance[], readonly WriteError[]>The instances arcactl has written to a service file, read back from its block.
serviceSectionfunctionfunction serviceSection(i: Instance): stringOne service, as the lines of its section.
splitPgpassfunctionfunction splitPgpass(line: string): readonly string[] | undefinedThe fields of a line, with the escapes undone; none where it does not have five.
WriteErrortypeno test imports ittype WriteError =
| { readonly kind: "invalid"; readonly what: string; readonly why: string }
| { readonly kind: "conflict"; readonly service: string; readonly why: string }
| { readonly kind: "block"; readonly path: string; readonly error: BlockError }
| FileError;What is wrong with what a writer is given.