@intentius/chant-lexicon-terraform 0.124.85 → 0.124.86

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.
Files changed (65) hide show
  1. package/dist/ci-setup.d.ts +11 -2
  2. package/dist/ci-setup.d.ts.map +1 -1
  3. package/dist/ci-setup.js +11 -6
  4. package/dist/components/capability-plugin.d.ts +12 -0
  5. package/dist/components/capability-plugin.d.ts.map +1 -1
  6. package/dist/components/capability-plugin.js +22 -4
  7. package/dist/compose.d.ts.map +1 -1
  8. package/dist/compose.js +1 -1
  9. package/dist/estate-migration.d.ts +101 -0
  10. package/dist/estate-migration.d.ts.map +1 -0
  11. package/dist/estate-migration.js +471 -0
  12. package/dist/integrity.json +2 -2
  13. package/dist/manifest.json +1 -1
  14. package/dist/op/activities/terraform.d.ts +65 -0
  15. package/dist/op/activities/terraform.d.ts.map +1 -1
  16. package/dist/op/activities/terraform.js +94 -1
  17. package/dist/state/backend.d.ts +46 -9
  18. package/dist/state/backend.d.ts.map +1 -1
  19. package/dist/state/backend.js +84 -31
  20. package/dist/state/gitlab.d.ts +1 -1
  21. package/dist/state/gitlab.d.ts.map +1 -1
  22. package/dist/state/gitlab.js +27 -14
  23. package/dist/state/index.d.ts +1 -0
  24. package/dist/state/index.d.ts.map +1 -1
  25. package/dist/state/index.js +1 -0
  26. package/dist/state/s3.d.ts +9 -3
  27. package/dist/state/s3.d.ts.map +1 -1
  28. package/dist/state/s3.js +4 -3
  29. package/dist/state/source.d.ts +92 -0
  30. package/dist/state/source.d.ts.map +1 -0
  31. package/dist/state/source.js +254 -0
  32. package/dist/state/store.d.ts +41 -4
  33. package/dist/state/store.d.ts.map +1 -1
  34. package/dist/state/store.js +125 -10
  35. package/dist/state/versions.d.ts +77 -10
  36. package/dist/state/versions.d.ts.map +1 -1
  37. package/dist/state/versions.js +118 -64
  38. package/dist/state-migration.d.ts +43 -1
  39. package/dist/state-migration.d.ts.map +1 -1
  40. package/dist/state-migration.js +251 -20
  41. package/dist/state-ops.d.ts +2 -3
  42. package/dist/state-ops.d.ts.map +1 -1
  43. package/dist/state-ops.js +4 -7
  44. package/package.json +2 -2
  45. package/src/ci-setup.test.ts +20 -0
  46. package/src/ci-setup.ts +11 -6
  47. package/src/components/capability-plugin.ts +36 -3
  48. package/src/components/terraform-apply-command-hook.test.ts +157 -0
  49. package/src/compose.ts +1 -0
  50. package/src/estate-migration.test.ts +186 -0
  51. package/src/estate-migration.ts +563 -0
  52. package/src/op/activities/terraform.ts +153 -3
  53. package/src/state/backend-verdict.test.ts +4 -3
  54. package/src/state/backend.test.ts +3 -1
  55. package/src/state/backend.ts +108 -33
  56. package/src/state/gitlab.ts +25 -12
  57. package/src/state/index.ts +1 -0
  58. package/src/state/s3.ts +5 -4
  59. package/src/state/source.ts +289 -0
  60. package/src/state/store.ts +145 -11
  61. package/src/state/versions.test.ts +365 -0
  62. package/src/state/versions.ts +148 -68
  63. package/src/state-migration-backends.test.ts +277 -0
  64. package/src/state-migration.ts +265 -23
  65. package/src/state-ops.ts +6 -8
@@ -16,15 +16,30 @@
16
16
  * `terraform apply` on the same checkout at the same time is not
17
17
  * kept out. Ruled on #4481 (ruling 4, 2026-10-25): chant's own
18
18
  * lock file, no Terraform lock-info file, local backends allowed.
19
+ * http a GitLab-managed state (./gitlab.ts): `<address>/lock`
20
+ *
21
+ * Each store also reads the state's versions (#4793), from the object's
22
+ * metadata, and its body only when a version's text is asked for:
23
+ *
24
+ * s3 bucket versioning: the object's `x-amz-version-id`
25
+ * gcs object versioning: a version is a generation
26
+ * azurerm blob versioning: the blob's `x-ms-version-id`; with none, the
27
+ * snapshots the backend takes when it sets `snapshot = true`,
28
+ * and `version(true)` takes one, whose time names it
29
+ * http GitLab keeps each version by its serial
30
+ * local keeps only the latest state
19
31
  *
20
32
  * Lifted from terragucci's `backend.ts` (c493e0e): `StateStore`, `s3Store`,
