@intentius/chant-lexicon-terraform 0.124.87 → 0.124.89
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/action-ops.d.ts.map +1 -1
- package/dist/action-ops.js +3 -1
- package/dist/chant-floors.d.ts +30 -0
- package/dist/chant-floors.d.ts.map +1 -0
- package/dist/chant-floors.js +29 -0
- package/dist/components/capability-plugin.d.ts +15 -1
- package/dist/components/capability-plugin.d.ts.map +1 -1
- package/dist/components/capability-plugin.js +13 -5
- package/dist/components/compose-group.d.ts +5 -1
- package/dist/components/compose-group.d.ts.map +1 -1
- package/dist/components/compose-group.js +7 -4
- package/dist/engine-runner.d.ts +86 -0
- package/dist/engine-runner.d.ts.map +1 -0
- package/dist/engine-runner.js +134 -0
- package/dist/engine-timings.d.ts +249 -0
- package/dist/engine-timings.d.ts.map +1 -0
- package/dist/engine-timings.js +569 -0
- package/dist/integrity.json +2 -2
- package/dist/live-roots.d.ts +143 -0
- package/dist/live-roots.d.ts.map +1 -0
- package/dist/live-roots.js +304 -0
- package/dist/manifest.json +1 -1
- package/dist/migration-history.d.ts +105 -0
- package/dist/migration-history.d.ts.map +1 -0
- package/dist/migration-history.js +159 -0
- package/dist/module-catalog/index.d.ts +1 -0
- package/dist/module-catalog/index.d.ts.map +1 -1
- package/dist/module-catalog/index.js +3 -1
- package/dist/op/activities/live-detect.d.ts +15 -0
- package/dist/op/activities/live-detect.d.ts.map +1 -1
- package/dist/op/activities/live-detect.js +94 -0
- package/dist/op/activities/terraform.d.ts +1 -65
- package/dist/op/activities/terraform.d.ts.map +1 -1
- package/dist/op/activities/terraform.js +4 -54
- package/dist/op/command-hook.d.ts +98 -0
- package/dist/op/command-hook.d.ts.map +1 -0
- package/dist/op/command-hook.js +115 -0
- package/dist/registry/index.d.ts +1 -0
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/index.js +1 -0
- package/dist/state/exec.d.ts +23 -0
- package/dist/state/exec.d.ts.map +1 -1
- package/dist/state/exec.js +38 -0
- package/dist/state-ops.d.ts.map +1 -1
- package/dist/state-ops.js +3 -1
- package/dist/terragrunt/index.d.ts +3 -1
- package/dist/terragrunt/index.d.ts.map +1 -1
- package/dist/terragrunt/index.js +3 -1
- package/dist/terragrunt/place.d.ts +27 -0
- package/dist/terragrunt/place.d.ts.map +1 -0
- package/dist/terragrunt/place.js +52 -0
- package/dist/terragrunt/run.d.ts +23 -0
- package/dist/terragrunt/run.d.ts.map +1 -1
- package/dist/terragrunt/run.js +107 -3
- package/package.json +2 -2
- package/src/action-ops.ts +3 -1
- package/src/chant-floors.ts +32 -0
- package/src/components/capability-plugin.ts +27 -6
- package/src/components/compose-group.test.ts +29 -0
- package/src/components/compose-group.ts +12 -5
- package/src/components/terraform-apply-command-hook.test.ts +43 -0
- package/src/engine-runner.test.ts +261 -0
- package/src/engine-runner.ts +191 -0
- package/src/engine-timings.test.ts +203 -0
- package/src/engine-timings.ts +718 -0
- package/src/live-record-store.test.ts +76 -0
- package/src/live-roots.test.ts +80 -0
- package/src/live-roots.ts +347 -0
- package/src/migration-history.test.ts +83 -0
- package/src/migration-history.ts +199 -0
- package/src/module-catalog/index.ts +4 -1
- package/src/op/activities/live-detect.ts +87 -0
- package/src/op/activities/terraform.ts +12 -111
- package/src/op/command-hook.ts +189 -0
- package/src/registry/index.ts +1 -0
- package/src/state/engine-env.test.ts +18 -0
- package/src/state/exec.ts +38 -0
- package/src/state-ops.ts +3 -1
- package/src/terragrunt/index.ts +3 -1
- package/src/terragrunt/place.test.ts +42 -0
- package/src/terragrunt/place.ts +75 -0
- package/src/terragrunt/run.ts +128 -4
package/dist/action-ops.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-ops.d.ts","sourceRoot":"","sources":["../src/action-ops.ts"],"names":[],"mappings":"AA2CA,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,wCAAwC,CAAC;AAEzF,OAAO,EAAqB,KAAK,i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C,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qDAAqD;IACrD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,mDAAmD;IACnD,QAAQ,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACrC,gFAAgF;IAChF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;CAC9B;AAsBD,eAAO,MAAM,yBAAyB,EAAE,UAAU,CAAC,eAAe,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAyBpH,CAAC"}
|
package/dist/action-ops.js
CHANGED
|
@@ -47,6 +47,7 @@ import { terraformChangeSetPart } from "./change-set.js";
|
|
|
47
47
|
import { DEFAULT_LOCK_TIMEOUT, lockTimeoutArgs } from "./lock-timeout.js";
|
|
48
48
|
import { lastLines, runBinary } from "./state/exec.js";
|
|
49
49
|
import { gatedStateOp, StateOpError, StateOpWaitingError } from "./state-ops.js";
|
|
50
|
+
import { actorFromEnv } from "@intentius/chant/actor";
|
|
50
51
|
/** The op an action's request waits at. */
|
|
51
52
|
export const ACTION_OP = "tf-action";
|
|
52
53
|
/** The request kind of an action. */
|
|
@@ -224,7 +225,8 @@ export async function invokeAction(input) {
|
|
|
224
225
|
}
|
|
225
226
|
}
|
|
226
227
|
}
|
|
227
|
-
|
|
228
|
+
/** Who asks when the caller names nobody: core's actor fallback (#4911). */
|
|
229
|
+
const actorOf = (env) => actorFromEnv(env);
|
|
228
230
|
function stepInvoke(input) {
|
|
229
231
|
const cwd = input.cwd ?? process.cwd();
|
|
230
232
|
const commit = input.commit ?? (process.env.GITHUB_SHA || process.env.CI_COMMIT_SHA || undefined);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The chant floors of the terraform lexicon's parts (#4916): for each part a
|
|
3
|
+
* product may feature-detect on, the first chant release whose lexicon has
|
|
4
|
+
* it. Lexicons release with chant at the same version, so each is a chant
|
|
5
|
+
* version, and chant core's floor table (`@intentius/chant/floor-table`)
|
|
6
|
+
* lists them beside core's, which `chant dev dead-guards` reads.
|
|
7
|
+
*
|
|
8
|
+
* Only this file is read for the table: the `_FLOOR` constants elsewhere in
|
|
9
|
+
* the lexicon name versions of other tools (`NEXUS_HOSTED_FLOOR` in
|
|
10
|
+
* ./registry/targets/nexus.ts is a Nexus version). The entries that serve a
|
|
11
|
+
* part re-export its floor by name, so the table names those subpaths too.
|
|
12
|
+
*
|
|
13
|
+
* This file imports nothing, so an entry that must stay light (./module-catalog)
|
|
14
|
+
* can re-export from it.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* The first chant whose terraform lexicon has `moduleConsumers`, the scan of
|
|
18
|
+
* every registry module call a root makes, with `readRegistryCatalog` and
|
|
19
|
+
* `deprecatedPins` beside it on `./registry` (#4599).
|
|
20
|
+
*/
|
|
21
|
+
export declare const MODULE_CONSUMERS_FLOOR = "0.124.55";
|
|
22
|
+
/**
|
|
23
|
+
* The first chant whose terraform lexicon has `usedSources`, every module
|
|
24
|
+
* source and provider address a root uses, with `moduleSourceForms`,
|
|
25
|
+
* `providerAddressForms` and `lockedProviders` on `./registry` (#3924).
|
|
26
|
+
*/
|
|
27
|
+
export declare const USED_SOURCES_FLOOR = "0.124.55";
|
|
28
|
+
/** The first chant whose terraform lexicon has `./module-catalog`, the known-module catalog TF047 reads (#4560). */
|
|
29
|
+
export declare const MODULE_CATALOG_FLOOR = "0.124.55";
|
|
30
|
+
//# sourceMappingURL=chant-floors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chant-floors.d.ts","sourceRoot":"","sources":["../src/chant-floors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,aAAa,CAAC;AAEjD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,aAAa,CAAC;AAE7C,oHAAoH;AACpH,eAAO,MAAM,oBAAoB,aAAa,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The chant floors of the terraform lexicon's parts (#4916): for each part a
|
|
3
|
+
* product may feature-detect on, the first chant release whose lexicon has
|
|
4
|
+
* it. Lexicons release with chant at the same version, so each is a chant
|
|
5
|
+
* version, and chant core's floor table (`@intentius/chant/floor-table`)
|
|
6
|
+
* lists them beside core's, which `chant dev dead-guards` reads.
|
|
7
|
+
*
|
|
8
|
+
* Only this file is read for the table: the `_FLOOR` constants elsewhere in
|
|
9
|
+
* the lexicon name versions of other tools (`NEXUS_HOSTED_FLOOR` in
|
|
10
|
+
* ./registry/targets/nexus.ts is a Nexus version). The entries that serve a
|
|
11
|
+
* part re-export its floor by name, so the table names those subpaths too.
|
|
12
|
+
*
|
|
13
|
+
* This file imports nothing, so an entry that must stay light (./module-catalog)
|
|
14
|
+
* can re-export from it.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* The first chant whose terraform lexicon has `moduleConsumers`, the scan of
|
|
18
|
+
* every registry module call a root makes, with `readRegistryCatalog` and
|
|
19
|
+
* `deprecatedPins` beside it on `./registry` (#4599).
|
|
20
|
+
*/
|
|
21
|
+
export const MODULE_CONSUMERS_FLOOR = "0.124.55";
|
|
22
|
+
/**
|
|
23
|
+
* The first chant whose terraform lexicon has `usedSources`, every module
|
|
24
|
+
* source and provider address a root uses, with `moduleSourceForms`,
|
|
25
|
+
* `providerAddressForms` and `lockedProviders` on `./registry` (#3924).
|
|
26
|
+
*/
|
|
27
|
+
export const USED_SOURCES_FLOOR = "0.124.55";
|
|
28
|
+
/** The first chant whose terraform lexicon has `./module-catalog`, the known-module catalog TF047 reads (#4560). */
|
|
29
|
+
export const MODULE_CATALOG_FLOOR = "0.124.55";
|
|
@@ -149,6 +149,7 @@ import { type PlanShapeArtifact } from "@intentius/chant/components/covered-roun
|
|
|
149
149
|
import { type CapabilityPlugin } from "@intentius/chant/components/capability-plugin";
|
|
150
150
|
import type { EngineOutputSource, EnginePlannedOutputs } from "@intentius/chant/components/verbs/member-outputs";
|
|
151
151
|
import { type TerraformCommandHook } from "../op/activities/terraform.js";
|
|
152
|
+
import { type ComposeGroupDeps } from "./compose-group.js";
|
|
152
153
|
import { type TerraformStateRead } from "../state-reads.js";
|
|
153
154
|
/** The `terraform-apply` step's input. */
|
|
154
155
|
export interface TerraformApplyStepInput {
|
|
@@ -213,9 +214,22 @@ export interface TerraformApplyDeps {
|
|
|
213
214
|
* and `output` of each upstream its `reads` name. The hook sees the
|
|
214
215
|
* command's name, args, directory and environment, may add variables to
|
|
215
216
|
* it, and its `after` gets the exit code, duration and output. Roots a
|
|
216
|
-
* wave runs at once (chant#4864) each see their own commands.
|
|
217
|
+
* wave runs at once (chant#4864) each see their own commands. A composed
|
|
218
|
+
* group's `init`, `plan`, `show` and `apply` (`terraform.compose`) go
|
|
219
|
+
* through it too, as commands for all the group's roots: `members` names
|
|
220
|
+
* them and `root` is the first (chant#4887). `engineTimings()`
|
|
221
|
+
* (`../engine-timings.ts`) is a hook that times each root and collects the
|
|
222
|
+
* engine's spans.
|
|
217
223
|
*/
|
|
218
224
|
onCommand?: TerraformCommandHook;
|
|
225
|
+
/**
|
|
226
|
+
* The composed group's deps (`terraform.compose`), such as the project,
|
|
227
|
+
* the identities and the environment its run takes, in place of the
|
|
228
|
+
* defaults (chant#4887). A product that spread `composeGroup(...)`'s
|
|
229
|
+
* methods over this capability passes its deps here instead, so the
|
|
230
|
+
* group's commands go through `onCommand` too.
|
|
231
|
+
*/
|
|
232
|
+
compose?: ComposeGroupDeps;
|
|
219
233
|
}
|
|
220
234
|
export type { TerraformCommand, TerraformCommandHook, TerraformCommandResult, TerraformCommandRun } from "../op/activities/terraform.js";
|
|
221
235
|
/** What `terraform-apply` returns. `outputs` is what a dependent's `stackOutput()` reads. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capability-plugin.d.ts","sourceRoot":"","sources":["../../src/components/capability-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiJG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAiC,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAExH,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,2CAA2C,CAAC;AAInD,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AACzG,OAAO,KAAK,EAAmB,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,kDAAkD,CAAC;AAClI,OAAO,EAYL,KAAK,oBAAoB,EAC1B,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"capability-plugin.d.ts","sourceRoot":"","sources":["../../src/components/capability-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiJG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAiC,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAExH,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,2CAA2C,CAAC;AAInD,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AACzG,OAAO,KAAK,EAAmB,kBAAkB,EAAE,oBAAoB,EAAE,M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,wBAAgB,4BAA4B,CAAC,IAAI,GAAE,kBAAuB,GAAG,UAAU,CAAC,uBAAuB,EAAE,wBAAwB,CAAC,CAmBzI;AAgJD,wFAAwF;AACxF,eAAO,MAAM,wBAAwB,EAAE,UAAU,CAAC,uBAAuB,EAAE,wBAAwB,CAAkC,CAAC;AAEtI,eAAO,MAAM,uBAAuB;aAClC,KAAK,YAAG,iBAAiB;aAEzB,KAAK,YAAG,wBAAwB,EAAE,sBAAsB;aACxD,IAAI,YAAG,gBAAgB;aAEvB,MAAM,YAAG,kBAAkB;CACnB,CAAC;AAEX,eAAO,MAAM,yBAAyB,EAAE,gBAoBvC,CAAC"}
|
|
@@ -159,7 +159,7 @@ import { terraformDefaultLockGrain, terraformLockGrainRefusal, terraformLockRows
|
|
|
159
159
|
import { rootRowKey } from "@intentius/chant/lifecycle/lock-rows";
|
|
160
160
|
import { rootTexts } from "../compose/hcl.js";
|
|
161
161
|
import { declaredVariables } from "../compose/root.js";
|
|
162
|
-
import { terraformComposeGroup } from "./compose-group.js";
|
|
162
|
+
import { composeGroup, terraformComposeGroup } from "./compose-group.js";
|
|
163
163
|
import { markPlaceholderDriven, placeholderVars, waitingHole } from "./placeholder-preview.js";
|
|
164
164
|
import { terraformReleaseInputs } from "./release-inputs.js";
|
|
165
165
|
import { terraformTraceFacts } from "./trace-facts.js";
|
|
@@ -563,15 +563,23 @@ export function terraformApplyCapabilityWith(deps = {}) {
|
|
|
563
563
|
return cap;
|
|
564
564
|
// chant#4865: each method that runs the engine for a root runs it through the product's hook, as commands for that root.
|
|
565
565
|
const scope = (method, step) => ({ root: typeof step?.root === "string" ? step.root : "", method });
|
|
566
|
+
// chant#4887: a composed group's commands run once for all its members; the hook sees them as commands for each, `root` the first.
|
|
567
|
+
const groupScope = (method, members) => {
|
|
568
|
+
const roots = [...new Set(members.map((m) => (typeof m.step?.root === "string" ? m.step.root : "")).filter((r) => r !== ""))].sort();
|
|
569
|
+
return { root: roots[0] ?? "", members: roots, method };
|
|
570
|
+
};
|
|
566
571
|
return {
|
|
567
572
|
...cap,
|
|
568
573
|
plan: (ctx, step) => withTerraformCommandHook(hook, scope("plan", step), () => cap.plan(ctx, step)),
|
|
569
574
|
run: (ctx, step) => withTerraformCommandHook(hook, scope("run", step), () => cap.run(ctx, step)),
|
|
570
575
|
outputs: (ctx, step) => withTerraformCommandHook(hook, scope("outputs", step), () => cap.outputs(ctx, step)),
|
|
576
|
+
planGroup: (ctx, members) => withTerraformCommandHook(hook, groupScope("plan", members), () => cap.planGroup(ctx, members)),
|
|
577
|
+
runGroup: (ctx, run, members) => withTerraformCommandHook(hook, groupScope("run", members), () => cap.runGroup(ctx, run, members)),
|
|
571
578
|
};
|
|
572
579
|
}
|
|
573
580
|
/** The step's methods with `deps.resolveRoot`, before {@link terraformApplyCapabilityWith} puts its command hook around them. */
|
|
574
581
|
function terraformApplyMethods(deps) {
|
|
582
|
+
const group = deps.compose ? composeGroup(deps.compose) : terraformComposeGroup;
|
|
575
583
|
return {
|
|
576
584
|
kind: "terraform-apply",
|
|
577
585
|
// A root's apply has no undo short of applying the previous configuration,
|
|
@@ -638,11 +646,11 @@ function terraformApplyMethods(deps) {
|
|
|
638
646
|
},
|
|
639
647
|
// #4447 (ws-107): a group core forms of components that read each other plans and applies as one composed run
|
|
640
648
|
// when `terraform.compose.enabled` is set (./compose-group.ts). Delegates, so the methods are read when called.
|
|
641
|
-
groupReads: (ctx, members) =>
|
|
649
|
+
groupReads: (ctx, members) => group.groupReads(ctx, members),
|
|
642
650
|
// #4542: a member pointed at a release's recorded copy plans alone, since a composition reads the declared roots.
|
|
643
651
|
groupFallback: async (ctx, members) => members.some((m) => typeof m.step.dir === "string")
|
|
644
652
|
? { kind: "release-copy", reason: "a member deploys a release's recorded copy of its root, which a composition does not read" }
|
|
645
|
-
:
|
|
653
|
+
: group.groupFallback(ctx, members),
|
|
646
654
|
// #4542: the root's files, which a release cut records and a promote under it plans.
|
|
647
655
|
releaseInputs: (input, ctx) => terraformReleaseInputs(input, ctx),
|
|
648
656
|
// #4552: resource under choudoufu, the root under Terraform, tofu and Terragrunt, which refuse resource by name.
|
|
@@ -673,13 +681,13 @@ function terraformApplyMethods(deps) {
|
|
|
673
681
|
for (const m of members)
|
|
674
682
|
if (m.input)
|
|
675
683
|
withContextCwd(m.ctx ?? ctx, m.input);
|
|
676
|
-
return
|
|
684
|
+
return group.planGroup(ctx, members);
|
|
677
685
|
},
|
|
678
686
|
runGroup: (ctx, run, members) => {
|
|
679
687
|
for (const m of members)
|
|
680
688
|
if (m.input)
|
|
681
689
|
withContextCwd(m.ctx ?? ctx, m.input);
|
|
682
|
-
return
|
|
690
|
+
return group.runGroup(ctx, run, members);
|
|
683
691
|
},
|
|
684
692
|
async run(ctx, step) {
|
|
685
693
|
const input = await filledInput(deps.resolveRoot, ctx, step);
|
|
@@ -80,7 +80,11 @@ export interface ComposeGroupDeps {
|
|
|
80
80
|
* `declaredTargetCloudIdentity` from the project root.
|
|
81
81
|
*/
|
|
82
82
|
identity?: (projectRoot: string, env: string) => Promise<TargetCloudIdentityLookup | undefined>;
|
|
83
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* How the binary runs: `choudoufu version`, and the composed run's own
|
|
85
|
+
* commands when `runner` is not given. Default `runBinary`. Either way each
|
|
86
|
+
* run goes through the step's command hook (chant#4887).
|
|
87
|
+
*/
|
|
84
88
|
exec?: BinaryExec;
|
|
85
89
|
/** A root's outputs as its state holds them, for a member whose part of the working state could not be shown. Default `terraformOutputs`. */
|
|
86
90
|
outputs?: (root: string) => Promise<Record<string, unknown>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose-group.d.ts","sourceRoot":"","sources":["../../src/components/compose-group.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAMH,OAAO,KAAK,EACV,sBAAsB,EACtB,mBAAmB,EAEnB,YAAY,EAEZ,aAAa,EACb,WAAW,EAEX,QAAQ,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CAAC,EAAE,GAAG,iBAAiB,EAAE,CAgBtH;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,aAAa,GAAG,SAAS,CAYrG;AAuBD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,SAAS,WAAW,CAAC,SAAS,CAAC,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAWlH;AAiCD,+JAA+J;AAC/J,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,QAAQ,CAAC,SAAS,QAAQ;IAC1B,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED,+DAA+D;AAC/D,wBAAgB,YAAY,CAAC,IAAI,GAAE,gBAAqB,GAAG,mBAAmB,CAqI7E;AAED,gDAAgD;AAChD,eAAO,MAAM,qBAAqB,EAAE,mBAAoC,CAAC"}
|
|
@@ -45,6 +45,7 @@ import { declaredTargetCloudIdentity } from "@intentius/chant/workspace/ci-cloud
|
|
|
45
45
|
import { COMPOSE_STEP_KIND, composeOff, compositionIfEnabled, identityKey, rootHclReads } from "../compose.js";
|
|
46
46
|
import { terraformBinary, terraformOutputs } from "../op/activities/terraform.js";
|
|
47
47
|
import { runBinary } from "../state/exec.js";
|
|
48
|
+
import { hookedBinaryExec } from "../op/command-hook.js";
|
|
48
49
|
import { estateVersionFallback, EstateRun } from "../compose/estate.js";
|
|
49
50
|
import { ComposedRun } from "../compose/run.js";
|
|
50
51
|
import { relPath, rootTexts } from "../compose/hcl.js";
|
|
@@ -55,11 +56,12 @@ async function loadProject(cwd) {
|
|
|
55
56
|
const terraform = config.terraform;
|
|
56
57
|
return { projectRoot, terraform: { ...(terraform ?? {}), roots: terraform?.roots ?? {} } };
|
|
57
58
|
}
|
|
58
|
-
function defaultRunner(o, log) {
|
|
59
|
+
function defaultRunner(o, exec, log) {
|
|
59
60
|
if (o.composition.estate) {
|
|
60
|
-
return new EstateRun({ projectRoot: o.projectRoot, composition: o.composition, terraform: o.terraform, env: o.env, work: o.work, ...(log ? { log } : {}) });
|
|
61
|
+
return new EstateRun({ projectRoot: o.projectRoot, composition: o.composition, terraform: o.terraform, env: o.env, work: o.work, exec, ...(log ? { log } : {}) });
|
|
61
62
|
}
|
|
62
63
|
return new ComposedRun({
|
|
64
|
+
exec,
|
|
63
65
|
projectRoot: o.projectRoot,
|
|
64
66
|
composition: o.composition,
|
|
65
67
|
terraform: o.terraform,
|
|
@@ -262,7 +264,8 @@ export class ComposedPlanMovedError extends Error {
|
|
|
262
264
|
/** The group methods, with `deps` in place of the defaults. */
|
|
263
265
|
export function composeGroup(deps = {}) {
|
|
264
266
|
const project = deps.project ?? loadProject;
|
|
265
|
-
|
|
267
|
+
// chant#4887: the composed group's commands go through the step's command hook, as a plain root's do.
|
|
268
|
+
const exec = hookedBinaryExec(deps.exec ?? runBinary);
|
|
266
269
|
const envOf = () => deps.env ?? process.env;
|
|
267
270
|
const log = deps.log ?? ((line) => console.error(line));
|
|
268
271
|
const readOutputs = deps.outputs ?? ((root) => terraformOutputs({ root }));
|
|
@@ -299,7 +302,7 @@ export function composeGroup(deps = {}) {
|
|
|
299
302
|
env: envOf(),
|
|
300
303
|
work,
|
|
301
304
|
};
|
|
302
|
-
const runner = deps.runner ? deps.runner(o) : defaultRunner(o, log);
|
|
305
|
+
const runner = deps.runner ? deps.runner(o) : defaultRunner(o, exec, log);
|
|
303
306
|
try {
|
|
304
307
|
return await fn(runner);
|
|
305
308
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { type OtlpSpan, type OtlpTrace } from "@intentius/chant/otlp";
|
|
2
|
+
import { type TerraformCommand, type TerraformCommandHook } from "./op/command-hook.js";
|
|
3
|
+
import { type BinaryExec, type Ran } from "./state/exec.js";
|
|
4
|
+
import type { TerragruntExec } from "./terragrunt/run.js";
|
|
5
|
+
export { withTerraformCommandHook, asUpstreamCommands, type TerraformCommand, type TerraformCommandHook, type TerraformCommandResult, type TerraformCommandRun } from "./op/command-hook.js";
|
|
6
|
+
/** A run of the binary that blocks: `-chdir=<dir>`, `TF_IN_AUTOMATION=1`, as {@link runBinary} runs it. */
|
|
7
|
+
export type BinaryExecSync = (binary: string, args: string[], dir: string, env: NodeJS.ProcessEnv) => Ran;
|
|
8
|
+
/** What {@link engineRunner} takes. */
|
|
9
|
+
export interface EngineRunnerOptions {
|
|
10
|
+
/** The product's own token variables, left out beside chant's forge token variables (terragucci's `TG_TOKEN`, `TG_MERGE_TOKEN`). */
|
|
11
|
+
tokens?: readonly string[];
|
|
12
|
+
/** The run under `exec`, for tests. Default {@link runBinary}. */
|
|
13
|
+
exec?: BinaryExec;
|
|
14
|
+
}
|
|
15
|
+
/** The product's runners of the engine, every one with the forge's tokens left out (chant#4954). */
|
|
16
|
+
export interface EngineRunner {
|
|
17
|
+
/** The token variables left out: chant's forge token variables and the product's. */
|
|
18
|
+
readonly tokens: readonly string[];
|
|
19
|
+
/** `env` less every forge token, by name and by value ({@link engineEnv}). */
|
|
20
|
+
env(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
21
|
+
/**
|
|
22
|
+
* The binary, run without blocking. Inside `withTerraformCommandHook(hook,
|
|
23
|
+
* { root, method })` each run goes through `hook` as a command for that
|
|
24
|
+
* root, as `terraform-apply`'s own do; outside one it just runs.
|
|
25
|
+
*/
|
|
26
|
+
exec: BinaryExec;
|
|
27
|
+
/** The binary, run to its end before it returns, for a caller that cannot wait. Goes through no hook. */
|
|
28
|
+
execSync: BinaryExecSync;
|
|
29
|
+
/** Terragrunt, as `planTerragruntWave` and the other Terragrunt calls take it, with the job's environment under the call's. */
|
|
30
|
+
terragrunt: TerragruntExec;
|
|
31
|
+
/**
|
|
32
|
+
* The path of a script named as `binary` under `dir` that leaves the forge
|
|
33
|
+
* tokens `env` holds out, by name and by value, then runs `binary` with
|
|
34
|
+
* what it was given: for a step chant runs with the job's environment
|
|
35
|
+
* (`terraform-apply`'s `resolveRoot`), or a `TG_TF_PATH`. A bare name is
|
|
36
|
+
* resolved on `env.PATH` first, so the script never runs itself. One
|
|
37
|
+
* script per binary and set of variables; written once.
|
|
38
|
+
*/
|
|
39
|
+
script(dir: string, binary: string, env: NodeJS.ProcessEnv): string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The runners of the engine for a product whose own token variables are
|
|
43
|
+
* `tokens` (chant#4954). A product makes one and runs the binary and
|
|
44
|
+
* Terragrunt only through it.
|
|
45
|
+
*/
|
|
46
|
+
export declare function engineRunner(options?: EngineRunnerOptions): EngineRunner;
|
|
47
|
+
/**
|
|
48
|
+
* The variables a command run inside `span` gets (chant#4954): `TRACEPARENT`,
|
|
49
|
+
* so the engine's spans join the trace where it reads it (OpenTofu and
|
|
50
|
+
* choudoufu), the trace's and span's ids and the root as resource attributes
|
|
51
|
+
* (`<prefix>.trace_id`, `<prefix>.span_id`, `<prefix>.root`) over the
|
|
52
|
+
* `OTEL_RESOURCE_ATTRIBUTES` `env` has, so a binary that ignores
|
|
53
|
+
* `TRACEPARENT` still names the span that ran it, and `OTEL_TRACES_EXPORTER`
|
|
54
|
+
* `otlp` unless `env` chose one (`none` keeps it off). Lifted from
|
|
55
|
+
* terragucci's `binaryEnv` (telemetry.ts).
|
|
56
|
+
*/
|
|
57
|
+
export declare function commandTraceEnv(env: NodeJS.ProcessEnv, trace: OtlpTrace, span: OtlpSpan, options: {
|
|
58
|
+
prefix: string;
|
|
59
|
+
root: string;
|
|
60
|
+
}): Record<string, string>;
|
|
61
|
+
/** What {@link commandTrace} takes. */
|
|
62
|
+
export interface CommandTraceOptions {
|
|
63
|
+
/** The run's trace. */
|
|
64
|
+
trace: OtlpTrace;
|
|
65
|
+
/** The product, which names the resource attributes (`terragucci.trace_id`). */
|
|
66
|
+
prefix: string;
|
|
67
|
+
/** The span a command's span hangs under, such as the product's span for its root. Undefined, or no function, hangs it under the trace's parent. */
|
|
68
|
+
parent?: (command: TerraformCommand) => OtlpSpan | undefined;
|
|
69
|
+
/** The environment the commands run over, whose `OTEL_RESOURCE_ATTRIBUTES` and `OTEL_TRACES_EXPORTER` are kept. Default `process.env`. */
|
|
70
|
+
env?: NodeJS.ProcessEnv;
|
|
71
|
+
/** Trace an upstream's reads for a root too. Default false: they are the upstream's, not the root's. */
|
|
72
|
+
upstreams?: boolean;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* A command hook that traces each engine command (chant#4954): a span
|
|
76
|
+
* `<binary> <name>` (kind client, with `process.executable.name` and
|
|
77
|
+
* `process.command_args`) under `parent(command)`, the variables
|
|
78
|
+
* {@link commandTraceEnv} gives for it, and the span ended with
|
|
79
|
+
* `process.exit.code` once the command ends, failed unless it exited 0 (or 2
|
|
80
|
+
* for a `plan`, `-detailed-exitcode`'s changes). A command timed apart from
|
|
81
|
+
* its call (`at`, a Terragrunt unit's plan) spans the time it ran. Pass it as
|
|
82
|
+
* `engineTimings({ inner })`, so the engine's spans join the trace and reach
|
|
83
|
+
* the timings' receiver.
|
|
84
|
+
*/
|
|
85
|
+
export declare function commandTrace(options: CommandTraceOptions): TerraformCommandHook;
|
|
86
|
+
//# sourceMappingURL=engine-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine-runner.d.ts","sourceRoot":"","sources":["../src/engine-runner.ts"],"names":[],"mappings":"AAgCA,OAAO,EAAmC,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvG,OAAO,EAAoB,KAAK,gBAAgB,EAAE,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACvG,OAAO,EAA6C,KAAK,UAAU,EAAE,KAAK,GAAG,EAAE,MAAM,cAAc,CAAC;AACpG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,KAAK,gBAAgB,EA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CAAC,CAY3J;AAED,uCAAuC;AACvC,MAAM,WAAW,mBAAmB;IAClC,uBAAuB;IACvB,KAAK,EAAE,SAAS,CAAC;IACjB,gFAAgF;IAChF,MAAM,EAAE,MAAM,CAAC;IACf,oJAAoJ;IACpJ,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,QAAQ,GAAG,SAAS,CAAC;IAC7D,0IAA0I;IAC1I,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,wGAAwG;IACxG,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,oBAAoB,CAa/E"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One runner of the engine for a product (chant#4954): every way a product
|
|
3
|
+
* runs tofu, terraform, choudoufu or Terragrunt, with the forge's tokens left
|
|
4
|
+
* out of its environment ({@link engineEnv}), and the trace parent each
|
|
5
|
+
* engine command gets.
|
|
6
|
+
*
|
|
7
|
+
* - {@link engineRunner} gives the runners for one set of product token
|
|
8
|
+
* variables: `exec`, a `BinaryExec` whose runs go through the command hook
|
|
9
|
+
* of the step call they run in (`withTerraformCommandHook`, chant#4865), so
|
|
10
|
+
* a product's plan stage sends its own `init`, `plan` and `show` through
|
|
11
|
+
* the same `onCommand` as `terraform-apply`'s; `execSync`, the same run
|
|
12
|
+
* for a caller that cannot wait; `terragrunt`, a `TerragruntExec`;
|
|
13
|
+
* `script`, a same-named script that drops the tokens and runs the binary,
|
|
14
|
+
* for a step chant runs with the job's environment; and `env`.
|
|
15
|
+
* - {@link commandTrace} is a `TerraformCommandHook` that opens a span per
|
|
16
|
+
* engine command under the product's span for its root, and gives the
|
|
17
|
+
* command `TRACEPARENT` and the resource attributes that name the span
|
|
18
|
+
* ({@link commandTraceEnv}). Pass it as `engineTimings({ inner })`.
|
|
19
|
+
*
|
|
20
|
+
* A Terragrunt unit's plan reaches the same hook through
|
|
21
|
+
* `planTerragruntWave({ onCommand })` (`./terragrunt/run.ts`).
|
|
22
|
+
*
|
|
23
|
+
* Lifted from terragucci's `binary-env.ts` (`binaryEnv`, `tokenlessBinary`,
|
|
24
|
+
* `terragruntExec`), the runs of the binary in its `action.ts`, `apply.ts`,
|
|
25
|
+
* `ephemeral.ts`, `unlock.ts` and `plan.ts`, and the trace half of its
|
|
26
|
+
* `telemetry.ts` (`binaryEnv`) and `report/observe.ts` (`commandHook`).
|
|
27
|
+
*/
|
|
28
|
+
import { execFile, spawnSync } from "node:child_process";
|
|
29
|
+
import { createHash } from "node:crypto";
|
|
30
|
+
import { accessSync, constants, existsSync, mkdirSync, statSync, writeFileSync } from "node:fs";
|
|
31
|
+
import { basename, delimiter, join } from "node:path";
|
|
32
|
+
import { FORGE_TOKEN_VARS } from "@intentius/chant/ci-handover";
|
|
33
|
+
import { formatOtlpPairs, parseOtlpPairs } from "@intentius/chant/otlp";
|
|
34
|
+
import { hookedBinaryExec } from "./op/command-hook.js";
|
|
35
|
+
import { engineEnv, runBinary, tokenlessBinaryExec } from "./state/exec.js";
|
|
36
|
+
export { withTerraformCommandHook, asUpstreamCommands } from "./op/command-hook.js";
|
|
37
|
+
/** Whether `p` is a file this process may run. */
|
|
38
|
+
function runnable(p) {
|
|
39
|
+
try {
|
|
40
|
+
accessSync(p, constants.X_OK);
|
|
41
|
+
return statSync(p).isFile();
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** A word single-quoted for `sh`. */
|
|
48
|
+
const shq = (s) => `'${s.replace(/'/g, `'\\''`)}'`;
|
|
49
|
+
/**
|
|
50
|
+
* The runners of the engine for a product whose own token variables are
|
|
51
|
+
* `tokens` (chant#4954). A product makes one and runs the binary and
|
|
52
|
+
* Terragrunt only through it.
|
|
53
|
+
*/
|
|
54
|
+
export function engineRunner(options = {}) {
|
|
55
|
+
const own = [...(options.tokens ?? [])];
|
|
56
|
+
const tokens = [...new Set([...own, ...FORGE_TOKEN_VARS])];
|
|
57
|
+
const env = (e) => engineEnv(e, own);
|
|
58
|
+
// The hook's variables are laid over the run's before the tokens are taken out, so no hook puts one back.
|
|
59
|
+
const exec = hookedBinaryExec(tokenlessBinaryExec(own, options.exec ?? runBinary));
|
|
60
|
+
const execSync = (binary, args, dir, given) => {
|
|
61
|
+
const p = spawnSync(binary, [`-chdir=${dir}`, ...args], { encoding: "utf-8", env: { ...env(given), TF_IN_AUTOMATION: "1" }, maxBuffer: 512 * 1024 * 1024 });
|
|
62
|
+
const stdout = p.stdout ?? "";
|
|
63
|
+
return { code: p.error && p.status === null ? 127 : (p.status ?? 1), stdout, out: `${stdout}${p.stderr ?? ""}${p.error ? p.error.message : ""}` };
|
|
64
|
+
};
|
|
65
|
+
const terragrunt = (file, args, opts) => new Promise((done) => {
|
|
66
|
+
execFile(file, [...args], { cwd: opts.cwd, env: env({ ...process.env, ...opts.env }), maxBuffer: 256 * 1024 * 1024 }, (err, stdout, stderr) => {
|
|
67
|
+
const code = err ? (typeof err.code === "number" ? err.code : null) : 0;
|
|
68
|
+
done({ code, stdout: String(stdout), stderr: err && code === null ? `${String(stderr)}${err.message}` : String(stderr) });
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
const script = (dir, given, e) => {
|
|
72
|
+
const binary = given.includes("/") ? given : ((e.PATH ?? "").split(delimiter).map((d) => join(d, given)).find((p) => runnable(p)) ?? given);
|
|
73
|
+
const kept = env(e);
|
|
74
|
+
const drop = [...new Set([...tokens, ...Object.keys(e).filter((k) => !(k in kept))])].filter((k) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(k)).sort();
|
|
75
|
+
const at = join(dir, createHash("sha256").update(`${binary}\n${drop.join(" ")}`).digest("hex").slice(0, 16));
|
|
76
|
+
const path = join(at, basename(binary) || "terraform");
|
|
77
|
+
if (!existsSync(path)) {
|
|
78
|
+
mkdirSync(at, { recursive: true });
|
|
79
|
+
writeFileSync(path, `#!/bin/sh\nexec env ${drop.map((k) => `-u ${k}`).join(" ")} ${shq(binary)} "$@"\n`, { mode: 0o755 });
|
|
80
|
+
}
|
|
81
|
+
return path;
|
|
82
|
+
};
|
|
83
|
+
return { tokens, env, exec, execSync, terragrunt, script };
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The variables a command run inside `span` gets (chant#4954): `TRACEPARENT`,
|
|
87
|
+
* so the engine's spans join the trace where it reads it (OpenTofu and
|
|
88
|
+
* choudoufu), the trace's and span's ids and the root as resource attributes
|
|
89
|
+
* (`<prefix>.trace_id`, `<prefix>.span_id`, `<prefix>.root`) over the
|
|
90
|
+
* `OTEL_RESOURCE_ATTRIBUTES` `env` has, so a binary that ignores
|
|
91
|
+
* `TRACEPARENT` still names the span that ran it, and `OTEL_TRACES_EXPORTER`
|
|
92
|
+
* `otlp` unless `env` chose one (`none` keeps it off). Lifted from
|
|
93
|
+
* terragucci's `binaryEnv` (telemetry.ts).
|
|
94
|
+
*/
|
|
95
|
+
export function commandTraceEnv(env, trace, span, options) {
|
|
96
|
+
const resource = {
|
|
97
|
+
...parseOtlpPairs(env.OTEL_RESOURCE_ATTRIBUTES),
|
|
98
|
+
[`${options.prefix}.trace_id`]: trace.traceId,
|
|
99
|
+
[`${options.prefix}.span_id`]: span.spanId,
|
|
100
|
+
[`${options.prefix}.root`]: options.root,
|
|
101
|
+
};
|
|
102
|
+
return {
|
|
103
|
+
TRACEPARENT: trace.traceparent(span),
|
|
104
|
+
OTEL_TRACES_EXPORTER: env.OTEL_TRACES_EXPORTER || "otlp",
|
|
105
|
+
OTEL_RESOURCE_ATTRIBUTES: formatOtlpPairs(resource),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* A command hook that traces each engine command (chant#4954): a span
|
|
110
|
+
* `<binary> <name>` (kind client, with `process.executable.name` and
|
|
111
|
+
* `process.command_args`) under `parent(command)`, the variables
|
|
112
|
+
* {@link commandTraceEnv} gives for it, and the span ended with
|
|
113
|
+
* `process.exit.code` once the command ends, failed unless it exited 0 (or 2
|
|
114
|
+
* for a `plan`, `-detailed-exitcode`'s changes). A command timed apart from
|
|
115
|
+
* its call (`at`, a Terragrunt unit's plan) spans the time it ran. Pass it as
|
|
116
|
+
* `engineTimings({ inner })`, so the engine's spans join the trace and reach
|
|
117
|
+
* the timings' receiver.
|
|
118
|
+
*/
|
|
119
|
+
export function commandTrace(options) {
|
|
120
|
+
return (c) => {
|
|
121
|
+
if (c.upstream !== undefined && !options.upstreams)
|
|
122
|
+
return;
|
|
123
|
+
const span = options.trace.start(`${c.binary} ${c.name}`, options.parent?.(c), { "process.executable.name": c.binary, "process.command_args": c.args.join(" ") }, { kind: 3 });
|
|
124
|
+
return {
|
|
125
|
+
env: commandTraceEnv({ ...(options.env ?? process.env), ...c.env }, options.trace, span, { prefix: options.prefix, root: c.root }),
|
|
126
|
+
after: (r) => {
|
|
127
|
+
if (r.at)
|
|
128
|
+
span.start = BigInt(Math.round(r.at.start)) * 1000000n;
|
|
129
|
+
const ok = r.code === 0 || (c.name === "plan" && r.code === 2);
|
|
130
|
+
options.trace.end(span, { "process.exit.code": r.code ?? -1 }, ok ? undefined : `exit ${r.code}`, r.at?.end);
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
}
|