@intentius/chant-lexicon-terraform 0.76.0 → 0.78.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/dist/behaviour/kinds.d.ts +9 -0
- package/dist/behaviour/kinds.d.ts.map +1 -1
- package/dist/describe-resources.d.ts +3 -2
- package/dist/describe-resources.d.ts.map +1 -1
- package/dist/hcl/descend.d.ts +1 -1
- package/dist/hcl/parse.d.ts +2 -2
- package/dist/hcl/roots.d.ts +1 -1
- package/dist/hcl/suppressions.d.ts +1 -1
- package/dist/hcl/value.d.ts +1 -1
- package/dist/integrity.json +3 -3
- package/dist/lint/post-synth/tf016.d.ts +1 -1
- package/dist/manifest.json +1 -1
- package/dist/op/activities/live-detect.d.ts +1 -1
- package/dist/op/activities/terraform.d.ts +38 -0
- package/dist/op/activities/terraform.d.ts.map +1 -1
- package/dist/rules/tf016.ts +1 -1
- package/package.json +5 -5
- package/src/behaviour/kinds.ts +6 -1
- package/src/behaviour/predict.ts +2 -2
- package/src/describe-resources.ts +4 -3
- package/src/hcl/descend.ts +1 -1
- package/src/hcl/parse.ts +2 -2
- package/src/hcl/roots.ts +1 -1
- package/src/hcl/suppressions.ts +1 -1
- package/src/hcl/value.ts +1 -1
- package/src/lint/post-synth/tf016.ts +1 -1
- package/src/op/activities/live-detect.ts +1 -1
- package/src/op/activities/terraform.test.ts +117 -0
- package/src/op/activities/terraform.ts +85 -28
|
@@ -31,6 +31,15 @@
|
|
|
31
31
|
import type { BehaviourKinds } from "@intentius/chant/behaviour-kinds";
|
|
32
32
|
/** The entity type every `resource` block arrives as. */
|
|
33
33
|
export declare const TERRAFORM_RESOURCE_TYPE = "Terraform::Resource";
|
|
34
|
+
/**
|
|
35
|
+
* Provider prefixes that are a substrate boundary rather than a missing row,
|
|
36
|
+
* each named as the substrate. Exported so the coverage page (#2404) can list
|
|
37
|
+
* them from the same table `notModelledWhen` reads.
|
|
38
|
+
*/
|
|
39
|
+
export declare const UNMODELLED_TERRAFORM_PROVIDERS: ReadonlyArray<{
|
|
40
|
+
prefix: string;
|
|
41
|
+
substrate: string;
|
|
42
|
+
}>;
|
|
34
43
|
/** This lexicon's answer for its own blocks. */
|
|
35
44
|
export declare const terraformBehaviourKinds: BehaviourKinds;
|
|
36
45
|
//# sourceMappingURL=kinds.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kinds.d.ts","sourceRoot":"","sources":["../../src/behaviour/kinds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAEvE,yDAAyD;AACzD,eAAO,MAAM,uBAAuB,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"kinds.d.ts","sourceRoot":"","sources":["../../src/behaviour/kinds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAEvE,yDAAyD;AACzD,eAAO,MAAM,uBAAuB,wBAAwB,CAAC;AA4G7D;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,EAAE,aAAa,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAmB/F,CAAC;AAoBF,gDAAgD;AAChD,eAAO,MAAM,uBAAuB,EAAE,cAiBrC,CAAC"}
|
|
@@ -155,7 +155,7 @@
|
|
|
155
155
|
import type { DescribeResourcesResult, ResourceMetadata, TeardownEnumeration } from "@intentius/chant/lexicon";
|
|
156
156
|
import { type DeclaredEntity, type UnobservedReason } from "@intentius/chant/observation";
|
|
157
157
|
import type { OwnershipMarker } from "@intentius/chant/ownership";
|
|
158
|
-
import { choudoufuLiveLs,
|
|
158
|
+
import { choudoufuLiveLs, choudoufuLivePlanDocument, terraformInit, terraformShow } from "./op/activities/terraform.js";
|
|
159
159
|
export { TERRAFORM_STATE_OWNERSHIP_KEYS } from "./state-ownership.js";
|
|
160
160
|
export { TERRAFORM_LIVE_MARKER_KEYS } from "./live-ownership.js";
|
|
161
161
|
/** One row out of `values.root_module.resources[]`, at any module depth. */
|
|
@@ -418,7 +418,8 @@ export declare function teardownOwned(options: {
|
|
|
418
418
|
export interface TerraformReadDeps {
|
|
419
419
|
init: typeof terraformInit;
|
|
420
420
|
show: typeof terraformShow;
|
|
421
|
-
|
|
421
|
+
/** The document alone (chant #2498): this reader indexes it and never reads the human render. */
|
|
422
|
+
livePlan: typeof choudoufuLivePlanDocument;
|
|
422
423
|
liveLs: typeof choudoufuLiveLs;
|
|
423
424
|
}
|
|
424
425
|
/** A declared entity, plus the root, address and mode `buildRoots()` recorded on it. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe-resources.d.ts","sourceRoot":"","sources":["../src/describe-resources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyJG;AAEH,OAAO,KAAK,EACV,uBAAuB,EACvB,gBAAgB,EAEhB,mBAAmB,EAEpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAKL,KAAK,cAAc,EAGnB,KAAK,gBAAgB,EACtB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EACL,eAAe,EACf,
|
|
1
|
+
{"version":3,"file":"describe-resources.d.ts","sourceRoot":"","sources":["../src/describe-resources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;IAC9E;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,wBAAwB,EACjC,IAAI,GAAE,iBAA6B,GAClC,OAAO,CAAC,uBAAuB,CAAC,CAuElC"}
|
package/dist/hcl/descend.d.ts
CHANGED
|
@@ -73,7 +73,7 @@ export interface DescendOptions {
|
|
|
73
73
|
projectRoot: string;
|
|
74
74
|
/** Resolved mode. `"none"` returns immediately with nothing. */
|
|
75
75
|
callModuleType?: "local" | "none";
|
|
76
|
-
/** Injectable parser (tests); defaults to core's lazy-loaded `@
|
|
76
|
+
/** Injectable parser (tests); defaults to core's lazy-loaded `@cdktn/hcl2json`. */
|
|
77
77
|
hcl2json?: Hcl2Json;
|
|
78
78
|
/** Mode facts stamped onto the child's entities, exactly as on the root's. */
|
|
79
79
|
modeOptions?: TerraformRootModeOptions;
|
package/dist/hcl/parse.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Both funnel through `blocksToEntities`, so an entity the audit path sees is
|
|
10
10
|
* the entity the build path sees.
|
|
11
11
|
*
|
|
12
|
-
* Core owns the parser glue: `loadHcl2json()` lazy-loads `@
|
|
12
|
+
* Core owns the parser glue: `loadHcl2json()` lazy-loads `@cdktn/hcl2json`
|
|
13
13
|
* (a ~1.8 MB wasm blob) and raises a one-line install hint when it is absent.
|
|
14
14
|
* `parseTerraformDir()` next to it is NOT reused: it returns carve's `TfGraph`,
|
|
15
15
|
* a scoring-and-excision shape with no room for the per-block bodies a
|
|
@@ -22,7 +22,7 @@ import { type Declarable } from "@intentius/chant/declarable";
|
|
|
22
22
|
import type { EntityReference } from "@intentius/chant/graph-ir";
|
|
23
23
|
import type { SuppressionDirective } from "@intentius/chant/lint/suppressions";
|
|
24
24
|
import type { TerraformDeleteMode } from "../config.js";
|
|
25
|
-
/** A parsed HCL block body, as `@
|
|
25
|
+
/** A parsed HCL block body, as `@cdktn/hcl2json` encodes it. */
|
|
26
26
|
export type BlockBody = Record<string, unknown>;
|
|
27
27
|
/**
|
|
28
28
|
* The meta-argument that expands a block into instances, when it carries one
|
package/dist/hcl/roots.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ export interface RenderTerraformRootsOptions {
|
|
|
49
49
|
* `../` is parsed as a child scope of the root that calls it.
|
|
50
50
|
*/
|
|
51
51
|
callModuleType?: CallModuleType;
|
|
52
|
-
/** Injectable parser (tests); defaults to core's lazy-loaded `@
|
|
52
|
+
/** Injectable parser (tests); defaults to core's lazy-loaded `@cdktn/hcl2json`. */
|
|
53
53
|
hcl2json?: Hcl2Json;
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* `hcl2json` drops comments entirely, and a probe of its output confirmed it
|
|
5
5
|
* exposes no source ranges either, so a suppression comment has nothing to
|
|
6
|
-
* attach to once a file goes through `@
|
|
6
|
+
* attach to once a file goes through `@cdktn/hcl2json`. This module runs a
|
|
7
7
|
* second, cheap pass over the SAME raw text `./parse.ts` hands the parser,
|
|
8
8
|
* entirely with line-oriented regexes: a brace-depth counter to find each
|
|
9
9
|
* top-level block's start line (`terraform`, `locals`, `provider "x"`,
|
package/dist/hcl/value.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* A value envelope over a parsed block body (chant #2113).
|
|
3
3
|
*
|
|
4
4
|
* Every TF post-synth check reads `BlockBody` (`./parse.ts`), raw
|
|
5
|
-
* `@
|
|
5
|
+
* `@cdktn/hcl2json` output, and re-derives, by hand, whether an attribute is
|
|
6
6
|
* a plain literal, a reference/expression, or absent. tflint's OPA ruleset
|
|
7
7
|
* hands a policy `{value, unknown, sensitive, ephemeral, range}` per
|
|
8
8
|
* attribute so a check reads that uniformly instead of re-deriving it
|
package/dist/integrity.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"algorithm": "sha256",
|
|
3
3
|
"artifacts": {
|
|
4
|
-
"manifest.json": "
|
|
4
|
+
"manifest.json": "4fb68c54608a0e076835585238168da0c977938ef5629481a42c888c1c148443",
|
|
5
5
|
"meta.json": "ca3d163bab055381827226140568f3bef7eaac187cebd76878e0b63e9e442356",
|
|
6
6
|
"types/index.d.ts": "022927e6a7b351cc4cf52d5f973f60ccd140e5810e17b32fb8868965aa1db161",
|
|
7
7
|
"rules/plan-before-apply.ts": "31b1b3176799fd365b2583fe3947edd187c2a863e3dc0094ed9e91ece2464c99",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"rules/tf013.ts": "096c3e7e51a8a54fd4354f6a93dc1f3540e155ef5e6ef39407904465803aaa2c",
|
|
24
24
|
"rules/tf014.ts": "c17d6c75fe0d38984a0108f4238667e9c069a0a761811d59f8ef9f67b5d8c5f3",
|
|
25
25
|
"rules/tf015.ts": "7190c71139f66ed0862725aead01b5eb3e6d366d1318a0506060b4c3d2417364",
|
|
26
|
-
"rules/tf016.ts": "
|
|
26
|
+
"rules/tf016.ts": "315cbb1d1485c28dd15ee82876938d8205f1828e0b310a43fb6e5cfe6977e3ca",
|
|
27
27
|
"rules/tf017.ts": "1b11c1a21aca33f5e634732fd23b57ac4c2e02af9ef531890d88c401fa593832",
|
|
28
28
|
"rules/tf018.ts": "188a56a73c53423ce4b653540cb4ab2b7aa64d10bb9bad090d392e2bfd821d0a",
|
|
29
29
|
"rules/tf019.ts": "ae1841a358e5b7a3f42c484f0b5cf1c1f5aa845a50516969a46d65b13e282951",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"rules/tf029.ts": "52e02b4921a64f3f928836896b8b80682400adb50bd7a0645f3fe2e8819433c2",
|
|
39
39
|
"skills/chant-terraform.md": "d9ca7b7c28aed0038ce775a3491150298492eed2858fd3651ed9bfca0e577ae8"
|
|
40
40
|
},
|
|
41
|
-
"composite": "
|
|
41
|
+
"composite": "5585a19e628db546da2eb237dab7f9d9d8ca8488f62a9c873f0f8809d817b917"
|
|
42
42
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* argument that takes a list or a bool.
|
|
9
9
|
*
|
|
10
10
|
* This is the one rule in the family that reads the block's SOURCE rather than
|
|
11
|
-
* its parsed body, and it has to. `@
|
|
11
|
+
* its parsed body, and it has to. `@cdktn/hcl2json` renders both `x = var.y`
|
|
12
12
|
* and `x = "${var.y}"` as the string `"${var.y}"`, so a check over the parse
|
|
13
13
|
* cannot tell the deprecated form from the idiomatic one and would report every
|
|
14
14
|
* reference in the root. The quotes only survive in the text, so the text is
|
package/dist/manifest.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* time and is dependency-light on purpose, since it shells out to the
|
|
10
10
|
* configured binary and never touches the lexicon's HCL parse or serializer,
|
|
11
11
|
* so it never pulls in
|
|
12
|
-
* the ~1.8 MB `@
|
|
12
|
+
* the ~1.8 MB `@cdktn/hcl2json` wasm parser just to decide whether an apply
|
|
13
13
|
* should run `apply -auto-approve` with no plan file. Plain text and a
|
|
14
14
|
* hand-rolled brace counter are enough for that narrower question, and the
|
|
15
15
|
* literal sidecar filename below is kept in sync with `LIVE_SIDECAR_FILENAME`
|
|
@@ -673,6 +673,44 @@ export declare function terraformShow(args: TerraformShowArgs, signal?: AbortSig
|
|
|
673
673
|
* in `JSON.parse` with the real text in the error.
|
|
674
674
|
*/
|
|
675
675
|
export declare function liveDocumentFrom(stdout: string): string;
|
|
676
|
+
/**
|
|
677
|
+
* What {@link choudoufuLivePlanDocument} resolves: the document and the facts
|
|
678
|
+
* around it, and none of the human render. The subset of
|
|
679
|
+
* {@link ChoudoufuLivePlanResult} a reader of the document needs.
|
|
680
|
+
*/
|
|
681
|
+
export interface ChoudoufuLivePlanDocumentResult extends LivePlanUnownedCounts {
|
|
682
|
+
/** `true` when `-detailed-exitcode` reported exit 2: the live plan proposes changes. */
|
|
683
|
+
drift: boolean;
|
|
684
|
+
/** GitHub issue #788's JSON document, captured whole. */
|
|
685
|
+
json: unknown;
|
|
686
|
+
/** Absolute path of the root module directory. */
|
|
687
|
+
dir: string;
|
|
688
|
+
/** Where the JSON document was written, relative to `dir`. */
|
|
689
|
+
documentPath: string;
|
|
690
|
+
/** The estate this plan ran against. */
|
|
691
|
+
estate: string;
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* `live-plan -detailed-exitcode -json` alone: the document, without the
|
|
695
|
+
* second run that renders the plan for a human (chant #2498).
|
|
696
|
+
*
|
|
697
|
+
* Two of {@link choudoufuLivePlan}'s three callers never read `text`:
|
|
698
|
+
* `describeResources()` indexes the document and `predictBehaviour()` prices
|
|
699
|
+
* it. Each was paying for the render anyway, and on a drifted estate whose
|
|
700
|
+
* provider retries a deleted resource the render costs as much as the
|
|
701
|
+
* document. This is the read they make instead.
|
|
702
|
+
*
|
|
703
|
+
* Inside a `withLiveReadSession` scope (core's `live-read-session.ts`) the
|
|
704
|
+
* run is shared with every identical read in the same command, keyed on
|
|
705
|
+
* the root, its resolved directory, the binary, the estate, the flags and
|
|
706
|
+
* the root's environment. The graph command runs in such a scope, so its
|
|
707
|
+
* observation and its prediction see one `live-plan` between them, and the
|
|
708
|
+
* graph's statuses and the prediction's figures are statements about the
|
|
709
|
+
* same read. The document file is still written on every call.
|
|
710
|
+
*/
|
|
711
|
+
export declare function choudoufuLivePlanDocument(args: ChoudoufuLivePlanArgs & {
|
|
712
|
+
documentPath?: string;
|
|
713
|
+
}, signal?: AbortSignal): Promise<ChoudoufuLivePlanDocumentResult>;
|
|
676
714
|
export declare function choudoufuLivePlan(args: ChoudoufuLivePlanArgs & {
|
|
677
715
|
documentPath?: string;
|
|
678
716
|
}, signal?: AbortSignal): Promise<ChoudoufuLivePlanResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terraform.d.ts","sourceRoot":"","sources":["../../../src/op/activities/terraform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;
|
|
1
|
+
{"version":3,"file":"terraform.d.ts","sourceRoot":"","sources":["../../../src/op/activities/terraform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AASH,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEzE,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,aAAa,CAAC;AAWrB,wEAAwE;AACxE,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAEhD,wEAAwE;AACxE,eAAO,MAAM,wBAAwB,cAAc,CAAC;AAEpD,gHAAgH;AAChH,eAAO,MAAM,+BAA+B,yBAAyB,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAE9C;;;;;;;;GAQG;AACH,eAAO,MAAM,+BAA+B,mEACsB,CAAC;AAEnE,mHAAmH;AACnH,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAE9C,wGAAwG;AACxG,eAAO,MAAM,mCAAmC,wDAAwD,CAAC;AAEzG,0GAA0G;AAC1G,eAAO,MAAM,8BAA8B,oDAAoD,CAAC;AAIhG,8EAA8E;AAC9E,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC1D,8EAA8E;IAC9E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8EAA8E;IA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BAAsB,EAC5B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,wBAAwB,CAAC,CAuBnC"}
|
package/dist/rules/tf016.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* argument that takes a list or a bool.
|
|
9
9
|
*
|
|
10
10
|
* This is the one rule in the family that reads the block's SOURCE rather than
|
|
11
|
-
* its parsed body, and it has to. `@
|
|
11
|
+
* its parsed body, and it has to. `@cdktn/hcl2json` renders both `x = var.y`
|
|
12
12
|
* and `x = "${var.y}"` as the string `"${var.y}"`, so a check over the parse
|
|
13
13
|
* cannot tell the deprecated form from the idiomatic one and would report every
|
|
14
14
|
* reference in the root. The quotes only survive in the text, so the text is
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/chant-lexicon-terraform",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.78.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"src/",
|
|
@@ -45,19 +45,19 @@
|
|
|
45
45
|
"bundle": "tsx src/package-cli.ts"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
+
"@cdktn/hcl2json": "^0.24.0",
|
|
48
49
|
"@intentius/chant": "*",
|
|
49
50
|
"tsc-alias": "^1.8.17",
|
|
50
51
|
"typescript": "^5.9.3",
|
|
51
|
-
"@cdktf/hcl2json": "^0.21.0",
|
|
52
52
|
"zod": "^4.3.6"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
58
|
+
"@intentius/chant": "^0.78.0",
|
|
59
|
+
"typescript": "^5.9.3",
|
|
60
|
+
"zod": "^4.3.6"
|
|
61
61
|
},
|
|
62
62
|
"description": "terraform lexicon for chant, existing Terraform root modules as declarable entities",
|
|
63
63
|
"license": "Apache-2.0",
|
package/src/behaviour/kinds.ts
CHANGED
|
@@ -140,7 +140,12 @@ const BLOCKS: Readonly<Record<string, string>> = {
|
|
|
140
140
|
"Terraform::Live": "choudoufu's estate declaration, which names the ownership marker every resource of the root carries and holds nothing itself",
|
|
141
141
|
};
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
/**
|
|
144
|
+
* Provider prefixes that are a substrate boundary rather than a missing row,
|
|
145
|
+
* each named as the substrate. Exported so the coverage page (#2404) can list
|
|
146
|
+
* them from the same table `notModelledWhen` reads.
|
|
147
|
+
*/
|
|
148
|
+
export const UNMODELLED_TERRAFORM_PROVIDERS: ReadonlyArray<{ prefix: string; substrate: string }> = [
|
|
144
149
|
{ prefix: "google_", substrate: "Google Cloud (the google terraform provider)" },
|
|
145
150
|
{ prefix: "google-beta_", substrate: "Google Cloud (the google-beta terraform provider)" },
|
|
146
151
|
{ prefix: "azurerm_", substrate: "Azure (the azurerm terraform provider)" },
|
package/src/behaviour/predict.ts
CHANGED
|
@@ -65,7 +65,7 @@ import type { EntityReference } from "@intentius/chant/graph-ir";
|
|
|
65
65
|
import { indexLivePlan, readLiveLs, type TerraformReadDeps } from "../describe-resources";
|
|
66
66
|
import type { TerraformConfig } from "../config";
|
|
67
67
|
import { RESOURCE_TYPE } from "../hcl/parse";
|
|
68
|
-
import { choudoufuLiveLs,
|
|
68
|
+
import { choudoufuLiveLs, choudoufuLivePlanDocument } from "../op/activities/terraform";
|
|
69
69
|
import { terraformBehaviourKinds } from "./kinds";
|
|
70
70
|
import {
|
|
71
71
|
terraformBehaviourRequest,
|
|
@@ -141,7 +141,7 @@ export interface TerraformPredictOptions
|
|
|
141
141
|
*/
|
|
142
142
|
const REAL_DEPS: TerraformBehaviourDeps = {
|
|
143
143
|
liveLs: choudoufuLiveLs,
|
|
144
|
-
livePlan:
|
|
144
|
+
livePlan: choudoufuLivePlanDocument,
|
|
145
145
|
predict: createBehaviourPredict({ kinds: [terraformBehaviourKinds] }),
|
|
146
146
|
};
|
|
147
147
|
|
|
@@ -173,7 +173,7 @@ import {
|
|
|
173
173
|
import type { OwnershipMarker } from "@intentius/chant/ownership";
|
|
174
174
|
import {
|
|
175
175
|
choudoufuLiveLs,
|
|
176
|
-
|
|
176
|
+
choudoufuLivePlanDocument,
|
|
177
177
|
terraformInit,
|
|
178
178
|
terraformShow,
|
|
179
179
|
} from "./op/activities/terraform";
|
|
@@ -1007,14 +1007,15 @@ async function liveRoots(options: LiveEstateOptions): Promise<Array<{ root: stri
|
|
|
1007
1007
|
export interface TerraformReadDeps {
|
|
1008
1008
|
init: typeof terraformInit;
|
|
1009
1009
|
show: typeof terraformShow;
|
|
1010
|
-
|
|
1010
|
+
/** The document alone (chant #2498): this reader indexes it and never reads the human render. */
|
|
1011
|
+
livePlan: typeof choudoufuLivePlanDocument;
|
|
1011
1012
|
liveLs: typeof choudoufuLiveLs;
|
|
1012
1013
|
}
|
|
1013
1014
|
|
|
1014
1015
|
const REAL_DEPS: TerraformReadDeps = {
|
|
1015
1016
|
init: terraformInit,
|
|
1016
1017
|
show: terraformShow,
|
|
1017
|
-
livePlan:
|
|
1018
|
+
livePlan: choudoufuLivePlanDocument,
|
|
1018
1019
|
liveLs: choudoufuLiveLs,
|
|
1019
1020
|
};
|
|
1020
1021
|
|
package/src/hcl/descend.ts
CHANGED
|
@@ -100,7 +100,7 @@ export interface DescendOptions {
|
|
|
100
100
|
projectRoot: string;
|
|
101
101
|
/** Resolved mode. `"none"` returns immediately with nothing. */
|
|
102
102
|
callModuleType?: "local" | "none";
|
|
103
|
-
/** Injectable parser (tests); defaults to core's lazy-loaded `@
|
|
103
|
+
/** Injectable parser (tests); defaults to core's lazy-loaded `@cdktn/hcl2json`. */
|
|
104
104
|
hcl2json?: Hcl2Json;
|
|
105
105
|
/** Mode facts stamped onto the child's entities, exactly as on the root's. */
|
|
106
106
|
modeOptions?: TerraformRootModeOptions;
|
package/src/hcl/parse.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Both funnel through `blocksToEntities`, so an entity the audit path sees is
|
|
10
10
|
* the entity the build path sees.
|
|
11
11
|
*
|
|
12
|
-
* Core owns the parser glue: `loadHcl2json()` lazy-loads `@
|
|
12
|
+
* Core owns the parser glue: `loadHcl2json()` lazy-loads `@cdktn/hcl2json`
|
|
13
13
|
* (a ~1.8 MB wasm blob) and raises a one-line install hint when it is absent.
|
|
14
14
|
* `parseTerraformDir()` next to it is NOT reused: it returns carve's `TfGraph`,
|
|
15
15
|
* a scoring-and-excision shape with no room for the per-block bodies a
|
|
@@ -27,7 +27,7 @@ import type { SuppressionDirective } from "@intentius/chant/lint/suppressions";
|
|
|
27
27
|
import type { TerraformDeleteMode } from "../config";
|
|
28
28
|
import { scanSuppressions, directivesFor, type FileScan } from "./suppressions";
|
|
29
29
|
|
|
30
|
-
/** A parsed HCL block body, as `@
|
|
30
|
+
/** A parsed HCL block body, as `@cdktn/hcl2json` encodes it. */
|
|
31
31
|
export type BlockBody = Record<string, unknown>;
|
|
32
32
|
|
|
33
33
|
/**
|
package/src/hcl/roots.ts
CHANGED
|
@@ -56,7 +56,7 @@ export interface RenderTerraformRootsOptions {
|
|
|
56
56
|
* `../` is parsed as a child scope of the root that calls it.
|
|
57
57
|
*/
|
|
58
58
|
callModuleType?: CallModuleType;
|
|
59
|
-
/** Injectable parser (tests); defaults to core's lazy-loaded `@
|
|
59
|
+
/** Injectable parser (tests); defaults to core's lazy-loaded `@cdktn/hcl2json`. */
|
|
60
60
|
hcl2json?: Hcl2Json;
|
|
61
61
|
}
|
|
62
62
|
|
package/src/hcl/suppressions.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* `hcl2json` drops comments entirely, and a probe of its output confirmed it
|
|
5
5
|
* exposes no source ranges either, so a suppression comment has nothing to
|
|
6
|
-
* attach to once a file goes through `@
|
|
6
|
+
* attach to once a file goes through `@cdktn/hcl2json`. This module runs a
|
|
7
7
|
* second, cheap pass over the SAME raw text `./parse.ts` hands the parser,
|
|
8
8
|
* entirely with line-oriented regexes: a brace-depth counter to find each
|
|
9
9
|
* top-level block's start line (`terraform`, `locals`, `provider "x"`,
|
package/src/hcl/value.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* A value envelope over a parsed block body (chant #2113).
|
|
3
3
|
*
|
|
4
4
|
* Every TF post-synth check reads `BlockBody` (`./parse.ts`), raw
|
|
5
|
-
* `@
|
|
5
|
+
* `@cdktn/hcl2json` output, and re-derives, by hand, whether an attribute is
|
|
6
6
|
* a plain literal, a reference/expression, or absent. tflint's OPA ruleset
|
|
7
7
|
* hands a policy `{value, unknown, sensitive, ephemeral, range}` per
|
|
8
8
|
* attribute so a check reads that uniformly instead of re-deriving it
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* argument that takes a list or a bool.
|
|
9
9
|
*
|
|
10
10
|
* This is the one rule in the family that reads the block's SOURCE rather than
|
|
11
|
-
* its parsed body, and it has to. `@
|
|
11
|
+
* its parsed body, and it has to. `@cdktn/hcl2json` renders both `x = var.y`
|
|
12
12
|
* and `x = "${var.y}"` as the string `"${var.y}"`, so a check over the parse
|
|
13
13
|
* cannot tell the deprecated form from the idiomatic one and would report every
|
|
14
14
|
* reference in the root. The quotes only survive in the text, so the text is
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* time and is dependency-light on purpose, since it shells out to the
|
|
10
10
|
* configured binary and never touches the lexicon's HCL parse or serializer,
|
|
11
11
|
* so it never pulls in
|
|
12
|
-
* the ~1.8 MB `@
|
|
12
|
+
* the ~1.8 MB `@cdktn/hcl2json` wasm parser just to decide whether an apply
|
|
13
13
|
* should run `apply -auto-approve` with no plan file. Plain text and a
|
|
14
14
|
* hand-rolled brace counter are enough for that narrower question, and the
|
|
15
15
|
* literal sidecar filename below is kept in sync with `LIVE_SIDECAR_FILENAME`
|
|
@@ -23,6 +23,8 @@ import {
|
|
|
23
23
|
terraformApply,
|
|
24
24
|
terraformShow,
|
|
25
25
|
choudoufuLivePlan,
|
|
26
|
+
choudoufuLivePlanDocument,
|
|
27
|
+
choudoufuLiveLs,
|
|
26
28
|
terraformInitCommand,
|
|
27
29
|
terraformPlanCommand,
|
|
28
30
|
terraformApplyCommand,
|
|
@@ -36,6 +38,7 @@ import {
|
|
|
36
38
|
DEFAULT_PLAN_FILE,
|
|
37
39
|
__resetChoudoufuVersionCheckForTests,
|
|
38
40
|
} from "./terraform";
|
|
41
|
+
import { withLiveReadSession } from "@intentius/chant/live-read-session";
|
|
39
42
|
|
|
40
43
|
// ── The child-process stub ──────────────────────────────────────────────────
|
|
41
44
|
|
|
@@ -601,3 +604,117 @@ describe("every activity forwards the AbortSignal (#2086)", () => {
|
|
|
601
604
|
});
|
|
602
605
|
}
|
|
603
606
|
});
|
|
607
|
+
|
|
608
|
+
describe("one command, one read of the account (chant#2498)", () => {
|
|
609
|
+
const LIVE_PLAN_DOCUMENT = JSON.stringify({ estate: "one-read", bound: [], omissions: [], unowned: [] });
|
|
610
|
+
const LIVE_LS = JSON.stringify({ estate: "one-read", resources: [] });
|
|
611
|
+
|
|
612
|
+
function liveProject(): string {
|
|
613
|
+
const dir = project({ binary: "choudoufu", roots: { estate: { dir: "./infra" } } });
|
|
614
|
+
writeFileSync(join(dir, "infra", "estate.chdf.hcl"), 'estate = "one-read"\n');
|
|
615
|
+
return dir;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
const runs = (fragment: string): number => execCalls.filter((c) => c.cmd.includes(fragment)).length;
|
|
619
|
+
|
|
620
|
+
beforeEach(() => {
|
|
621
|
+
__resetChoudoufuVersionCheckForTests();
|
|
622
|
+
replies.push(
|
|
623
|
+
{ match: "choudoufu version", reply: { stdout: "choudoufu v0.15.0 (based on OpenTofu v1.13.0)\non darwin_arm64", stderr: "" } },
|
|
624
|
+
{ match: "live-plan -detailed-exitcode -json", reply: { stdout: LIVE_PLAN_DOCUMENT, stderr: "" } },
|
|
625
|
+
{ match: "-no-color", reply: { stdout: "No changes.\n\nPlan: 0 to add, 0 to change, 0 to destroy.\n", stderr: "" } },
|
|
626
|
+
{ match: "live-ls", reply: { stdout: LIVE_LS, stderr: "" } },
|
|
627
|
+
);
|
|
628
|
+
vi.spyOn(console, "error").mockImplementation(() => undefined);
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
test("the document alone is one run, with no human render", async () => {
|
|
632
|
+
const dir = liveProject();
|
|
633
|
+
const result = await choudoufuLivePlanDocument({ root: "estate", cwd: dir });
|
|
634
|
+
expect(result.estate).toBe("one-read");
|
|
635
|
+
expect(result.drift).toBe(false);
|
|
636
|
+
expect(result.json).toEqual(JSON.parse(LIVE_PLAN_DOCUMENT));
|
|
637
|
+
expect(runs("live-plan -detailed-exitcode -json")).toBe(1);
|
|
638
|
+
expect(runs("-no-color")).toBe(0);
|
|
639
|
+
expect("text" in result).toBe(false);
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
test("the full activity still makes the two runs, the second for the render", async () => {
|
|
643
|
+
const dir = liveProject();
|
|
644
|
+
const result = await choudoufuLivePlan({ root: "estate", cwd: dir });
|
|
645
|
+
expect(result.text).toContain("No changes.");
|
|
646
|
+
expect(runs("live-plan -detailed-exitcode -json")).toBe(1);
|
|
647
|
+
expect(runs("live-plan -detailed-exitcode -no-color")).toBe(1);
|
|
648
|
+
});
|
|
649
|
+
|
|
650
|
+
test("outside a read session, every call reads", async () => {
|
|
651
|
+
const dir = liveProject();
|
|
652
|
+
await choudoufuLivePlanDocument({ root: "estate", cwd: dir });
|
|
653
|
+
await choudoufuLivePlanDocument({ root: "estate", cwd: dir });
|
|
654
|
+
await choudoufuLiveLs({ root: "estate", cwd: dir, consistent: true });
|
|
655
|
+
await choudoufuLiveLs({ root: "estate", cwd: dir, consistent: true });
|
|
656
|
+
expect(runs("live-plan -detailed-exitcode -json")).toBe(2);
|
|
657
|
+
expect(runs("live-ls")).toBe(2);
|
|
658
|
+
});
|
|
659
|
+
|
|
660
|
+
test("inside one session, the observation's read and the prediction's read are one live-plan and one live-ls", async () => {
|
|
661
|
+
const dir = liveProject();
|
|
662
|
+
await withLiveReadSession(async () => {
|
|
663
|
+
// What describeResources() does, then what predictBehaviour() does,
|
|
664
|
+
// then the full activity a finding mode would run on top.
|
|
665
|
+
const observed = await choudoufuLivePlanDocument({ root: "estate", cwd: dir });
|
|
666
|
+
const listed = await choudoufuLiveLs({ root: "estate", cwd: dir, consistent: true });
|
|
667
|
+
const predicted = await choudoufuLivePlanDocument({ root: "estate", cwd: dir });
|
|
668
|
+
const listedAgain = await choudoufuLiveLs({ root: "estate", cwd: dir, consistent: true });
|
|
669
|
+
const rendered = await choudoufuLivePlan({ root: "estate", cwd: dir });
|
|
670
|
+
expect(predicted.json).toEqual(observed.json);
|
|
671
|
+
expect(listedAgain.json).toEqual(listed.json);
|
|
672
|
+
expect(rendered.json).toEqual(observed.json);
|
|
673
|
+
});
|
|
674
|
+
expect(runs("live-plan -detailed-exitcode -json")).toBe(1);
|
|
675
|
+
expect(runs("live-plan -detailed-exitcode -no-color")).toBe(1);
|
|
676
|
+
expect(runs("live-ls")).toBe(1);
|
|
677
|
+
});
|
|
678
|
+
|
|
679
|
+
test("a different flag is a different read", async () => {
|
|
680
|
+
const dir = liveProject();
|
|
681
|
+
await withLiveReadSession(async () => {
|
|
682
|
+
await choudoufuLivePlanDocument({ root: "estate", cwd: dir });
|
|
683
|
+
await choudoufuLivePlanDocument({ root: "estate", cwd: dir, adoptionOnly: true });
|
|
684
|
+
await choudoufuLiveLs({ root: "estate", cwd: dir, consistent: true });
|
|
685
|
+
await choudoufuLiveLs({ root: "estate", cwd: dir });
|
|
686
|
+
});
|
|
687
|
+
expect(runs("live-plan -detailed-exitcode -json")).toBe(2);
|
|
688
|
+
expect(runs("live-ls -estate=one-read -json -consistent")).toBe(1);
|
|
689
|
+
expect(runs("live-ls")).toBe(2);
|
|
690
|
+
const adoption = execCalls.filter((c) => c.opts.env?.TOFU_LIVE_COLLECT_UNCLAIMED === "1");
|
|
691
|
+
expect(adoption.length).toBe(1);
|
|
692
|
+
});
|
|
693
|
+
|
|
694
|
+
test("a read that failed is not shared: the next caller reads again", async () => {
|
|
695
|
+
const dir = liveProject();
|
|
696
|
+
replies.unshift({ match: "live-plan -detailed-exitcode -json", reply: execError(1, "no credentials") });
|
|
697
|
+
await withLiveReadSession(async () => {
|
|
698
|
+
await expect(choudoufuLivePlanDocument({ root: "estate", cwd: dir })).rejects.toThrow("no credentials");
|
|
699
|
+
replies.shift();
|
|
700
|
+
const result = await choudoufuLivePlanDocument({ root: "estate", cwd: dir });
|
|
701
|
+
expect(result.json).toEqual(JSON.parse(LIVE_PLAN_DOCUMENT));
|
|
702
|
+
});
|
|
703
|
+
expect(runs("live-plan -detailed-exitcode -json")).toBe(2);
|
|
704
|
+
});
|
|
705
|
+
|
|
706
|
+
test("drift on the shared read is the same drift for every caller", async () => {
|
|
707
|
+
const dir = liveProject();
|
|
708
|
+
replies.unshift({
|
|
709
|
+
match: "live-plan -detailed-exitcode -json",
|
|
710
|
+
reply: execError(2, "", LIVE_PLAN_DOCUMENT),
|
|
711
|
+
});
|
|
712
|
+
await withLiveReadSession(async () => {
|
|
713
|
+
const first = await choudoufuLivePlanDocument({ root: "estate", cwd: dir });
|
|
714
|
+
const second = await choudoufuLivePlanDocument({ root: "estate", cwd: dir });
|
|
715
|
+
expect(first.drift).toBe(true);
|
|
716
|
+
expect(second.drift).toBe(true);
|
|
717
|
+
});
|
|
718
|
+
expect(runs("live-plan -detailed-exitcode -json")).toBe(1);
|
|
719
|
+
});
|
|
720
|
+
});
|
|
@@ -44,6 +44,7 @@ import { writeFileSync } from "node:fs";
|
|
|
44
44
|
import { promisify } from "node:util";
|
|
45
45
|
import { resolve, dirname, join } from "node:path";
|
|
46
46
|
import { loadChantConfigUpward } from "@intentius/chant/config";
|
|
47
|
+
import { liveReadKey, memoLiveRead } from "@intentius/chant/live-read-session";
|
|
47
48
|
import { computePlanDigest } from "@intentius/chant/op";
|
|
48
49
|
import type { TerraformConfig, TerraformRootConfig } from "../../config";
|
|
49
50
|
import { detectLiveEstate } from "./live-detect";
|
|
@@ -1173,10 +1174,46 @@ export function liveDocumentFrom(stdout: string): string {
|
|
|
1173
1174
|
return start === -1 ? stdout : lines.slice(start).join("\n");
|
|
1174
1175
|
}
|
|
1175
1176
|
|
|
1176
|
-
|
|
1177
|
+
/**
|
|
1178
|
+
* What {@link choudoufuLivePlanDocument} resolves: the document and the facts
|
|
1179
|
+
* around it, and none of the human render. The subset of
|
|
1180
|
+
* {@link ChoudoufuLivePlanResult} a reader of the document needs.
|
|
1181
|
+
*/
|
|
1182
|
+
export interface ChoudoufuLivePlanDocumentResult extends LivePlanUnownedCounts {
|
|
1183
|
+
/** `true` when `-detailed-exitcode` reported exit 2: the live plan proposes changes. */
|
|
1184
|
+
drift: boolean;
|
|
1185
|
+
/** GitHub issue #788's JSON document, captured whole. */
|
|
1186
|
+
json: unknown;
|
|
1187
|
+
/** Absolute path of the root module directory. */
|
|
1188
|
+
dir: string;
|
|
1189
|
+
/** Where the JSON document was written, relative to `dir`. */
|
|
1190
|
+
documentPath: string;
|
|
1191
|
+
/** The estate this plan ran against. */
|
|
1192
|
+
estate: string;
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
/**
|
|
1196
|
+
* `live-plan -detailed-exitcode -json` alone: the document, without the
|
|
1197
|
+
* second run that renders the plan for a human (chant #2498).
|
|
1198
|
+
*
|
|
1199
|
+
* Two of {@link choudoufuLivePlan}'s three callers never read `text`:
|
|
1200
|
+
* `describeResources()` indexes the document and `predictBehaviour()` prices
|
|
1201
|
+
* it. Each was paying for the render anyway, and on a drifted estate whose
|
|
1202
|
+
* provider retries a deleted resource the render costs as much as the
|
|
1203
|
+
* document. This is the read they make instead.
|
|
1204
|
+
*
|
|
1205
|
+
* Inside a `withLiveReadSession` scope (core's `live-read-session.ts`) the
|
|
1206
|
+
* run is shared with every identical read in the same command, keyed on
|
|
1207
|
+
* the root, its resolved directory, the binary, the estate, the flags and
|
|
1208
|
+
* the root's environment. The graph command runs in such a scope, so its
|
|
1209
|
+
* observation and its prediction see one `live-plan` between them, and the
|
|
1210
|
+
* graph's statuses and the prediction's figures are statements about the
|
|
1211
|
+
* same read. The document file is still written on every call.
|
|
1212
|
+
*/
|
|
1213
|
+
export async function choudoufuLivePlanDocument(
|
|
1177
1214
|
args: ChoudoufuLivePlanArgs & { documentPath?: string },
|
|
1178
1215
|
signal?: AbortSignal,
|
|
1179
|
-
): Promise<
|
|
1216
|
+
): Promise<ChoudoufuLivePlanDocumentResult> {
|
|
1180
1217
|
const resolved = await resolveRoot(args, signal);
|
|
1181
1218
|
const { binary, dir } = resolved;
|
|
1182
1219
|
const estate = resolveEstate(args, resolved, "choudoufuLivePlan");
|
|
@@ -1187,8 +1224,6 @@ export async function choudoufuLivePlan(
|
|
|
1187
1224
|
// from the declaration itself. See {@link choudoufuLivePlanCommand}.
|
|
1188
1225
|
const estateFlag: { estate?: string } = resolved.estate === undefined ? { estate } : {};
|
|
1189
1226
|
|
|
1190
|
-
let drift: boolean;
|
|
1191
|
-
let jsonStdout: string;
|
|
1192
1227
|
const planCmd = choudoufuLivePlanCommand({ binary, ...estateFlag, json: true });
|
|
1193
1228
|
// The document's `adoptable` and `swept` sections are populated only on a
|
|
1194
1229
|
// run that asked the estate-wide sweep the account-bounded question, which
|
|
@@ -1198,30 +1233,47 @@ export async function choudoufuLivePlan(
|
|
|
1198
1233
|
// run asks for the same thing. Set only under `adoptionOnly`: the sweep is
|
|
1199
1234
|
// an account-wide list per admitted type, and an observation read has no use
|
|
1200
1235
|
// for it.
|
|
1201
|
-
const
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
const
|
|
1212
|
-
throw
|
|
1213
|
-
|
|
1214
|
-
|
|
1236
|
+
const adoptionOnly = args.adoptionOnly === true;
|
|
1237
|
+
const planEnv = adoptionOnly ? { ...env, TOFU_LIVE_COLLECT_UNCLAIMED: "1" } : env;
|
|
1238
|
+
const key = liveReadKey("live-plan", { root: args.root, dir, binary, estate, adoptionOnly, env });
|
|
1239
|
+
|
|
1240
|
+
const { drift, jsonStdout } = await memoLiveRead(key, async (): Promise<{ drift: boolean; jsonStdout: string }> => {
|
|
1241
|
+
try {
|
|
1242
|
+
const { stdout, stderr } = await run(planCmd, dir, planEnv, signal);
|
|
1243
|
+
report(stdout, stderr);
|
|
1244
|
+
return { drift: false, jsonStdout: stdout };
|
|
1245
|
+
} catch (err) {
|
|
1246
|
+
const failure = err as ExecFailure;
|
|
1247
|
+
if (typeof failure.code !== "number") throw err;
|
|
1248
|
+
if (failure.code !== 2) {
|
|
1249
|
+
const detail = (failure.stderr ?? "").trim() || (failure.stdout ?? "").trim();
|
|
1250
|
+
throw new Error(
|
|
1251
|
+
`${binary} live-plan failed in ${dir} (exit ${failure.code})${detail ? `\n${detail}` : ""}`,
|
|
1252
|
+
);
|
|
1253
|
+
}
|
|
1254
|
+
report(failure.stdout ?? "", failure.stderr ?? "");
|
|
1255
|
+
return { drift: true, jsonStdout: failure.stdout ?? "" };
|
|
1215
1256
|
}
|
|
1216
|
-
|
|
1217
|
-
drift = true;
|
|
1218
|
-
jsonStdout = failure.stdout ?? "";
|
|
1219
|
-
}
|
|
1257
|
+
});
|
|
1220
1258
|
|
|
1221
1259
|
// Belt and braces: v0.14.0 keeps `-json` stdout to the document, so this is
|
|
1222
1260
|
// the identity on a supported binary. See {@link liveDocumentFrom}.
|
|
1223
1261
|
const document = liveDocumentFrom(jsonStdout);
|
|
1224
1262
|
const json: unknown = JSON.parse(document);
|
|
1263
|
+
writeFileSync(join(dir, documentPath), document);
|
|
1264
|
+
return { drift, json, dir, documentPath, estate, ...countLivePlanUnowned(json) };
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
export async function choudoufuLivePlan(
|
|
1268
|
+
args: ChoudoufuLivePlanArgs & { documentPath?: string },
|
|
1269
|
+
signal?: AbortSignal,
|
|
1270
|
+
): Promise<ChoudoufuLivePlanResult> {
|
|
1271
|
+
const { drift, json, dir, documentPath, estate, ...unowned } = await choudoufuLivePlanDocument(args, signal);
|
|
1272
|
+
const resolved = await resolveRoot(args, signal);
|
|
1273
|
+
const { binary } = resolved;
|
|
1274
|
+
const env = terraformEnvironment(resolved.root);
|
|
1275
|
+
const estateFlag: { estate?: string } = resolved.estate === undefined ? { estate } : {};
|
|
1276
|
+
|
|
1225
1277
|
// #788's document carries no render of the human plan itself
|
|
1226
1278
|
// (`views.LivePlanDocument` has no such field), so the human text needs a
|
|
1227
1279
|
// second live read rather than a field on the same response. `-adoption-only`
|
|
@@ -1255,8 +1307,6 @@ export async function choudoufuLivePlan(
|
|
|
1255
1307
|
text = failure.stdout ?? "";
|
|
1256
1308
|
}
|
|
1257
1309
|
|
|
1258
|
-
writeFileSync(join(dir, documentPath), document);
|
|
1259
|
-
|
|
1260
1310
|
// An `adoptable[]` row carries its own tagging command in the document
|
|
1261
1311
|
// (choudoufu #962). An `unowned[]` row does not, and the render is the only
|
|
1262
1312
|
// place one is printed for it, so the parse still runs on an adoption run
|
|
@@ -1279,7 +1329,7 @@ export async function choudoufuLivePlan(
|
|
|
1279
1329
|
dir,
|
|
1280
1330
|
documentPath,
|
|
1281
1331
|
estate,
|
|
1282
|
-
...
|
|
1332
|
+
...unowned,
|
|
1283
1333
|
...parseChoudoufuPlanSummary(text),
|
|
1284
1334
|
};
|
|
1285
1335
|
}
|
|
@@ -1301,9 +1351,16 @@ export async function choudoufuLiveLs(
|
|
|
1301
1351
|
const estate = resolveEstate(args, resolved, "choudoufuLiveLs");
|
|
1302
1352
|
const env = terraformEnvironment(resolved.root);
|
|
1303
1353
|
|
|
1304
|
-
const
|
|
1305
|
-
const {
|
|
1306
|
-
|
|
1354
|
+
const consistent = args.consistent === true;
|
|
1355
|
+
const cmd = choudoufuLiveLsCommand({ binary, estate, ...(consistent ? { consistent: true } : {}) });
|
|
1356
|
+
// Shared with every identical listing in the same read session, the way
|
|
1357
|
+
// {@link choudoufuLivePlanDocument} shares the document (chant #2498).
|
|
1358
|
+
const key = liveReadKey("live-ls", { root: args.root, dir, binary, estate, consistent, env });
|
|
1359
|
+
const stdout = await memoLiveRead(key, async () => {
|
|
1360
|
+
const result = await run(cmd, dir, env, signal);
|
|
1361
|
+
report(result.stdout, result.stderr);
|
|
1362
|
+
return result.stdout;
|
|
1363
|
+
});
|
|
1307
1364
|
|
|
1308
1365
|
return { json: JSON.parse(stdout), dir, estate };
|
|
1309
1366
|
}
|