@quadnix/octo-event-listeners 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +108 -21
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.type.d.ts +2 -0
- package/dist/index.type.js +2 -0
- package/dist/index.type.js.map +1 -0
- package/dist/journal.event.listener.d.ts +317 -0
- package/dist/journal.event.listener.js +480 -0
- package/dist/journal.event.listener.js.map +1 -0
- package/dist/logger/logger.factory.d.ts +8 -22
- package/dist/logger/logger.factory.js +9 -8
- package/dist/logger/logger.factory.js.map +1 -1
- package/dist/logging.event.listener.d.ts +18 -11
- package/dist/logging.event.listener.js +73 -16
- package/dist/logging.event.listener.js.map +1 -1
- package/dist/reporters/report.builder.js +8 -25
- package/dist/reporters/report.builder.js.map +1 -1
- package/dist/reporters/report.model.d.ts +24 -2
- package/dist/reporters/report.model.js +1 -1
- package/dist/reporters/report.model.js.map +1 -1
- package/dist/reporters/run.observer.d.ts +1 -6
- package/dist/reporters/run.observer.js +1 -6
- package/dist/reporters/run.observer.js.map +1 -1
- package/dist/reporters/text/text.reporter.d.ts +3 -5
- package/dist/reporters/text/text.reporter.js +11 -8
- package/dist/reporters/text/text.reporter.js.map +1 -1
- package/dist/utilities/journal/journal.utility.d.ts +154 -0
- package/dist/utilities/journal/journal.utility.js +183 -0
- package/dist/utilities/journal/journal.utility.js.map +1 -0
- package/dist/utilities/timestamp/timestamp.utility.d.ts +11 -0
- package/dist/utilities/timestamp/timestamp.utility.js +26 -0
- package/dist/utilities/timestamp/timestamp.utility.js.map +1 -0
- package/package.json +7 -4
- package/dist/html-report.event.listener.d.ts +0 -99
- package/dist/html-report.event.listener.js +0 -224
- package/dist/html-report.event.listener.js.map +0 -1
- package/dist/reporters/html/html.reporter.d.ts +0 -6
- package/dist/reporters/html/html.reporter.js +0 -407
- package/dist/reporters/html/html.reporter.js.map +0 -1
- package/dist/reporters/html/index.reporter.d.ts +0 -23
- package/dist/reporters/html/index.reporter.js +0 -69
- package/dist/reporters/html/index.reporter.js.map +0 -1
- package/dist/reporters/html/report.styles.d.ts +0 -8
- package/dist/reporters/html/report.styles.js +0 -317
- package/dist/reporters/html/report.styles.js.map +0 -1
- package/dist/reporters/timestamp.d.ts +0 -12
- package/dist/reporters/timestamp.js +0 -21
- package/dist/reporters/timestamp.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,35 +1,122 @@
|
|
|
1
1
|
# Octo
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Infrastructure as code written as intent: you describe an app and what it needs, modules turn that
|
|
4
|
+
into Terraform, and your own Terragrunt applies it. Users start at
|
|
5
|
+
[octo.quadnix.com](https://octo.quadnix.com/).
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
> Octo is in `0.x`. Version `1.x` will mark it ready for production.
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
> We plan to release version `1.x.x` when it is deemed ready for production use.
|
|
9
|
+
**This README is a set of procedures for working on the repository.** `docs/ARCHITECTURE.md`
|
|
10
|
+
explains what exists, and `docs/CODING-STANDARDS.md` how to add to it.
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
Requires Node 20 or newer, Terraform or OpenTofu 1.6 or newer, and Terragrunt 0.78 or newer. The
|
|
13
|
+
integration suites also need Docker, and the e2e suites AWS credentials.
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
---
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
exact package manager the project expects — you do **not** need to install pnpm yourself.
|
|
17
|
+
## A — Set up this machine
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
This repository is a [pnpm](https://pnpm.io) workspace. Corepack reads the `packageManager`
|
|
21
|
-
field in the root `package.json` and uses the pnpm version pinned there, so everyone (and CI)
|
|
22
|
-
runs the same version.
|
|
19
|
+
Once.
|
|
23
20
|
|
|
24
21
|
```sh
|
|
25
|
-
# One-time per machine: activate Corepack so the `pnpm` command uses the pinned version.
|
|
26
22
|
corepack enable
|
|
27
|
-
|
|
28
|
-
# Install all workspace dependencies (packages/*).
|
|
29
23
|
pnpm install
|
|
24
|
+
pnpm run prepare
|
|
30
25
|
```
|
|
31
26
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
`prepare` installs the pre-commit hook, which runs the format check, lint, the build with its type
|
|
28
|
+
check, the circular-dependency check, the secrets spec and the docs code-block check.
|
|
29
|
+
|
|
30
|
+
## B — Build, lint and test
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
pnpm run build
|
|
34
|
+
pnpm run lint
|
|
35
|
+
pnpm test
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`octo-aws-cdk`, `octo-event-listeners`, `octo-build` and `octo-templates` import `octo` from its
|
|
39
|
+
`dist`, and `octo-templates` imports `octo-aws-cdk` the same way. **Rebuild what you changed before
|
|
40
|
+
testing what depends on it**, or the suite runs against the old code and still passes.
|
|
41
|
+
|
|
42
|
+
`pnpm run build` also type-checks every package, tests included, through each package's
|
|
43
|
+
`check:types`.
|
|
44
|
+
|
|
45
|
+
`pnpm run format` writes what `pnpm run format:check` checks. Lint does not check formatting.
|
|
46
|
+
|
|
47
|
+
`pnpm run lint:fix` sorts imports, members and keys. A flag passed through `pnpm run` is written
|
|
48
|
+
without `--`: pnpm forwards the separator, and the script then drops the flag.
|
|
49
|
+
|
|
50
|
+
## C — Run integration tests
|
|
51
|
+
|
|
52
|
+
Integration specs run real Terraform; `octo-templates`' start LocalStack in Docker.
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
pnpm run test:integration
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## D — Run an e2e suite
|
|
59
|
+
|
|
60
|
+
**Every e2e suite reaches a live AWS account.** `octo-aws-cdk`'s plan and apply nothing;
|
|
61
|
+
`octo-templates`' create real resources and tear them down.
|
|
62
|
+
|
|
63
|
+
1. Copy the `.env.defaults` beside the suite to `.env` and fill in real values. `.env` is ignored.
|
|
64
|
+
2. Build the packages the suite imports:
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
npx nx run-many -t build --projects=octo,octo-event-listeners,octo-aws-cdk
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
3. Run one spec, by path, from its package:
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
cd packages/octo-templates
|
|
74
|
+
NODE_OPTIONS=--experimental-vm-modules npx jest --runTestsByPath src/<template>/main.e2e-spec.ts
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Never `pnpm run test:e2e` — it runs every suite live at once. Never combine `-u` with `-t`: jest then
|
|
78
|
+
deletes the snapshots of every test it skipped. A template's own `README.md`, where it has one,
|
|
79
|
+
holds what is particular to it.
|
|
80
|
+
|
|
81
|
+
## E — Work in a worktree
|
|
82
|
+
|
|
83
|
+
For a large change or a hands-free agent run:
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
git worktree add ../ai-worktrees/octo-worktree-<branch> -b ai/<branch>
|
|
87
|
+
WORKTREE=../ai-worktrees/octo-worktree-<branch>
|
|
88
|
+
find . -maxdepth 4 -name node_modules -type d ! -path "*/node_modules/*/node_modules" | \
|
|
89
|
+
while read src; do
|
|
90
|
+
mkdir -p "$WORKTREE/$(dirname $src)"
|
|
91
|
+
ln -s "$(pwd)/$src" "$WORKTREE/$src"
|
|
92
|
+
done
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The symlinks let Nx and Jest resolve packages. Run lint and tests from inside the worktree.
|
|
96
|
+
|
|
97
|
+
## F — Release
|
|
98
|
+
|
|
99
|
+
1. Merge to `main` with PR titles per `.github/jobs/validate-pr-title.job.sh`. The commit type sets
|
|
100
|
+
the bump: `chore` releases nothing.
|
|
101
|
+
2. Run the **Manual Release** workflow on `main`. It versions every changed package, tags, writes
|
|
102
|
+
the changelog, and publishes to npm.
|
|
103
|
+
|
|
104
|
+
## Environment variables
|
|
105
|
+
|
|
106
|
+
Everything outside the code that governs how this repository behaves. A suite's `.env` is read
|
|
107
|
+
through `env-smart`, falling back to the `.env.defaults` beside it.
|
|
108
|
+
|
|
109
|
+
| Variable | Set by | What it does |
|
|
110
|
+
|-----------------------------------------------------------------------------------------------------|-----------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
111
|
+
| `AWS_ACCOUNT_ID` | a suite's `.env` | The account every e2e suite plans or applies into. |
|
|
112
|
+
| `AWS_REGION_ID` | `packages/octo-aws-cdk/test/.env` | The region the module e2es plan into. Template suites hardcode `us-east-1`. |
|
|
113
|
+
| `OCTO_DEFINITION_FILE_PATH` | the user, or a `create-app` project's scripts | The `octo.yaml` every lifecycle command boots from. `OctoCliUtility` sets it for the CLI-driven template suites. A relative path is resolved once against the working directory, so `run-action` callbacks find it. |
|
|
114
|
+
| `OCTO_JOURNAL_COMMAND_ID` | `JournalEventListener` | The running command's id, set for every process it starts, so a `run-action` that Terraform starts mid-apply names that apply as `parentCommandId` in its journal. |
|
|
115
|
+
| `TF_VAR_OCTO_PROJECT_ROOT` | `TerraformUtility`, unless already set | The working directory, so `terraform.localPath()` paths resolve inside Terragrunt's cache copy of a folder. |
|
|
116
|
+
| `TG_LOG_CUSTOM_FORMAT` | `TerraformUtility`, always | Terragrunt's log line layout, its default without the time, since the journal records when each line arrived. |
|
|
117
|
+
| `TG_LOG_FORMAT` | `TerraformUtility`, always unset | Unset for every Terragrunt process, so it cannot override `TG_LOG_CUSTOM_FORMAT`. |
|
|
118
|
+
| `TG_PROVIDER_CACHE` | `TerraformUtility`, unless already set | `1`, so Terragrunt shares one provider cache across folders. |
|
|
119
|
+
| `TG_TF_PATH` | `TerraformUtility`, from `--terraformBinary` | Which Terraform or OpenTofu binary Terragrunt runs. |
|
|
120
|
+
| `NODE_OPTIONS` | every package's test scripts | `--experimental-vm-modules`, which Jest needs to run ESM. Set it yourself when running `jest` directly. |
|
|
121
|
+
| `OCTO_STAGE`, `OCTO_PHASE`, `OCTO_NAT`, `OCTO_TARGET`, `OCTO_WORK`, `OCTO_CASE`, `OCTO_PROBE_STATE` | you, by hand | Drive the `aws-ecs-server` debugging harnesses; that template's `README.md` describes each. |
|
|
122
|
+
| `GH_TOKEN` | a repository secret | Checkout and push in **Manual Release**, and the tags and GitHub releases `nx release` creates. |
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { JournalEventListener } from './journal.event.listener.js';
|
|
2
2
|
export { LoggingEventListener } from './logging.event.listener.js';
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.type.js","sourceRoot":"","sources":["../src/index.type.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import { Event } from '@quadnix/octo';
|
|
2
|
+
import { JournalUtility, type Plain } from './utilities/journal/journal.utility.js';
|
|
3
|
+
/**
|
|
4
|
+
* Each event a journal records, by its class name, mapped to its payload as the journal holds it. An
|
|
5
|
+
* event without a payload has none in its entry.
|
|
6
|
+
*
|
|
7
|
+
* @group Event Listeners/Journal
|
|
8
|
+
*/
|
|
9
|
+
export type EventPayloads = {
|
|
10
|
+
[K in keyof typeof JournalUtility.EVENT_CLASSES]: K extends 'StateFilesSavedEvent' ? {
|
|
11
|
+
/**
|
|
12
|
+
* Every state file the save wrote, but the journal's own; an entry is recorded only when one is
|
|
13
|
+
* left. A file copied from a path, or deleted, has no `md5`.
|
|
14
|
+
*/
|
|
15
|
+
stateFiles: {
|
|
16
|
+
md5?: string;
|
|
17
|
+
stateFileName: string;
|
|
18
|
+
}[];
|
|
19
|
+
} : Plain<InstanceType<(typeof JournalUtility.EVENT_CLASSES)[K]>['payload']>;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* What every journal file of one command starts with.
|
|
23
|
+
*
|
|
24
|
+
* @group Event Listeners/Journal
|
|
25
|
+
*/
|
|
26
|
+
export type JournalHeader = {
|
|
27
|
+
/**
|
|
28
|
+
* The CLI command, such as `validate`, or the mode where no command ran it.
|
|
29
|
+
*/
|
|
30
|
+
command: string;
|
|
31
|
+
/**
|
|
32
|
+
* Unix milliseconds when the command started, then 8 random hex: `1767225600000-0a1b2c3d`.
|
|
33
|
+
*/
|
|
34
|
+
commandId: string;
|
|
35
|
+
host: string;
|
|
36
|
+
/**
|
|
37
|
+
* The version of `@quadnix/octo` the command ran, absent when it could not be read.
|
|
38
|
+
*/
|
|
39
|
+
octoVersion?: string;
|
|
40
|
+
/**
|
|
41
|
+
* The command that started this one, such as the `apply` a `run-action` ran inside.
|
|
42
|
+
*/
|
|
43
|
+
parentCommandId?: string;
|
|
44
|
+
/**
|
|
45
|
+
* When the command started, in Unix milliseconds.
|
|
46
|
+
*/
|
|
47
|
+
startedAt: number;
|
|
48
|
+
/**
|
|
49
|
+
* The format of the journal files.
|
|
50
|
+
*/
|
|
51
|
+
version: 1;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* One event of a command, as its journal holds it. Narrow on `type` to read its payload.
|
|
55
|
+
*
|
|
56
|
+
* @group Event Listeners/Journal
|
|
57
|
+
*/
|
|
58
|
+
export type JournalEntry = {
|
|
59
|
+
[K in keyof EventPayloads]: {
|
|
60
|
+
/**
|
|
61
|
+
* The event's subject, where its type alone does not say, such as a module's class name; empty
|
|
62
|
+
* otherwise.
|
|
63
|
+
*/
|
|
64
|
+
name: string;
|
|
65
|
+
/**
|
|
66
|
+
* The event's place among every event the command's process created, shared with the terraform log.
|
|
67
|
+
*/
|
|
68
|
+
sequence: number;
|
|
69
|
+
/**
|
|
70
|
+
* When the event was created, in Unix milliseconds.
|
|
71
|
+
*/
|
|
72
|
+
time: number;
|
|
73
|
+
type: K;
|
|
74
|
+
} & (EventPayloads[K] extends undefined ? {
|
|
75
|
+
payload?: undefined;
|
|
76
|
+
} : {
|
|
77
|
+
payload: EventPayloads[K];
|
|
78
|
+
});
|
|
79
|
+
}[keyof EventPayloads];
|
|
80
|
+
/**
|
|
81
|
+
* `journal.<commandId>.<command>.json`: every event of one command, in the order it happened.
|
|
82
|
+
*
|
|
83
|
+
* Beside it, `journal.<commandId>.<command>.<md5>.json` keeps each version of `models.json`,
|
|
84
|
+
* `resources-actual.json`, `resources-old.json` or an external resource's record the command wrote,
|
|
85
|
+
* named by the MD5 of its contents, as its `StateFilesSavedEvent` entry names it.
|
|
86
|
+
*
|
|
87
|
+
* @group Event Listeners/Journal
|
|
88
|
+
*/
|
|
89
|
+
export type JournalFile = JournalHeader & {
|
|
90
|
+
entries: JournalEntry[];
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* One record of a terraform log: a process starting, a chunk it wrote, or its exit. `process` tells
|
|
94
|
+
* apart the command's processes, and `sequence` places the record among the command's events.
|
|
95
|
+
*
|
|
96
|
+
* @group Event Listeners/Journal
|
|
97
|
+
*/
|
|
98
|
+
export type TerraformLogRecord = {
|
|
99
|
+
args: string[];
|
|
100
|
+
binary: string;
|
|
101
|
+
dir: string;
|
|
102
|
+
process: number;
|
|
103
|
+
sequence: number;
|
|
104
|
+
time: number;
|
|
105
|
+
type: 'started';
|
|
106
|
+
} | {
|
|
107
|
+
process: number;
|
|
108
|
+
sequence: number;
|
|
109
|
+
stream: 'stderr' | 'stdout';
|
|
110
|
+
text: string;
|
|
111
|
+
time: number;
|
|
112
|
+
type: 'output';
|
|
113
|
+
} | {
|
|
114
|
+
exitCode: number;
|
|
115
|
+
process: number;
|
|
116
|
+
sequence: number;
|
|
117
|
+
time: number;
|
|
118
|
+
type: 'exited';
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* `journal.<commandId>.<command>.terraform.json`: everything terraform and terragrunt wrote during one
|
|
122
|
+
* command, chunk by chunk, in the order it arrived.
|
|
123
|
+
*
|
|
124
|
+
* @group Event Listeners/Journal
|
|
125
|
+
*/
|
|
126
|
+
export type TerraformLogFile = JournalHeader & {
|
|
127
|
+
outputs: TerraformLogRecord[];
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Writes the journal: every event of this command, in the order it happened, into Octo's state.
|
|
131
|
+
*
|
|
132
|
+
* A command is one process, named after the CLI command it runs, or the mode where no command runs
|
|
133
|
+
* it. Its events go to `journal.<commandId>.<command>.json`, and what terraform and terragrunt wrote to
|
|
134
|
+
* `journal.<commandId>.<command>.terraform.json`, each chunk as it arrives.
|
|
135
|
+
* A copy of every model and resource state file written is kept as `journal.<commandId>.<command>.<md5>.json`,
|
|
136
|
+
* so each version a command wrote survives the next command overwriting it.
|
|
137
|
+
* Ids start with the time they were made, so files sort in the order their commands started.
|
|
138
|
+
*
|
|
139
|
+
* The listener only creates files: {@link StateManagementService} archives them when the lock is
|
|
140
|
+
* released. A command that runs under a lock, run when none is held, writes nothing, because its
|
|
141
|
+
* files would belong to no lock. They are written with every other state file written, at the end of a command,
|
|
142
|
+
* and before the lock is released, after which nothing more is recorded. It never fails a command: a write that
|
|
143
|
+
* fails is reported on stderr. The one write that fails loudly is the one before the release, which
|
|
144
|
+
* keeps the lock held.
|
|
145
|
+
*
|
|
146
|
+
* The terraform log is written to a temporary file as each chunk arrives, and holds nothing in memory.
|
|
147
|
+
* That file is valid JSON after every chunk. Each state save takes a copy of it on disk and hands the
|
|
148
|
+
* state provider that copy's path, so an apply's output reaches the state provider at every terraform
|
|
149
|
+
* state check-in without ever being read into memory. It is deleted when the command ends.
|
|
150
|
+
*
|
|
151
|
+
* A command that another one started, such as a `run-action` terraform starts mid-apply, names that
|
|
152
|
+
* command as `parentCommandId`.
|
|
153
|
+
*
|
|
154
|
+
* @group Event Listeners
|
|
155
|
+
*/
|
|
156
|
+
export declare class JournalEventListener {
|
|
157
|
+
/**
|
|
158
|
+
* The CLI command, or the mode, this process runs. Undefined until one begins.
|
|
159
|
+
*/
|
|
160
|
+
private command;
|
|
161
|
+
/**
|
|
162
|
+
* A UTC timestamp to the millisecond, then 8 random hex, so ids sort by when commands started.
|
|
163
|
+
*/
|
|
164
|
+
private commandId;
|
|
165
|
+
/**
|
|
166
|
+
* Every event recorded so far.
|
|
167
|
+
*/
|
|
168
|
+
private entries;
|
|
169
|
+
/**
|
|
170
|
+
* Whether an `octo` command announced itself, which then decides when the journal is written. A
|
|
171
|
+
* driver that announces no command, such as `runModules`, runs each mode as a command of its own.
|
|
172
|
+
*/
|
|
173
|
+
private isInCommand;
|
|
174
|
+
/**
|
|
175
|
+
* Whether the lock was released, after which nothing is recorded or written.
|
|
176
|
+
*/
|
|
177
|
+
private isReleased;
|
|
178
|
+
/**
|
|
179
|
+
* Whether this command writes at all, settled at its first write.
|
|
180
|
+
*/
|
|
181
|
+
private isWritten;
|
|
182
|
+
/**
|
|
183
|
+
* The version of `@quadnix/octo` this command uses.
|
|
184
|
+
*/
|
|
185
|
+
private readonly octoVersion;
|
|
186
|
+
/**
|
|
187
|
+
* The state file lists this listener saves itself, which it adds nothing to.
|
|
188
|
+
*/
|
|
189
|
+
private readonly ownStateFiles;
|
|
190
|
+
/**
|
|
191
|
+
* The command of the process that started this one, when there is one.
|
|
192
|
+
*/
|
|
193
|
+
private readonly parentCommandId;
|
|
194
|
+
/**
|
|
195
|
+
* The last write queued, so the next one waits for it.
|
|
196
|
+
*/
|
|
197
|
+
private pending;
|
|
198
|
+
/**
|
|
199
|
+
* State file contents not copied yet, by MD5.
|
|
200
|
+
*/
|
|
201
|
+
private readonly pendingCopies;
|
|
202
|
+
/**
|
|
203
|
+
* When this command started, in Unix milliseconds.
|
|
204
|
+
*/
|
|
205
|
+
private startedAt;
|
|
206
|
+
/**
|
|
207
|
+
* The terraform log file this command is writing, opened at its first record.
|
|
208
|
+
*/
|
|
209
|
+
private terraformLog;
|
|
210
|
+
/**
|
|
211
|
+
* The last change to the terraform log queued, so the next one waits for it.
|
|
212
|
+
*/
|
|
213
|
+
private terraformLogQueue;
|
|
214
|
+
/**
|
|
215
|
+
* The snapshots of the terraform log a save carries and has not finished with.
|
|
216
|
+
*/
|
|
217
|
+
private readonly terraformLogSnapshotPaths;
|
|
218
|
+
/**
|
|
219
|
+
* The MD5 of every copy this command already wrote.
|
|
220
|
+
*/
|
|
221
|
+
private readonly writtenCopies;
|
|
222
|
+
/**
|
|
223
|
+
* Names this command to every process it starts.
|
|
224
|
+
*/
|
|
225
|
+
constructor();
|
|
226
|
+
/**
|
|
227
|
+
* A new command id: the Unix time in milliseconds, then 8 random hex.
|
|
228
|
+
*/
|
|
229
|
+
private static createCommandId;
|
|
230
|
+
/**
|
|
231
|
+
* Records every event but registrations and serializations, adds the journal to every state save,
|
|
232
|
+
* and writes it at the end of a command, or a mode outside one, and before the lock is released.
|
|
233
|
+
*/
|
|
234
|
+
onEvent(event: Event<unknown>): Promise<void>;
|
|
235
|
+
/**
|
|
236
|
+
* Adds a record to the terraform log, opening it at the first. Each is written over the end of the
|
|
237
|
+
* file, followed by the end again, so the file stays valid JSON. Nothing is recorded before a command
|
|
238
|
+
* is named, since a journal is only written for a command.
|
|
239
|
+
*/
|
|
240
|
+
private appendTerraformLog;
|
|
241
|
+
/**
|
|
242
|
+
* What every journal file of this command starts with.
|
|
243
|
+
*/
|
|
244
|
+
private buildHeader;
|
|
245
|
+
/**
|
|
246
|
+
* The command's journal, its terraform log, and the state file copies not written yet. Empty before
|
|
247
|
+
* a command begins.
|
|
248
|
+
*/
|
|
249
|
+
private buildStateFiles;
|
|
250
|
+
/**
|
|
251
|
+
* Closes the terraform log and deletes it, once every record queued is written.
|
|
252
|
+
*/
|
|
253
|
+
private closeTerraformLog;
|
|
254
|
+
/**
|
|
255
|
+
* The name of one of this command's journal files.
|
|
256
|
+
*/
|
|
257
|
+
private fileName;
|
|
258
|
+
/**
|
|
259
|
+
* The state management service, or `undefined` when no state provider was booted, and so there is
|
|
260
|
+
* nowhere to write.
|
|
261
|
+
*/
|
|
262
|
+
private getStateManagementService;
|
|
263
|
+
/**
|
|
264
|
+
* Holds the contents of each model and resource state file, and each external resource record, a
|
|
265
|
+
* save wrote, until a journal write copies them. Marks the copies the save itself carried as written.
|
|
266
|
+
*/
|
|
267
|
+
private holdCopies;
|
|
268
|
+
/**
|
|
269
|
+
* Whether this command writes at all. One that runs under a lock writes nothing when no lock is
|
|
270
|
+
* held. A lock that cannot be read counts as held, so a failure is still recorded.
|
|
271
|
+
*/
|
|
272
|
+
private isWrittenAtAll;
|
|
273
|
+
/**
|
|
274
|
+
* Opens a new terraform log in a temporary directory, holding the header and no records, and
|
|
275
|
+
* removes it if the process exits before it is closed.
|
|
276
|
+
*/
|
|
277
|
+
private openTerraformLog;
|
|
278
|
+
/**
|
|
279
|
+
* The version of `@quadnix/octo` this command uses, read from its `package.json`.
|
|
280
|
+
*/
|
|
281
|
+
private readOctoVersion;
|
|
282
|
+
/**
|
|
283
|
+
* Adds one event to the journal, as plain data taken the moment it arrives. An event of a class the
|
|
284
|
+
* journal does not record is left out.
|
|
285
|
+
*/
|
|
286
|
+
private record;
|
|
287
|
+
/**
|
|
288
|
+
* Copies the terraform log as it stands, once every record queued is written, beside it, and returns
|
|
289
|
+
* the copy's path, or `undefined` when nothing was recorded. A save uploads the copy while the log
|
|
290
|
+
* keeps growing; the copy is deleted once the save is done, or with the log.
|
|
291
|
+
*/
|
|
292
|
+
private snapshotTerraformLog;
|
|
293
|
+
/**
|
|
294
|
+
* Starts a new command in this process, for a driver that runs each mode as one. The first mode
|
|
295
|
+
* names the command the process already started.
|
|
296
|
+
*/
|
|
297
|
+
private startCommand;
|
|
298
|
+
/**
|
|
299
|
+
* Reports a journal failure on stderr, which stays free of a command's own output.
|
|
300
|
+
*/
|
|
301
|
+
private warn;
|
|
302
|
+
/**
|
|
303
|
+
* Writes the command's journal, its terraform log, and the state file copies not written yet, as one
|
|
304
|
+
* change.
|
|
305
|
+
*/
|
|
306
|
+
private write;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* @internal
|
|
310
|
+
*/
|
|
311
|
+
export declare class JournalEventListenerFactory {
|
|
312
|
+
private static instance;
|
|
313
|
+
/**
|
|
314
|
+
* @internal
|
|
315
|
+
*/
|
|
316
|
+
static create(): Promise<JournalEventListener>;
|
|
317
|
+
}
|