@intentius/chant-lexicon-terraform 0.124.103 → 0.124.104
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/dist/chant-floors.d.ts +4 -0
- package/dist/chant-floors.js +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/integrity.json +2 -2
- package/dist/manifest.json +1 -1
- package/dist/plugin.d.ts +0 -8
- package/dist/plugin.js +10 -0
- package/dist/state-locations.d.ts +40 -0
- package/dist/state-locations.js +104 -0
- package/package.json +2 -2
package/dist/chant-floors.d.ts
CHANGED
|
@@ -39,3 +39,7 @@ export declare const TERRAFORM_OWNERSHIP_ROWS_FLOOR = "0.124.103";
|
|
|
39
39
|
* `@intentius/chant` at `UNDECLARED_LIVE_NODES_FLOOR` or later to draw them.
|
|
40
40
|
*/
|
|
41
41
|
export declare const TERRAFORM_UNDECLARED_NODES_FLOOR = "0.124.103";
|
|
42
|
+
/**
|
|
43
|
+
* The first terraform lexicon release whose roots publish `stateLocations` on their graph meta, so `chant workspace state` says where a root's state lives: the backend block with the `-backend-config` files, pairs and `TF_CLI_ARGS` flags over it (s3 with its lockfile or DynamoDB table, gcs, azurerm, http, local, cloud), the root's estate or workspace as its environment, and the record store of a choudoufu live block (#5456).
|
|
44
|
+
*/
|
|
45
|
+
export declare const TERRAFORM_STATE_LOCATIONS_FLOOR = "0.124.104";
|
package/dist/chant-floors.js
CHANGED
|
@@ -39,3 +39,7 @@ export const TERRAFORM_OWNERSHIP_ROWS_FLOOR = "0.124.103";
|
|
|
39
39
|
* `@intentius/chant` at `UNDECLARED_LIVE_NODES_FLOOR` or later to draw them.
|
|
40
40
|
*/
|
|
41
41
|
export const TERRAFORM_UNDECLARED_NODES_FLOOR = "0.124.103";
|
|
42
|
+
/**
|
|
43
|
+
* The first terraform lexicon release whose roots publish `stateLocations` on their graph meta, so `chant workspace state` says where a root's state lives: the backend block with the `-backend-config` files, pairs and `TF_CLI_ARGS` flags over it (s3 with its lockfile or DynamoDB table, gcs, azurerm, http, local, cloud), the root's estate or workspace as its environment, and the record store of a choudoufu live block (#5456).
|
|
44
|
+
*/
|
|
45
|
+
export const TERRAFORM_STATE_LOCATIONS_FLOOR = "0.124.104";
|
package/dist/index.d.ts
CHANGED
|
@@ -29,4 +29,4 @@ export { predictTerraformBehaviour, terraformBehaviourRequest, terraformPredictO
|
|
|
29
29
|
export { terraformExitOf, terraformPlanMoved, type TerraformExitSource } from "./exit-codes.js";
|
|
30
30
|
export { classifyTerraformDisruption, terraformActionsDisruption, terraformDisruptionQueries, terraformQueryVerdict, } from "./disruption.js";
|
|
31
31
|
export { TERRAFORM_HEALTH_TYPES, terraformHealthTargets } from "./health-targets.js";
|
|
32
|
-
export { TERRAFORM_HEALTH_DISRUPTION_FLOOR, TERRAFORM_OWNERSHIP_ROWS_FLOOR, TERRAFORM_UNDECLARED_NODES_FLOOR } from "./chant-floors.js";
|
|
32
|
+
export { TERRAFORM_HEALTH_DISRUPTION_FLOOR, TERRAFORM_OWNERSHIP_ROWS_FLOOR, TERRAFORM_UNDECLARED_NODES_FLOOR, TERRAFORM_STATE_LOCATIONS_FLOOR } from "./chant-floors.js";
|
package/dist/index.js
CHANGED
|
@@ -71,4 +71,4 @@ export { terraformExitOf, terraformPlanMoved } from "./exit-codes.js";
|
|
|
71
71
|
// Disruption from a plan's actions and health through the provider lexicons (#5338).
|
|
72
72
|
export { classifyTerraformDisruption, terraformActionsDisruption, terraformDisruptionQueries, terraformQueryVerdict, } from "./disruption.js";
|
|
73
73
|
export { TERRAFORM_HEALTH_TYPES, terraformHealthTargets } from "./health-targets.js";
|
|
74
|
-
export { TERRAFORM_HEALTH_DISRUPTION_FLOOR, TERRAFORM_OWNERSHIP_ROWS_FLOOR, TERRAFORM_UNDECLARED_NODES_FLOOR } from "./chant-floors.js";
|
|
74
|
+
export { TERRAFORM_HEALTH_DISRUPTION_FLOOR, TERRAFORM_OWNERSHIP_ROWS_FLOOR, TERRAFORM_UNDECLARED_NODES_FLOOR, TERRAFORM_STATE_LOCATIONS_FLOOR } from "./chant-floors.js";
|
package/dist/integrity.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"algorithm": "sha256",
|
|
3
3
|
"artifacts": {
|
|
4
|
-
"manifest.json": "
|
|
4
|
+
"manifest.json": "3ba459e2176a939da05be0d81f21e82770981aeabfd328fa5b29dddc61314b87",
|
|
5
5
|
"meta.json": "ca3d163bab055381827226140568f3bef7eaac187cebd76878e0b63e9e442356",
|
|
6
6
|
"types/index.d.ts": "022927e6a7b351cc4cf52d5f973f60ccd140e5810e17b32fb8868965aa1db161",
|
|
7
7
|
"rules/plan-before-apply.ts": "7c10245b2c3335253b48ee7d8b075d89f43116bde20313a5d1031b343fef1282",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"rules/tf047.ts": "bfa86f85c4c5efff297280fc2f15104d6319fa96dfc444a31829fb7353224092",
|
|
60
60
|
"skills/chant-terraform.md": "53dd11c7b289652f92fdaf2c03766abda46d8964e31fe709e8b142ced4f19c50"
|
|
61
61
|
},
|
|
62
|
-
"composite": "
|
|
62
|
+
"composite": "6c90406fac17be37b6285ec1196a77d2e1583d5229f818a5d30b735c81c06eac"
|
|
63
63
|
}
|
package/dist/manifest.json
CHANGED
package/dist/plugin.d.ts
CHANGED
|
@@ -1,10 +1,2 @@
|
|
|
1
1
|
import type { LexiconPlugin } from "@intentius/chant/lexicon";
|
|
2
|
-
/**
|
|
3
|
-
* terraform lexicon plugin.
|
|
4
|
-
*
|
|
5
|
-
* There is no upstream schema to pin here: Terraform's resource surface lives
|
|
6
|
-
* in provider registries, one schema per provider, and this lexicon reads the
|
|
7
|
-
* HCL an estate already has rather than generating types for it. So `spec/`
|
|
8
|
-
* and `codegen/` stay near-empty and there is no `upstreamPin`.
|
|
9
|
-
*/
|
|
10
2
|
export declare const terraformPlugin: LexiconPlugin;
|
package/dist/plugin.js
CHANGED
|
@@ -66,6 +66,8 @@ function looksLikeHcl(text) {
|
|
|
66
66
|
* HCL an estate already has rather than generating types for it. So `spec/`
|
|
67
67
|
* and `codegen/` stay near-empty and there is no `upstreamPin`.
|
|
68
68
|
*/
|
|
69
|
+
/** The state locations of the roots `buildRoots` read in this process, for `graphMeta` (#5456). */
|
|
70
|
+
let lastStateLocations;
|
|
69
71
|
export const terraformPlugin = {
|
|
70
72
|
behaviourKinds: terraformBehaviourKinds,
|
|
71
73
|
name: "terraform",
|
|
@@ -197,8 +199,12 @@ export const terraformPlugin = {
|
|
|
197
199
|
const namespace = ctx.config.terraform;
|
|
198
200
|
// A `signalOnly` root (#4484) feeds change detection only, so it builds no entities here.
|
|
199
201
|
const roots = ownRoots(namespace?.roots);
|
|
202
|
+
lastStateLocations = undefined;
|
|
200
203
|
if (Object.keys(roots).length === 0)
|
|
201
204
|
return { entities: new Map(), warnings: [] };
|
|
205
|
+
// Where each root's state lives (#5456), published by graphMeta below.
|
|
206
|
+
const { terraformStateLocations } = await import("./state-locations.js");
|
|
207
|
+
lastStateLocations = terraformStateLocations(ctx.projectRoot, roots, { binary: namespace?.binary });
|
|
202
208
|
return renderTerraformRoots({
|
|
203
209
|
projectRoot: ctx.projectRoot,
|
|
204
210
|
roots,
|
|
@@ -207,6 +213,10 @@ export const terraformPlugin = {
|
|
|
207
213
|
moduleRoot: namespace?.moduleRoot,
|
|
208
214
|
});
|
|
209
215
|
},
|
|
216
|
+
/** Where each root's state lives, for `chant workspace state` (#5456). */
|
|
217
|
+
graphMeta() {
|
|
218
|
+
return lastStateLocations ? { stateLocations: lastStateLocations } : undefined;
|
|
219
|
+
},
|
|
210
220
|
/** `chant terraform pin-rollout` (#3189). */
|
|
211
221
|
commands() {
|
|
212
222
|
return terraformCommands;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
type Scalar = string | number | boolean | null;
|
|
2
|
+
export interface TerraformStateLocation {
|
|
3
|
+
environment: string | null;
|
|
4
|
+
unit: string;
|
|
5
|
+
substrate: "terraform";
|
|
6
|
+
backend: {
|
|
7
|
+
kind: string;
|
|
8
|
+
location: Record<string, Scalar>;
|
|
9
|
+
};
|
|
10
|
+
lock: {
|
|
11
|
+
mechanism: string;
|
|
12
|
+
location?: Record<string, Scalar>;
|
|
13
|
+
} | null;
|
|
14
|
+
reach: {
|
|
15
|
+
status: "unchecked";
|
|
16
|
+
reason: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** The root fields a location is read from. */
|
|
20
|
+
export interface StateRoot {
|
|
21
|
+
dir: string;
|
|
22
|
+
workspace?: string;
|
|
23
|
+
estate?: string;
|
|
24
|
+
backendConfig?: Readonly<Record<string, string>>;
|
|
25
|
+
backendConfigFiles?: readonly string[];
|
|
26
|
+
}
|
|
27
|
+
/** One backend as a location and a lock. A backend chant has no reading for keeps its type and the keys it names. */
|
|
28
|
+
export declare function backendLocation(type: string, config: Record<string, unknown>, workspace: string | undefined): {
|
|
29
|
+
backend: TerraformStateLocation["backend"];
|
|
30
|
+
lock: TerraformStateLocation["lock"];
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The state locations of the given roots, in name order: one for each root's
|
|
34
|
+
* backend, and one for the record store of each root with a live block.
|
|
35
|
+
*/
|
|
36
|
+
export declare function terraformStateLocations(projectRoot: string, roots: Readonly<Record<string, StateRoot>>, options?: {
|
|
37
|
+
binary?: string;
|
|
38
|
+
env?: NodeJS.ProcessEnv;
|
|
39
|
+
}): TerraformStateLocation[];
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where each Terraform root's state lives (#5456), as the entries `chant
|
|
3
|
+
* workspace state` reads from the member graph's `meta.stateLocations`.
|
|
4
|
+
*
|
|
5
|
+
* A root's backend is what its code declares with the `-backend-config`
|
|
6
|
+
* files, pairs and `TF_CLI_ARGS` flags applied over it ({@link declaredBackend}),
|
|
7
|
+
* the same reading the state and lock paths use. A root's environment is its
|
|
8
|
+
* `estate`, else its `workspace`, and an s3 key as the backend names it for a
|
|
9
|
+
* non-default workspace (`env:/<workspace>/<key>`). A root with a choudoufu
|
|
10
|
+
* live block also has its record store. Text reads only: nothing is run, no
|
|
11
|
+
* bucket is called, so `reach` is `unchecked`.
|
|
12
|
+
*/
|
|
13
|
+
import { resolve } from "node:path";
|
|
14
|
+
import { declaredBackend } from "./state/backend.js";
|
|
15
|
+
import { writtenRecordStore } from "./live-roots.js";
|
|
16
|
+
const UNCHECKED = { status: "unchecked", reason: "the location is read from configuration; no call is made to it" };
|
|
17
|
+
const text = (v) => (typeof v === "string" && v !== "" ? v : null);
|
|
18
|
+
/** An s3 backend's key for a workspace: the backend's own rule, `<prefix>/<workspace>/<key>` with `env:` as the default prefix. */
|
|
19
|
+
function s3Key(config, workspace) {
|
|
20
|
+
const key = text(config.key);
|
|
21
|
+
if (!key || !workspace || workspace === "default")
|
|
22
|
+
return key;
|
|
23
|
+
return `${text(config.workspace_key_prefix) ?? "env:"}/${workspace}/${key}`;
|
|
24
|
+
}
|
|
25
|
+
function located(config, keys) {
|
|
26
|
+
return Object.fromEntries(keys.map((k) => [k, typeof config[k] === "number" || typeof config[k] === "boolean" ? config[k] : text(config[k])]));
|
|
27
|
+
}
|
|
28
|
+
/** One backend as a location and a lock. A backend chant has no reading for keeps its type and the keys it names. */
|
|
29
|
+
export function backendLocation(type, config, workspace) {
|
|
30
|
+
switch (type) {
|
|
31
|
+
case "s3": {
|
|
32
|
+
const key = s3Key(config, workspace);
|
|
33
|
+
const lockfile = config.use_lockfile === true;
|
|
34
|
+
const table = text(config.dynamodb_table);
|
|
35
|
+
return {
|
|
36
|
+
backend: { kind: "s3", location: { bucket: text(config.bucket), key, region: text(config.region) } },
|
|
37
|
+
lock: lockfile
|
|
38
|
+
? { mechanism: "s3-lockfile", location: { key: key ? `${key}.tflock` : null } }
|
|
39
|
+
: table
|
|
40
|
+
? { mechanism: "dynamodb", location: { table } }
|
|
41
|
+
: null,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
case "gcs":
|
|
45
|
+
return {
|
|
46
|
+
backend: { kind: "gcs", location: { bucket: text(config.bucket), prefix: text(config.prefix) } },
|
|
47
|
+
lock: { mechanism: "gcs-object" },
|
|
48
|
+
};
|
|
49
|
+
case "azurerm":
|
|
50
|
+
return {
|
|
51
|
+
backend: { kind: "azurerm", location: located(config, ["storage_account_name", "container_name", "key", "resource_group_name"]) },
|
|
52
|
+
lock: { mechanism: "blob-lease" },
|
|
53
|
+
};
|
|
54
|
+
case "http":
|
|
55
|
+
return {
|
|
56
|
+
backend: { kind: "http", location: located(config, ["address"]) },
|
|
57
|
+
lock: text(config.lock_address) ? { mechanism: "http-lock", location: located(config, ["lock_address"]) } : null,
|
|
58
|
+
};
|
|
59
|
+
case "local":
|
|
60
|
+
return { backend: { kind: "local", location: { path: text(config.path) ?? "terraform.tfstate" } }, lock: { mechanism: "local-file" } };
|
|
61
|
+
case "cloud":
|
|
62
|
+
return { backend: { kind: "cloud", location: located(config, ["organization", "hostname"]) }, lock: { mechanism: "terraform-cloud" } };
|
|
63
|
+
default:
|
|
64
|
+
return { backend: { kind: type, location: located(config, Object.keys(config).sort()) }, lock: null };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The state locations of the given roots, in name order: one for each root's
|
|
69
|
+
* backend, and one for the record store of each root with a live block.
|
|
70
|
+
*/
|
|
71
|
+
export function terraformStateLocations(projectRoot, roots, options = {}) {
|
|
72
|
+
const out = [];
|
|
73
|
+
for (const name of Object.keys(roots).sort()) {
|
|
74
|
+
const root = roots[name];
|
|
75
|
+
const dir = resolve(projectRoot, root.dir);
|
|
76
|
+
// A live root's estate is its environment (config.ts); a stock root's is its workspace.
|
|
77
|
+
const environment = root.estate ?? root.workspace ?? null;
|
|
78
|
+
const declared = declaredBackend(dir, {
|
|
79
|
+
binary: options.binary,
|
|
80
|
+
env: options.env ?? process.env,
|
|
81
|
+
...(root.backendConfig ? { backendConfig: root.backendConfig } : {}),
|
|
82
|
+
...(root.backendConfigFiles ? { backendConfigFiles: root.backendConfigFiles } : {}),
|
|
83
|
+
});
|
|
84
|
+
// No backend block is the local backend, which init records as no backend at all.
|
|
85
|
+
const { backend, lock } = backendLocation(declared?.type ?? "local", declared?.config ?? {}, root.workspace);
|
|
86
|
+
out.push({ environment, unit: name, substrate: "terraform", backend, lock, reach: UNCHECKED });
|
|
87
|
+
const store = writtenRecordStore(dir, root.estate ?? name, options.binary);
|
|
88
|
+
if (store) {
|
|
89
|
+
out.push({
|
|
90
|
+
environment,
|
|
91
|
+
unit: `${name} (records)`,
|
|
92
|
+
substrate: "terraform",
|
|
93
|
+
backend: store.kind === "s3"
|
|
94
|
+
? { kind: "choudoufu-record-store:s3", location: { bucket: store.bucket, prefix: store.prefix, region: store.region ?? null } }
|
|
95
|
+
: store.kind === "local"
|
|
96
|
+
? { kind: "choudoufu-record-store:local", location: { dir: store.dir, prefix: store.prefix } }
|
|
97
|
+
: { kind: `choudoufu-record-store:${store.name}`, location: {} },
|
|
98
|
+
lock: null,
|
|
99
|
+
reach: UNCHECKED,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return out;
|
|
104
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/chant-lexicon-terraform",
|
|
3
|
-
"version": "0.124.
|
|
3
|
+
"version": "0.124.104",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"access": "public"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
|
-
"@intentius/chant": "^0.124.
|
|
95
|
+
"@intentius/chant": "^0.124.114",
|
|
96
96
|
"zod": "^4.3.6"
|
|
97
97
|
},
|
|
98
98
|
"description": "terraform lexicon for chant, existing Terraform root modules as declarable entities",
|