21
- * `gcsStore` and `azureStore`, plus a local store and `removeBeside`.
33
+ * `gcsStore` and `azureStore`, plus a local store and `removeBeside`; the
34
+ * version reads and the azurerm metadata lookup from the same file (#4793).
22
35
  */
36
+ import { createHash } from "node:crypto";
23
37
  import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
24
38
  import { dirname, isAbsolute, join } from "node:path";
25
39
  import { AzureBlobClient } from "./azure-blob.js";
26
40
  import { GcsClient } from "./gcs.js";
27
- import { StoreError } from "./object-store.js";
41
+ import { gitlabStore } from "./gitlab.js";
42
+ import { defaultFetch, StoreError } from "./object-store.js";
28
43
  import { S3Client } from "./s3.js";
29
44
  /** The ID in a lock info's JSON, or "" when it names none. */
30
45
  export function lockId(text) {
@@ -37,10 +52,17 @@ export function lockId(text) {
37
52
  }
38
53
  }
39
54
  const JSON_TYPE = "application/json";
55
+ const sha = (s) => createHash("sha256").update(s).digest("hex");
40
56
  /** The S3 state, locked by the lock file `use_lockfile` takes. */
41
57
  function s3Store(o, fetchFn) {
42
58
  const client = new S3Client(o.target, fetchFn);
43
59
  const lockKey = `${o.key}.tflock`;
60
+ const version = async () => {
61
+ const head = await client.head(o.key);
62
+ if (!head.exists)
63
+ return { exists: false };
64
+ return head.versionId ? { exists: true, versionId: head.versionId } : { exists: true, off: `bucket versioning is off for ${o.bucket}, so it keeps only the latest state` };
65
+ };
44
66
  return {
45
67
  backend: "s3",
46
68
  location: `s3://${o.bucket}/${o.key}`,
@@ -56,11 +78,17 @@ function s3Store(o, fetchFn) {
56
78
  removeBeside: (suffix) => client.remove(`${o.key}${suffix}`),
57
79
  besideLocation: (suffix) => `s3://${o.bucket}/${o.key}${suffix}`,
58
80
  adopt: () => { },
81
+ version,
82
+ hasVersion: (id) => client.hasVersion(o.key, id),
83
+ readVersion: (id) => client.readVersion(o.key, id),
84
+ isAt: async (id) => (await version()).versionId === id,
85
+ listVersions: () => client.listVersions(o.key),
59
86
  };
60
87
  }
61
88
  /** The GCS state, locked by `<prefix>/<workspace>.tflock`, whose generation is the lock's ID. */
62
89
  function gcsStore(o, fetchFn) {
63
90
  const client = new GcsClient(o.target, fetchFn);
91
+ let versioning;
64
92
  return {
65
93
  backend: "gcs",
66
94
  location: `gs://${o.bucket}/${o.key}`,
@@ -79,21 +107,66 @@ function gcsStore(o, fetchFn) {
79
107
  removeBeside: (suffix) => client.remove(`${o.key}${suffix}`),
80
108
  besideLocation: (suffix) => `gs://${o.bucket}/${o.key}${suffix}`,
81
109
  adopt: () => { },
110
+ version: async () => {
111
+ const head = await client.head(o.key);
112
+ if (!head.exists)
113
+ return { exists: false };
114
+ versioning ?? (versioning = client.versioning());
115
+ if ((await versioning) === false)
116
+ return { exists: true, off: `object versioning is off for ${o.bucket}, so it keeps only the latest state` };
117
+ return { exists: true, ...(head.generation ? { versionId: head.generation } : {}) };
118
+ },
119
+ hasVersion: async (id) => (await client.head(o.key, id)).exists,
120
+ readVersion: (id) => client.readGeneration(o.key, id),
121
+ isAt: async (id) => (await client.head(o.key)).generation === id,
122
+ listVersions: () => client.listVersions(o.key),
82
123
  };
83
124
  }
84
125
  /** The metadata an azurerm backend keeps a lock's info in, base64 JSON, on the leased blob. */
85
126
  export const LOCK_METADATA = "terraformlockid";
86
- /** The azurerm state blob, locked by a lease on it with the lock info in its metadata. */
127
+ /**
128
+ * The account's blob endpoint: the state's, or `https://<account>.blob.<suffix>`
129
+ * with the storage suffix the cloud's metadata at `metadata_host` names (#4793).
130
+ */
131
+ export async function azureEndpoint(o, fetchFn = defaultFetch) {
132
+ if (o.endpoint)
133
+ return o.endpoint;
134
+ if (!o.metadataHost)
135
+ throw new StoreError(`az://${o.account}/${o.container} names neither an endpoint nor a metadata_host`);
136
+ const url = `https://${o.metadataHost}/metadata/endpoints?api-version=2023-11-01`;
137
+ const res = await fetchFn(url, { method: "GET", headers: { accept: "application/json" } });
138
+ const text = await res.text();
139
+ if (!res.ok)
140
+ throw new StoreError(`the Azure metadata at ${o.metadataHost}: ${res.status}`);
141
+ let suffix;
142
+ try {
143
+ const j = JSON.parse(text);
144
+ suffix = (Array.isArray(j) ? j[0] : j)?.suffixes?.storage;
145
+ }
146
+ catch {
147
+ // Reported below.
148
+ }
149
+ if (typeof suffix !== "string" || suffix === "")
150
+ throw new StoreError(`the Azure metadata at ${o.metadataHost} names no storage suffix`);
151
+ return `https://${o.account}.blob.${suffix.replace(/^\.+/, "")}`;
152
+ }
153
+ /**
154
+ * The azurerm state blob, locked by a lease on it with the lock info in its
155
+ * metadata. Its client is made on the first call, once the endpoint is known.
156
+ */
87
157
  function azureStore(o, fetchFn) {
88
- const client = new AzureBlobClient({ account: o.account, container: o.container, endpoint: o.endpoint, ...o.auth }, fetchFn);
158
+ let made;
159
+ const open = () => (made ?? (made = azureEndpoint(o, fetchFn).then((endpoint) => new AzureBlobClient({ account: o.account, container: o.container, endpoint, ...o.auth }, fetchFn))));
89
160
  let leaseId;
90
161
  const at = `az://${o.account}/${o.container}/${o.key}`;
162
+ /** A version id names the blob's versions when it keeps them, else a snapshot does. */
163
+ const atOf = async (c, id) => ((await c.head(o.key)).versionId ? { versionid: id } : { snapshot: id });
91
164
  return {
92
165
  backend: "azurerm",
93
166
  location: at,
94
167
  lockLocation: at,
95
168
  heldLock: async () => {
96
- const head = await client.head(o.key);
169
+ const head = await (await open()).head(o.key);
97
170
  if (!head.exists || head.leaseState !== "leased")
98
171
  return undefined;
99
172
  const meta = head.metadata[LOCK_METADATA];
@@ -101,6 +174,7 @@ function azureStore(o, fetchFn) {
101
174
  return { id: lockId(info), info };
102
175
  },
103
176
  lock: async (info) => {
177
+ const client = await open();
104
178
  const id = lockId(info);
105
179
  // The backend leases a blob that is there: a state with none yet gets an empty one first, as the backend makes it.
106
180
  if (!(await client.head(o.key)).exists)
@@ -114,6 +188,7 @@ function azureStore(o, fetchFn) {
114
188
  unlock: async () => {
115
189
  if (!leaseId)
116
190
  return;
191
+ const client = await open();
117
192
  const id = leaseId;
118
193
  await client.setMetadata(o.key, {}, id);
119
194
  await client.lease(o.key, "release", id);
@@ -122,19 +197,49 @@ function azureStore(o, fetchFn) {
122
197
  write: async (body) => {
123
198
  if (!leaseId)
124
199
  throw new StoreError(`${at} is written under its lease, and none is held`);
200
+ const client = await open();
125
201
  // As the backend writes it: a snapshot first when it takes snapshots, and the lock info kept on the blob.
126
202
  if (o.snapshot && (await client.head(o.key)).exists)
127
203
  await client.snapshot(o.key);
128
204
  const meta = (await client.head(o.key)).metadata;
129
205
  await client.putBlob(o.key, body, JSON_TYPE, { leaseId, metadata: meta });
130
206
  },
131
- readBeside: (suffix) => client.get(`${o.key}${suffix}`),
132
- writeBeside: async (suffix, body) => void (await client.putBlob(`${o.key}${suffix}`, body, JSON_TYPE)),
133
- removeBeside: (suffix) => client.remove(`${o.key}${suffix}`),
207
+ readBeside: async (suffix) => (await open()).get(`${o.key}${suffix}`),
208
+ writeBeside: async (suffix, body) => void (await (await open()).putBlob(`${o.key}${suffix}`, body, JSON_TYPE)),
209
+ removeBeside: async (suffix) => (await open()).remove(`${o.key}${suffix}`),
134
210
  besideLocation: (suffix) => `${at}${suffix}`,
135
211
  adopt: (held) => {
136
212
  leaseId = held.id;
137
213
  },
214
+ version: async (pin = false) => {
215
+ const client = await open();
216
+ const head = await client.head(o.key);
217
+ if (!head.exists)
218
+ return { exists: false };
219
+ if (head.versionId)
220
+ return { exists: true, versionId: head.versionId };
221
+ if (!o.snapshot)
222
+ return { exists: true, off: `blob versioning is off for ${o.account}, and the backend takes no snapshots (snapshot = true), so it keeps only the latest state` };
223
+ return pin ? { exists: true, versionId: await client.snapshot(o.key) } : { exists: true, off: "the blob keeps no versions, and only a snapshot would name this one" };
224
+ },
225
+ hasVersion: async (id) => {
226
+ const client = await open();
227
+ return (await client.head(o.key, await atOf(client, id))).exists;
228
+ },
229
+ readVersion: async (id) => {
230
+ const client = await open();
231
+ return client.readAt(o.key, await atOf(client, id));
232
+ },
233
+ isAt: async (id) => {
234
+ const client = await open();
235
+ const head = await client.head(o.key);
236
+ if (head.versionId)
237
+ return head.versionId === id;
238
+ // A snapshot is a copy, not the blob's own version: the state is at it while the two texts are the same.
239
+ const [then, now] = await Promise.all([client.readAt(o.key, { snapshot: id }), client.get(o.key)]);
240
+ return then !== undefined && now !== undefined && sha(then) === sha(now);
241
+ },
242
+ listVersions: async () => (await open()).listVersions(o.key),
138
243
  };
139
244
  }
140
245
  /** A local state, locked by `<path>.tflock` created only when absent. `dir` is the root the path is relative to. */
@@ -171,15 +276,25 @@ function localStore(o, dir) {
171
276
  removeBeside: async (suffix) => rmSync(`${file}${suffix}`, { force: true }),
172
277
  besideLocation: (suffix) => `${file}${suffix}`,
173
278
  adopt: () => { },
279
+ version: async () => (existsSync(file) ? { exists: true, off: "a local backend keeps only the latest state" } : { exists: false }),
280
+ hasVersion: async () => false,
281
+ readVersion: async () => undefined,
282
+ isAt: async () => false,
174
283
  };
175
284
  }
176
- /** The store a state is in, opened with the credentials stateObject chose. `dir` is the root a local path is relative to. */
177
- export function stateStore(o, dir, fetchFn) {
285
+ /**
286
+ * The store a state is in, opened with the credentials stateObject chose.
287
+ * `dir` is the root a local path is relative to. A GitLab-managed state's
288
+ * store names `who` in the lock info of its probe (./gitlab.ts).
289
+ */
290
+ export function stateStore(o, dir, fetchFn, who) {
178
291
  if (o.backend === "s3")
179
292
  return s3Store(o, fetchFn);
180
293
  if (o.backend === "gcs")
181
294
  return gcsStore(o, fetchFn);
182
295
  if (o.backend === "azurerm")
183
296
  return azureStore(o, fetchFn);
297
+ if (o.backend === "http")
298
+ return gitlabStore(o, fetchFn, who);
184
299
  return localStore(o, dir);
185
300
  }
@@ -1,7 +1,8 @@
1
1
  /**
2
- * A root's state read by version (#4762), for chant core's state export
3
- * (`@intentius/chant/state-export`): the version a bucket or container
4
- * holds now, whether it holds another, and one version's text.
2
+ * A root's state read by version: for chant core's state export (#4762,
3
+ * `@intentius/chant/state-export`), for what an apply leaves, and for an
4
+ * audit of every version a store keeps (#4793). The reads are the stores'
5
+ * (./store.ts):
5
6
  *
6
7
  * s3 bucket versioning: the object's `x-amz-version-id`
7
8
  * gcs object versioning: a version is a generation
@@ -10,17 +11,23 @@
10
11
  * a request for the current version takes one, whose id names it
11
12
  * http a GitLab-managed state (./gitlab.ts): GitLab keeps each version
12
13
  * by its serial, so the version id is the serial
14
+ * local keeps only the latest state
13
15
  *
14
- * A local state keeps no versions, and is refused. Nothing here writes a
15
- * state; the one write is the azurerm snapshot above.
16
+ * A backend chant reads no versions of is named by what it keeps: pg,
17
+ * kubernetes, consul and an http backend other than GitLab's keep no
18
+ * history (each write replaces the state in place), and any other may keep
19
+ * versions chant does not read. Nothing here writes a state; the one write
20
+ * is the azurerm snapshot above.
16
21
  *
17
- * Lifted from terragucci's `backend.ts` (`version`, `hasVersion`,
18
- * `readVersion` of its stores), so terragucci deletes its copy.
22
+ * Lifted from terragucci's `backend.ts`: the `version`, `hasVersion`,
23
+ * `readVersion` and `isAt` of its stores, `keepsHistory`, `stateVersion` and
24
+ * `listStateVersions`, so terragucci deletes its copy.
19
25
  */
20
26
  import type { StateVersionSource } from "@intentius/chant/state-export";
21
- import { type StateObject } from "./backend.js";
22
- import type { GitLabStateStore } from "./gitlab.js";
23
- import type { StoreFetch } from "./object-store.js";
27
+ import { type ObjectVersion } from "@intentius/chant/object-store";
28
+ import { type InitialisedBackend, type StateObject, type StateStoreWords } from "./backend.js";
29
+ import { type GitLabStateStore } from "./gitlab.js";
30
+ import { type StoreFetch } from "./object-store.js";
24
31
  /** What the version reads cover, for a refusal. */
25
32
  export declare const READS_VERSIONS = "a state export reads versions of s3, gcs and azurerm states and GitLab-managed state";
26
33
  /**
@@ -36,4 +43,64 @@ export declare function stateVersionSource(o: StateObject, fetchFn?: StoreFetch,
36
43
  };
37
44
  /** A GitLab-managed state as a version source: the version id is the serial. */
38
45
  export declare function gitlabVersionSource(store: GitLabStateStore): StateVersionSource;
46
+ /**
47
+ * Why a backend keeps no history, for the types that keep none: each write
48
+ * replaces the state in place. GitLab's http backend keeps each version by
49
+ * serial, so an http backend is in this list only when its address is not
50
+ * GitLab's state API.
51
+ */
52
+ export declare const NO_HISTORY: Readonly<Record<string, string>>;
53
+ /** Whether the backend keeps no history of the state: false for one that keeps none, undefined when it may keep some. The address of an http backend is the recorded one, else TF_HTTP_ADDRESS. */
54
+ export declare function keepsHistory(b: InitialisedBackend, env?: NodeJS.ProcessEnv): false | undefined;
55
+ /** The state's address (../compose/state-address.ts) from the configuration init recorded, credentials left out. */
56
+ export declare function recordedAddress(b: InitialisedBackend): string | undefined;
57
+ /** The version of a root's state an apply leaves, as a run records it. */
58
+ export interface RootStateVersion {
59
+ /** The backend the root initialised: `s3`, `local`, `gcs` and so on. */
60
+ backend: string;
61
+ /** Where the state is: `s3://<bucket>/<key>`, `gs://<bucket>/<key>`, `az://<account>/<container>/<key>`, a GitLab state's address, the local file's path, or another backend's address. */
62
+ location?: string;
63
+ /** The backend's id for this version: an S3 version id, a GCS generation, an Azure blob version id or snapshot time, a GitLab serial. Absent when the backend keeps no versions or none could be read. */
64
+ version_id?: string;
65
+ /** `on`: the backend keeps each version; `off`: it keeps only the latest; `unknown`: chant could not tell. */
66
+ versioning: "on" | "off" | "unknown";
67
+ /** Why the version could not be read, or what `off` means for this backend. */
68
+ note?: string;
69
+ }
70
+ export interface ReadStateVersionOptions {
71
+ /** The calls the store makes. Default the global fetch. */
72
+ fetch?: StoreFetch;
73
+ /** Stands in for the backend `init` recorded: a Terragrunt unit's, from its evaluated `remote_state` block. */
74
+ backend?: InitialisedBackend;
75
+ /** The product's words for a credentials refusal (`StateStoreWords`). */
76
+ words?: StateStoreWords;
77
+ }
78
+ /**
79
+ * The version of the state a root's backend holds now, from the object's
80
+ * metadata (#4793). An azurerm blob that keeps snapshots and no versions
81
+ * gets a snapshot, whose time names the version. Never throws: a version
82
+ * that cannot be read is `unknown`, with why.
83
+ */
84
+ export declare function readStateVersion(dir: string, env?: NodeJS.ProcessEnv, options?: ReadStateVersionOptions): Promise<RootStateVersion>;
85
+ /** What a state's store lists of its versions: each one, newest first; why none are listed; or why the list could not be read. */
86
+ export type StateVersionList = {
87
+ versions: ObjectVersion[];
88
+ } | {
89
+ skipped: string;
90
+ } | {
91
+ error: string;
92
+ };
93
+ /**
94
+ * Every version a state's store keeps, by the state's location as a run
95
+ * recorded it (`s3://<bucket>/<key>`, `gs://<bucket>/<key>`,
96
+ * `az://<account>/<container>/<key>`), from the store's list of the
97
+ * object's versions with the job's own identity: ids and times, never a
98
+ * state's contents (#4793). A GitLab state is skipped, since GitLab's state
99
+ * API lists no versions, and so is any other location, with why. Throws
100
+ * only what is neither a store's error nor a failed call.
101
+ */
102
+ export declare function listStateVersions(location: string, env?: NodeJS.ProcessEnv, options?: {
103
+ fetch?: StoreFetch;
104
+ words?: StateStoreWords;
105
+ }): Promise<StateVersionList>;
39
106
  //# sourceMappingURL=versions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../src/state/versions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAAgB,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEtF,OAAO,EAA4B,KAAK,WAAW,EAAoB,MAAM,WAAW,CAAC;AAEzF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,mDAAmD;AACnD,eAAO,MAAM,cAAc,yFAAyF,CAAC;AAiDrH;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,UAAU,EAAE,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,kBAAkB,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAMlJ;AAED,gFAAgF;AAChF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,gBAAgB,GAAG,kBAAkB,CAU/E"}
1
+ {"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../src/state/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M,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8GAA8G;IAC9G,UAAU,EAAE,IAAI,GAAG,KAAK,GAAG,SAAS,CAAC;IACrC,+EAA+E;IAC/E,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,uBAAuB;IACtC,2DAA2D;IAC3D,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,+GAA+G;IAC/G,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,yEAAyE;IACzE,KAAK,CAAC,EAAE,eAAe,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,EAAE,OAAO,GAAE,uBAA4B,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAsB1J;AAED,kIAAkI;AAClI,MAAM,MAAM,gBAAgB,GAAG;IAAE,QAAQ,EAAE,aAAa,EAAE,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvG;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,EAAE,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,UAAU,CAAC;IAAC,KAAK,CAAC,EAAE,eAAe,CAAA;CAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAsBxL"}
@@ -1,59 +1,11 @@
1
- import { AzureBlobClient } from "./azure-blob.js";
2
- import { isRefused, stateLocation } from "./backend.js";
3
- import { GcsClient } from "./gcs.js";
4
- import { S3Client } from "./s3.js";
1
+ import { AzureBlobClient, azureFromEnv, GcsClient, gcsFromEnv, S3Client, s3FromEnv } from "@intentius/chant/object-store";
2
+ import { literal, stateAddress } from "../compose/state-address.js";
3
+ import { initialisedBackend, isRefused, readableStateObject, stateLocation } from "./backend.js";
4
+ import { isGitLabAddress } from "./gitlab.js";
5
+ import { StoreError } from "./object-store.js";
6
+ import { stateStore } from "./store.js";
5
7
  /** What the version reads cover, for a refusal. */
6
8
  export const READS_VERSIONS = "a state export reads versions of s3, gcs and azurerm states and GitLab-managed state";
7
- function s3Versions(o, fetchFn) {
8
- const client = new S3Client(o.target, fetchFn);
9
- return {
10
- location: `s3://${o.bucket}/${o.key}`,
11
- async current() {
12
- const head = await client.head(o.key);
13
- if (!head.exists)
14
- return { exists: false };
15
- return head.versionId ? { exists: true, versionId: head.versionId } : { exists: true, off: `bucket versioning is off for ${o.bucket}, so it keeps only the latest state` };
16
- },
17
- hasVersion: (id) => client.hasVersion(o.key, id),
18
- readVersion: (id) => client.readVersion(o.key, id),
19
- };
20
- }
21
- function gcsVersions(o, fetchFn) {
22
- const client = new GcsClient(o.target, fetchFn);
23
- return {
24
- location: `gs://${o.bucket}/${o.key}`,
25
- async current() {
26
- const head = await client.head(o.key);
27
- if (!head.exists)
28
- return { exists: false };
29
- if ((await client.versioning()) === false)
30
- return { exists: true, off: `object versioning is off for ${o.bucket}, so it keeps only the latest state` };
31
- return { exists: true, ...(head.generation ? { versionId: head.generation } : {}) };
32
- },
33
- hasVersion: async (id) => (await client.head(o.key, id)).exists,
34
- readVersion: (id) => client.readGeneration(o.key, id),
35
- };
36
- }
37
- function azureVersions(o, fetchFn, pin = true) {
38
- const client = new AzureBlobClient({ account: o.account, container: o.container, endpoint: o.endpoint, ...o.auth }, fetchFn);
39
- // A blob that keeps versions names each by its version id; else by a snapshot.
40
- const at = async (id) => ((await client.head(o.key)).versionId ? { versionid: id } : { snapshot: id });
41
- return {
42
- location: `az://${o.account}/${o.container}/${o.key}`,
43
- async current() {
44
- const head = await client.head(o.key);
45
- if (!head.exists)
46
- return { exists: false };
47
- if (head.versionId)
48
- return { exists: true, versionId: head.versionId };
49
- if (!o.snapshot)
50
- return { exists: true, off: `blob versioning is off for ${o.account}, and the backend takes no snapshots (snapshot = true), so it keeps only the latest state` };
51
- return pin ? { exists: true, versionId: await client.snapshot(o.key) } : { exists: true, off: "the blob keeps no versions, and only a snapshot would name this one" };
52
- },
53
- hasVersion: async (id) => (await client.head(o.key, await at(id))).exists,
54
- readVersion: async (id) => client.readAt(o.key, await at(id)),
55
- };
56
- }
57
9
  /**
58
10
  * A root's state as a version source, or why it has none: a refused backend,
59
11
  * or a local state, which keeps no versions. With `pin: false` an azurerm
@@ -65,21 +17,123 @@ export function stateVersionSource(o, fetchFn, options = {}) {
65
17
  return { refused: o.reason };
66
18
  if (o.backend === "local")
67
19
  return { refused: `the state is a local file, ${stateLocation(o)}, which keeps no versions; ${READS_VERSIONS}` };
68
- if (o.backend === "s3")
69
- return s3Versions(o, fetchFn);
70
- if (o.backend === "gcs")
71
- return gcsVersions(o, fetchFn);
72
- return azureVersions(o, fetchFn, options.pin ?? true);
20
+ const store = stateStore(o, "", fetchFn);
21
+ const pin = options.pin ?? true;
22
+ return {
23
+ location: store.location,
24
+ current: () => store.version(pin),
25
+ hasVersion: (id) => store.hasVersion(id),
26
+ readVersion: (id) => store.readVersion(id),
27
+ };
73
28
  }
74
29
  /** A GitLab-managed state as a version source: the version id is the serial. */
75
30
  export function gitlabVersionSource(store) {
76
31
  return {
77
32
  location: store.location,
78
- async current() {
79
- const now = await store.serial();
80
- return now ? { exists: true, versionId: String(now.serial) } : { exists: false };
81
- },
82
- hasVersion: async (id) => /^\d+$/.test(id) && (await store.hasVersion(id)),
33
+ current: () => store.version(),
34
+ hasVersion: (id) => store.hasVersion(id),
83
35
  readVersion: (id) => store.readVersion(id),
84
36
  };
85
37
  }
38
+ /**
39
+ * Why a backend keeps no history, for the types that keep none: each write
40
+ * replaces the state in place. GitLab's http backend keeps each version by
41
+ * serial, so an http backend is in this list only when its address is not
42
+ * GitLab's state API.
43
+ */
44
+ export const NO_HISTORY = {
45
+ pg: "a pg backend keeps one row per workspace, which each write replaces",
46
+ kubernetes: "a kubernetes backend keeps one Secret per workspace, which each write replaces",
47
+ consul: "a consul backend keeps one key per workspace, which each write replaces",
48
+ http: "an http backend keeps what its server holds at the address and names no versions",
49
+ };
50
+ const str = (v) => (typeof v === "string" && v !== "" ? v : undefined);
51
+ /** Whether the backend keeps no history of the state: false for one that keeps none, undefined when it may keep some. The address of an http backend is the recorded one, else TF_HTTP_ADDRESS. */
52
+ export function keepsHistory(b, env = {}) {
53
+ if (!(b.type in NO_HISTORY))
54
+ return undefined;
55
+ if (b.type === "http" && isGitLabAddress(str(b.config.address) ?? env.TF_HTTP_ADDRESS))
56
+ return undefined;
57
+ return false;
58
+ }
59
+ /** The state's address (../compose/state-address.ts) from the configuration init recorded, credentials left out. */
60
+ export function recordedAddress(b) {
61
+ const workspaces = Array.isArray(b.config.workspaces) ? b.config.workspaces[0] : b.config.workspaces;
62
+ const get = (n) => literal(b.config[n] ?? (workspaces && typeof workspaces === "object" ? workspaces[n] : undefined));
63
+ const a = stateAddress(b.type, get, "");
64
+ return "key" in a ? a.key : undefined;
65
+ }
66
+ /**
67
+ * The version of the state a root's backend holds now, from the object's
68
+ * metadata (#4793). An azurerm blob that keeps snapshots and no versions
69
+ * gets a snapshot, whose time names the version. Never throws: a version
70
+ * that cannot be read is `unknown`, with why.
71
+ */
72
+ export async function readStateVersion(dir, env = process.env, options = {}) {
73
+ const recorded = options.backend ?? initialisedBackend(dir, env);
74
+ const o = readableStateObject(dir, env, recorded, options.words);
75
+ if (isRefused(o)) {
76
+ const b = recorded ?? { type: "local", config: {} };
77
+ const location = recordedAddress(b);
78
+ const at = location ? { location } : {};
79
+ if (o.refused !== "backend")
80
+ return { backend: o.backend, ...at, versioning: "unknown", note: o.reason };
81
+ if (keepsHistory(b, env) === false)
82
+ return { backend: b.type, ...at, versioning: "off", note: NO_HISTORY[b.type] };
83
+ return { backend: b.type, ...at, versioning: "unknown", note: `a ${b.type} backend can keep versions of the state, which chant does not read` };
84
+ }
85
+ const location = stateLocation(o);
86
+ if (o.backend === "local")
87
+ return { backend: "local", location, versioning: "off", note: "a local backend keeps only the latest state" };
88
+ try {
89
+ const v = await stateStore(o, dir, options.fetch).version(true);
90
+ if (!v.exists)
91
+ return { backend: o.backend, location, versioning: "unknown", note: o.backend === "http" ? "GitLab holds no state at this address" : `the state object is not in the ${o.backend === "azurerm" ? "container" : "bucket"}` };
92
+ if (v.versionId)
93
+ return { backend: o.backend, location, version_id: v.versionId, versioning: "on" };
94
+ if (v.off)
95
+ return { backend: o.backend, location, versioning: "off", note: v.off };
96
+ return { backend: o.backend, location, versioning: "unknown", note: "the store gave no version id" };
97
+ }
98
+ catch (e) {
99
+ return { backend: o.backend, location, versioning: "unknown", note: e.message };
100
+ }
101
+ }
102
+ /**
103
+ * Every version a state's store keeps, by the state's location as a run
104
+ * recorded it (`s3://<bucket>/<key>`, `gs://<bucket>/<key>`,
105
+ * `az://<account>/<container>/<key>`), from the store's list of the
106
+ * object's versions with the job's own identity: ids and times, never a
107
+ * state's contents (#4793). A GitLab state is skipped, since GitLab's state
108
+ * API lists no versions, and so is any other location, with why. Throws
109
+ * only what is neither a store's error nor a failed call.
110
+ */
111
+ export async function listStateVersions(location, env = process.env, options = {}) {
112
+ const m = /^(s3|gs|az):\/\/([^/]+)\/(.+)$/.exec(location);
113
+ if (!m) {
114
+ if (isGitLabAddress(location))
115
+ return { skipped: "GitLab's state API lists no versions of a state" };
116
+ return { skipped: "chant lists the versions of s3, gcs and azurerm states only" };
117
+ }
118
+ const [, scheme, bucket, rest] = m;
119
+ const words = { setting: "the state bucket", sessionName: "chant-state", ...options.words };
120
+ try {
121
+ let versions;
122
+ if (scheme === "s3")
123
+ versions = await new S3Client(s3FromEnv({ bucket, ...words }, env), options.fetch).listVersions(rest);
124
+ else if (scheme === "gs")
125
+ versions = await new GcsClient(gcsFromEnv({ bucket, ...words }, env), options.fetch).listVersions(rest);
126
+ else {
127
+ const [container, ...key] = rest.split("/");
128
+ if (!container || key.length === 0)
129
+ return { skipped: `${location} names no blob` };
130
+ versions = await new AzureBlobClient(azureFromEnv({ account: bucket, container, ...words }, env), options.fetch).listVersions(key.join("/"));
131
+ }
132
+ return versions.length > 0 ? { versions } : { skipped: "the store lists no versions of the state" };
133
+ }
134
+ catch (e) {
135
+ if (!(e instanceof StoreError) && !(e instanceof TypeError))
136
+ throw e;
137
+ return { error: e.message };
138
+ }
139
+ }
@@ -1,5 +1,6 @@
1
1
  import type { MigrationRootPlan, StateMigrationEngine } from "@intentius/chant/state-migration";
2
2
  import { type RootRun } from "./state-ops.js";
3
+ import { type InitialisedBackend, type LockableState } from "./state/backend.js";
3
4
  import { type BinaryExec, type StateFile, type StateResource } from "./state/exec.js";
4
5
  import { type LockOperation } from "./state/locks.js";
5
6
  import type { StoreFetch } from "./state/object-store.js";
@@ -19,6 +20,19 @@ export interface Restore {
19
20
  /** The version the migration left: a state that moved past it is refused. */
20
21
  from_version_id: string | null;
21
22
  }
23
+ /** A root's state moving to the backend its code now names, from the backend it was in (#4806). */
24
+ export interface BackendMove {
25
+ root: string;
26
+ /** Where the state is now: a backend's type and configuration, as a backend block gives them; `remote` or `cloud` for a TFE-API workspace; `file` with `config.path` for an exported state file. */
27
+ from: {
28
+ backend: string;
29
+ config: Record<string, unknown>;
30
+ };
31
+ }
32
+ /** The backends a migration reads and writes through the binary, under the backend's own lock: those that keep no versions (#4806). */
33
+ export declare const PULLED_BACKENDS: readonly string[];
34
+ /** The backends a migration locks and writes itself. */
35
+ export declare const MIGRATED_BACKENDS: readonly string[];
22
36
  /** A migration that cannot be planned: an address in no state, a root that is refused. Nothing was written. */
23
37
  export declare class MigrationError extends Error {
24
38
  constructor(message: string);
@@ -29,6 +43,28 @@ export declare const stateDigest: (s: StateFile) => string;
29
43
  export declare function addressMatches(address: string, r: StateResource): boolean;
30
44
  /** A lineage that a migration and a root always give the same: a state planned twice has one digest. */
31
45
  export declare function derivedLineage(...parts: string[]): string;
46
+ /** A state the binary reads and writes for a migration, under its backend's own lock: one that keeps no versions (pg, kubernetes, consul, an http backend other than GitLab's). */
47
+ export interface PulledState {
48
+ backend: string;
49
+ pulled: true;
50
+ /** Its address, credentials left out, when the configuration names one. */
51
+ location?: string;
52
+ }
53
+ /** The backend as a pulled state, or undefined when it is not one that keeps no versions. */
54
+ export declare function pulledState(b: InitialisedBackend, env?: NodeJS.ProcessEnv): PulledState | undefined;
55
+ /** A state a migration writes or reads: one chant locks, or one the binary reads and writes under its own lock. */
56
+ export type MigratedState = LockableState | PulledState;
57
+ /** Where a migrated state is, as the record names it. */
58
+ export declare const migratedLocation: (o: MigratedState) => string | undefined;
59
+ /**
60
+ * Problems with backend moves as a migration file gives them, one line each,
61
+ * headed `backends[<i>]`: a root that moves twice, a source backend chant
62
+ * does not read, a config that does not say where the state is, a
63
+ * credential written in the repo. None: the moves can be planned.
64
+ */
65
+ export declare function backendMoveProblems(moves: readonly BackendMove[]): string[];
66
+ /** A terraform block whose backend is `type` with `config`, for an override file. */
67
+ export declare function backendBlock(type: string, config: Record<string, unknown>): string;
32
68
  /**
33
69
  * The states after the moves. `before` holds each affected root's state, or
34
70
  * null when it has none. A changed state keeps its lineage and gets the next
@@ -57,14 +93,20 @@ export interface TerraformMigrationInput {
57
93
  moves?: Move[];
58
94
  /** States put back to a version a migration recorded. */
59
95
  restores?: Restore[];
60
- /** Every root the moves or restores name. */
96
+ /** States moved to the backend each root's code names now (#4806). */
97
+ backends?: BackendMove[];
98
+ /** Every root the moves, restores or backend moves name. */
61
99
  roots: MigrationRootRun[];
100
+ /** What a `file` source's relative path is read from. Default the working directory. */
101
+ repo?: string;
62
102
  /** The work dir: new states, plans and data dirs. The caller removes it. */
63
103
  work: string;
64
104
  exec?: BinaryExec;
65
105
  fetch?: StoreFetch;
66
106
  /** What the migration's lock says. */
67
107
  lock?: LockOperation;
108
+ /** What the lock of a workspace a backend move reads from says. Default the migration's operation, reading. */
109
+ sourceLock?: LockOperation;
68
110
  /** Who the lock names. Default `chant@<host>`. */
69
111
  who?: string;
70
112
  /** The proof plan's override file. Default {@link DEFAULT_OVERRIDE_FILE}. */
@@ -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