@intentius/chant-lexicon-pulumi 0.124.54 → 0.124.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -3
- package/dist/adopt.d.ts +68 -0
- package/dist/adopt.d.ts.map +1 -0
- package/dist/adopt.js +162 -0
- package/dist/capability-plugin.d.ts +3 -0
- package/dist/capability-plugin.d.ts.map +1 -1
- package/dist/capability-plugin.js +8 -1
- package/dist/change-set.d.ts +27 -4
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +15 -5
- package/dist/ci-setup.d.ts +53 -0
- package/dist/ci-setup.d.ts.map +1 -0
- package/dist/ci-setup.js +146 -0
- package/dist/composites/pulumi-adopt-op.d.ts +106 -0
- package/dist/composites/pulumi-adopt-op.d.ts.map +1 -0
- package/dist/composites/pulumi-adopt-op.js +132 -0
- package/dist/engine-events.d.ts +222 -0
- package/dist/engine-events.d.ts.map +1 -0
- package/dist/engine-events.js +280 -0
- package/dist/exit-codes.d.ts +53 -0
- package/dist/exit-codes.d.ts.map +1 -0
- package/dist/exit-codes.js +67 -0
- package/dist/index.d.ts +12 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -2
- package/dist/init-templates.d.ts.map +1 -1
- package/dist/init-templates.js +5 -3
- package/dist/integrity.json +3 -3
- package/dist/lint/post-synth/pul015.d.ts +2 -1
- package/dist/lint/post-synth/pul015.d.ts.map +1 -1
- package/dist/lock-rows.d.ts +32 -0
- package/dist/lock-rows.d.ts.map +1 -0
- package/dist/lock-rows.js +36 -0
- package/dist/manifest.json +1 -1
- package/dist/member-engine.d.ts +27 -2
- package/dist/member-engine.d.ts.map +1 -1
- package/dist/member-engine.js +58 -7
- package/dist/member-outputs.d.ts.map +1 -1
- package/dist/member-outputs.js +4 -4
- package/dist/op/activities/index.d.ts +9 -1
- package/dist/op/activities/index.d.ts.map +1 -1
- package/dist/op/activities/index.js +8 -1
- package/dist/op/activities/pulumi-adopt.d.ts +104 -0
- package/dist/op/activities/pulumi-adopt.d.ts.map +1 -0
- package/dist/op/activities/pulumi-adopt.js +216 -0
- package/dist/op/activities/pulumi.d.ts.map +1 -1
- package/dist/op/activities/pulumi.js +2 -1
- package/dist/op/activity-contracts.d.ts +73 -0
- package/dist/op/activity-contracts.d.ts.map +1 -1
- package/dist/op/activity-contracts.js +49 -0
- package/dist/op/builders.d.ts +9 -0
- package/dist/op/builders.d.ts.map +1 -1
- package/dist/op/builders.js +20 -0
- package/dist/plan-shape.d.ts +47 -0
- package/dist/plan-shape.d.ts.map +1 -0
- package/dist/plan-shape.js +94 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +25 -4
- package/dist/plunge-timings.d.ts +43 -0
- package/dist/plunge-timings.d.ts.map +1 -0
- package/dist/plunge-timings.js +106 -0
- package/dist/pulumi-up.d.ts +376 -0
- package/dist/pulumi-up.d.ts.map +1 -0
- package/dist/pulumi-up.js +823 -0
- package/dist/release-copy.d.ts +47 -0
- package/dist/release-copy.d.ts.map +1 -0
- package/dist/release-copy.js +131 -0
- package/dist/review-stack.d.ts +92 -0
- package/dist/review-stack.d.ts.map +1 -0
- package/dist/review-stack.js +222 -0
- package/dist/rules/pul015.ts +2 -1
- package/dist/run.d.ts +250 -7
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +432 -26
- package/dist/stack-export-snapshot.d.ts +125 -0
- package/dist/stack-export-snapshot.d.ts.map +1 -0
- package/dist/stack-export-snapshot.js +233 -0
- package/dist/stack-ops.d.ts +175 -0
- package/dist/stack-ops.d.ts.map +1 -0
- package/dist/stack-ops.js +400 -0
- package/dist/stack-references.d.ts +46 -0
- package/dist/stack-references.d.ts.map +1 -0
- package/dist/stack-references.js +88 -0
- package/dist/trace-facts.d.ts +34 -0
- package/dist/trace-facts.d.ts.map +1 -0
- package/dist/trace-facts.js +81 -0
- package/dist/workspace-member.d.ts +13 -2
- package/dist/workspace-member.d.ts.map +1 -1
- package/dist/workspace-member.js +14 -9
- package/package.json +2 -2
- package/src/adopt.ts +202 -0
- package/src/capability-plugin.ts +15 -6
- package/src/change-set.ts +29 -5
- package/src/ci-setup.test.ts +123 -0
- package/src/ci-setup.ts +176 -0
- package/src/composites/pulumi-adopt-op.test.ts +223 -0
- package/src/composites/pulumi-adopt-op.ts +191 -0
- package/src/composites/pulumi-watch-op.test.ts +2 -2
- package/src/engine-events.test.ts +134 -0
- package/src/engine-events.ts +390 -0
- package/src/engine-graph.test.ts +1 -1
- package/src/exit-codes.test.ts +21 -0
- package/src/exit-codes.ts +71 -0
- package/src/index.ts +75 -1
- package/src/init-templates.ts +5 -3
- package/src/lint/post-synth/pul015.ts +2 -1
- package/src/lock-rows.test.ts +60 -0
- package/src/lock-rows.ts +56 -0
- package/src/member-engine.test.ts +112 -0
- package/src/member-engine.ts +73 -6
- package/src/member-outputs.test.ts +2 -2
- package/src/member-outputs.ts +9 -8
- package/src/op/activities/index.ts +19 -1
- package/src/op/activities/pulumi-adopt.ts +334 -0
- package/src/op/activities/pulumi.ts +2 -1
- package/src/op/activity-contracts.ts +75 -0
- package/src/op/builders.ts +37 -0
- package/src/plan-shape.test.ts +91 -0
- package/src/plan-shape.ts +105 -0
- package/src/plugin.test.ts +1 -1
- package/src/plugin.ts +28 -4
- package/src/plunge-timings.test.ts +241 -0
- package/src/plunge-timings.ts +115 -0
- package/src/plunge-up-failed.test.ts +54 -0
- package/src/pr-note.test.ts +87 -0
- package/src/pulumi-up.test.ts +470 -0
- package/src/pulumi-up.ts +1032 -0
- package/src/release-copy.test.ts +74 -0
- package/src/release-copy.ts +142 -0
- package/src/review-stack.test.ts +254 -0
- package/src/review-stack.ts +266 -0
- package/src/run.test.ts +176 -3
- package/src/run.ts +501 -30
- package/src/stack-export-snapshot.test.ts +190 -0
- package/src/stack-export-snapshot.ts +312 -0
- package/src/stack-ops.test.ts +286 -0
- package/src/stack-ops.ts +552 -0
- package/src/stack-references.test.ts +96 -0
- package/src/stack-references.ts +110 -0
- package/src/testdata/pulumi-stream/README.md +16 -0
- package/src/testdata/pulumi-stream/preview-stream.ndjson +42 -0
- package/src/testdata/pulumi-stream/up-failed-plunge.ndjson +5 -0
- package/src/trace-facts.test.ts +38 -0
- package/src/trace-facts.ts +83 -0
- package/src/workspace-member.test.ts +2 -1
- package/src/workspace-member.ts +30 -12
package/dist/ci-setup.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The engine install lines a Pulumi project's pull request pipeline runs in
|
|
3
|
+
* chant's default image (#4550, `LexiconPlugin.ciSetup`): Pulumi, or plunge
|
|
4
|
+
* when the member's engine is plunge (`pulumiMemberEngine`, #4559).
|
|
5
|
+
*
|
|
6
|
+
* Each line installs one release (#4592), modelled on plywood#12's
|
|
7
|
+
* (INTENTIUS/plywood 9b24b50847, packages/plywood/src/images.ts):
|
|
8
|
+
*
|
|
9
|
+
* - it takes a version, by default {@link PULUMI_CI_VERSION} or
|
|
10
|
+
* {@link PLUNGE_CI_VERSION};
|
|
11
|
+
* - it downloads the Linux archive for the job's architecture and the
|
|
12
|
+
* release's own checksums file (Pulumi's `pulumi-<ver>-checksums.txt`,
|
|
13
|
+
* plunge's `plunge-v<ver>-checksums.txt`), and fails unless the archive's
|
|
14
|
+
* line is there and matches the archive (`sha256sum -c`);
|
|
15
|
+
* - for a release with a recorded sum ({@link PINNED_SHA256}, or the
|
|
16
|
+
* caller's `sha256`), the line must also hold that sum, so a tampered
|
|
17
|
+
* checksums file fails as a tampered archive does;
|
|
18
|
+
* - it unpacks under a versioned path, `/opt/chant/<engine>-<version>/`,
|
|
19
|
+
* with the language hosts beside the binary, and links the binary into
|
|
20
|
+
* /usr/local/bin;
|
|
21
|
+
* - it skips the download when that directory already holds the binary,
|
|
22
|
+
* and for Pulumi also when the `pulumi` on PATH is that version, so an
|
|
23
|
+
* image that carries the engine pays nothing.
|
|
24
|
+
*
|
|
25
|
+
* A product with images of its own (plywood keeps its engines under
|
|
26
|
+
* /opt/plywood) passes `root`, so the lines find what its image carries.
|
|
27
|
+
*/
|
|
28
|
+
import { pulumiMemberEngine } from "./member-engine.js";
|
|
29
|
+
/** The Pulumi release the default lines install: the plunge corpus's, which plunge 0.1.0 is built from. */
|
|
30
|
+
export const PULUMI_CI_VERSION = "3.272.0";
|
|
31
|
+
/** The plunge release the default lines install (INTENTIUS/plunge, tag plunge-v<ver>), not the Pulumi version it is built from. */
|
|
32
|
+
export const PLUNGE_CI_VERSION = "0.1.0";
|
|
33
|
+
/** Where the lines install each release by default. */
|
|
34
|
+
export const CI_ENGINE_ROOT = "/opt/chant";
|
|
35
|
+
export const CI_ARCHES = ["x64", "arm64"];
|
|
36
|
+
/**
|
|
37
|
+
* The sha256 of each recorded Linux archive, copied from its release's
|
|
38
|
+
* checksums file (the same sums plywood#12 records). A checksums file that
|
|
39
|
+
* lists another sum for one of these fails the install. Add a release's
|
|
40
|
+
* two lines when moving a default version.
|
|
41
|
+
*/
|
|
42
|
+
export const PINNED_SHA256 = {
|
|
43
|
+
"pulumi-v3.272.0-linux-x64.tar.gz": "58d545f2b98761051922008ebd381ecef95484d7f7a5ff7faa15d7a780ea84f6",
|
|
44
|
+
"pulumi-v3.272.0-linux-arm64.tar.gz": "4f0741901b8982c4326b702dabf483c63d2cf77c88ac42dd752b72541284a534",
|
|
45
|
+
"plunge-v0.1.0-linux-x64.tar.gz": "22b89da39ab7dc11268c7b625fec3d99c0793c9c47bf8d031fa94e6967ee8187",
|
|
46
|
+
"plunge-v0.1.0-linux-arm64.tar.gz": "6855611b8cf8381d73f5ddf0b5c0a0d83bdc2a5bd8c50d415e52bb05a4574f83",
|
|
47
|
+
};
|
|
48
|
+
const VERSION = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
|
|
49
|
+
const SHA256 = /^[0-9a-f]{64}$/;
|
|
50
|
+
const ROOT = /^\/[A-Za-z0-9._/-]*$/;
|
|
51
|
+
/** The release of `engine` at `version`. A version is a plain semver, so it is safe on a shell line. */
|
|
52
|
+
export function ciRelease(engine, version) {
|
|
53
|
+
if (!VERSION.test(version))
|
|
54
|
+
throw new Error(`${engine} version ${JSON.stringify(version)} is not a release version such as 3.272.0`);
|
|
55
|
+
if (engine === "pulumi") {
|
|
56
|
+
return {
|
|
57
|
+
base: `https://github.com/pulumi/pulumi/releases/download/v${version}`,
|
|
58
|
+
archive: (arch) => `pulumi-v${version}-linux-${arch}.tar.gz`,
|
|
59
|
+
checksums: `pulumi-${version}-checksums.txt`,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
base: `https://github.com/INTENTIUS/plunge/releases/download/plunge-v${version}`,
|
|
64
|
+
archive: (arch) => `plunge-v${version}-linux-${arch}.tar.gz`,
|
|
65
|
+
checksums: `plunge-v${version}-checksums.txt`,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** Where one release of one engine lives after its line runs. */
|
|
69
|
+
export function ciEngineDir(engine, version, root = CI_ENGINE_ROOT) {
|
|
70
|
+
if (!ROOT.test(root))
|
|
71
|
+
throw new Error(`an engine root is an absolute path of letters, digits and ._/-, not ${JSON.stringify(root)}`);
|
|
72
|
+
return `${root.replace(/\/+$/, "")}/${engine}-${version}`;
|
|
73
|
+
}
|
|
74
|
+
/** The recorded sums for `version`, by architecture: the caller's, else {@link PINNED_SHA256}'s. */
|
|
75
|
+
export function recordedSums(engine, version, given) {
|
|
76
|
+
const r = ciRelease(engine, version);
|
|
77
|
+
const out = {};
|
|
78
|
+
for (const arch of CI_ARCHES) {
|
|
79
|
+
const sum = given ? given[arch] : PINNED_SHA256[r.archive(arch)];
|
|
80
|
+
if (sum === undefined)
|
|
81
|
+
continue;
|
|
82
|
+
if (!SHA256.test(sum))
|
|
83
|
+
throw new Error(`the recorded sha256 for ${r.archive(arch)} is not 64 hex digits`);
|
|
84
|
+
out[arch] = sum;
|
|
85
|
+
}
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
88
|
+
/** The job's architecture as x64 or arm64. */
|
|
89
|
+
const JOB_ARCH = `"$(uname -m | sed 's/x86_64/x64/;s/aarch64/arm64/')"`;
|
|
90
|
+
/**
|
|
91
|
+
* Shell that downloads one release into `dir` and checks it against the
|
|
92
|
+
* release's checksums file and, when recorded, the sum per architecture.
|
|
93
|
+
* Both archives unpack a top directory named after the engine, which
|
|
94
|
+
* `--strip-components=1` drops.
|
|
95
|
+
*/
|
|
96
|
+
function fetchScript(engine, version, dir, sums) {
|
|
97
|
+
const r = ciRelease(engine, version);
|
|
98
|
+
const recorded = CI_ARCHES.filter((a) => sums[a]);
|
|
99
|
+
const pinCase = recorded.length > 0 ? `case "$a" in ${recorded.map((a) => `${a}) want=${sums[a]} ;;`).join(" ")} *) want= ;; esac` : "want=";
|
|
100
|
+
const file = r.archive("x64").replace("-x64.", "-$a.");
|
|
101
|
+
return [
|
|
102
|
+
`a=${JOB_ARCH}`,
|
|
103
|
+
`f="${file}"`,
|
|
104
|
+
`t="$(mktemp -d)"`,
|
|
105
|
+
`curl -fsSLo "$t/$f" "${r.base}/$f"`,
|
|
106
|
+
`curl -fsSLo "$t/sums" "${r.base}/${r.checksums}"`,
|
|
107
|
+
// The archive's line, with any ./ or * before the name taken off.
|
|
108
|
+
`line="$(sed -n "s#^\\([0-9a-f]\\{64\\}\\) *[*.]*/*$f\\$#\\1#p" "$t/sums")"`,
|
|
109
|
+
`{ [ -n "$line" ] || { echo "${engine} ${version}: $f is not in ${r.checksums}" >&2; exit 1; }; }`,
|
|
110
|
+
pinCase,
|
|
111
|
+
`{ [ -z "$want" ] || [ "$line" = "$want" ] || { echo "${engine} ${version}: ${r.checksums} lists $line for $f; chant records $want" >&2; exit 1; }; }`,
|
|
112
|
+
`echo "$line $t/$f" | sha256sum -c - >/dev/null`,
|
|
113
|
+
`mkdir -p "${dir}"`,
|
|
114
|
+
`tar -xzf "$t/$f" -C "${dir}" --strip-components=1`,
|
|
115
|
+
].join(" && ");
|
|
116
|
+
}
|
|
117
|
+
/** The line for one engine: skip when present, else fetch and check, then link into /usr/local/bin. */
|
|
118
|
+
function installLine(engine, version, options, present) {
|
|
119
|
+
const dir = ciEngineDir(engine, version, options.root);
|
|
120
|
+
const install = `(set -e; ${fetchScript(engine, version, dir, recordedSums(engine, version, options.sha256))})`;
|
|
121
|
+
const link = `ln -sf "${dir}/${engine}" /usr/local/bin/${engine}`;
|
|
122
|
+
const inDir = `[ -x "${dir}/${engine}" ]`;
|
|
123
|
+
return present ? `${present} || { { ${inDir} || ${install}; } && ${link}; }` : `{ ${inDir} || ${install}; } && ${link}`;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Pulumi at `version` under `<root>/pulumi-<version>/`, checked against the
|
|
127
|
+
* release checksums. Skips when the `pulumi` on PATH is that version.
|
|
128
|
+
*/
|
|
129
|
+
export function pulumiInstallLine(version = PULUMI_CI_VERSION, options = {}) {
|
|
130
|
+
ciRelease("pulumi", version);
|
|
131
|
+
const present = `{ command -v pulumi >/dev/null 2>&1 && [ "$(pulumi version 2>/dev/null)" = "v${version}" ]; }`;
|
|
132
|
+
return installLine("pulumi", version, options, present);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* plunge at `version` under `<root>/plunge-<version>/`, its language hosts
|
|
136
|
+
* beside it, checked against the release checksums. plunge reports the
|
|
137
|
+
* Pulumi version it is built from, not its own release, so only the
|
|
138
|
+
* versioned directory tells an installed release apart.
|
|
139
|
+
*/
|
|
140
|
+
export function plungeInstallLine(version = PLUNGE_CI_VERSION, options = {}) {
|
|
141
|
+
return installLine("plunge", version, options);
|
|
142
|
+
}
|
|
143
|
+
/** The lines for the project at `dir`. */
|
|
144
|
+
export function pulumiCiSetup(ctx) {
|
|
145
|
+
return [pulumiMemberEngine(ctx.dir).engine === "plunge" ? plungeInstallLine() : pulumiInstallLine()];
|
|
146
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PulumiAdoptOp composite (#4562): adopt stock Pulumi stacks onto plunge's
|
|
3
|
+
* per-resource records, behind a gate, the pulumi twin of the terraform
|
|
4
|
+
* lexicon's `TerraformAdoptOp`. It is the step after `plywood init --engine
|
|
5
|
+
* plunge` (INTENTIUS/plywood#3); plywood supplies the words.
|
|
6
|
+
*
|
|
7
|
+
* plunge refuses a stock checkpoint with no records (`AdoptionRequiredError`)
|
|
8
|
+
* rather than recreate everything, so a stack moves to plunge by `plunge
|
|
9
|
+
* stack adopt`. Adoption writes one record per resource with the
|
|
10
|
+
* checkpoint's IDs and calls no cloud API; the next `plunge up` adds the
|
|
11
|
+
* `plunge-stack` and `plunge-urn` tags in place.
|
|
12
|
+
*
|
|
13
|
+
* Phases:
|
|
14
|
+
*
|
|
15
|
+
* - **Check**: the shared bucket check (#4558) on each stack's backend
|
|
16
|
+
* bucket. A setting that fails, not waived, refuses the run before
|
|
17
|
+
* anything is exported, naming the fix. A `file://` backend is skipped.
|
|
18
|
+
* - **Export**: each stack's stock checkpoint, `pulumi stack export
|
|
19
|
+
* --stack <s>`, kept in a scratch file. It is the back-out copy (`pulumi
|
|
20
|
+
* stack import --file` on a stock backend), and on the route from Pulumi
|
|
21
|
+
* Cloud (`from: { backend }`) or from an export taken by hand (`from: {
|
|
22
|
+
* file }`) it is what plunge adopts with `--file`.
|
|
23
|
+
* - Then one wave per stack, in the order given: **Preview** runs `plunge
|
|
24
|
+
* stack adopt --json` (writes nothing), the **gate** binds that preview's
|
|
25
|
+
* `planDigest`, and **Adopt** runs `plunge stack adopt --json --yes`. A
|
|
26
|
+
* stack whose checkpoint changed after approval previews a new digest,
|
|
27
|
+
* and the old approval does not open the gate for it.
|
|
28
|
+
*
|
|
29
|
+
* Every gate is a fact on the workspace ledger: `chant run` records the
|
|
30
|
+
* pending gate citing the preview's digest and exits gated, `chant approve
|
|
31
|
+
* <op> <gate>` writes the resolution, and the next run walks to the Adopt
|
|
32
|
+
* step. The run itself is a run record on the same ledger (#4551), as for
|
|
33
|
+
* `TerraformAdoptOp`. There is no `gate: "never"`: adoption moves the stack's
|
|
34
|
+
* state onto another backend's records, which nobody should skip reviewing.
|
|
35
|
+
*
|
|
36
|
+
* ## Compensation
|
|
37
|
+
*
|
|
38
|
+
* Refused without a command, as `TerraformAdoptOp` refuses it. Backing out
|
|
39
|
+
* is `plunge stack export --file s.json` then `pulumi stack import --file
|
|
40
|
+
* s.json` on a stock backend, a decision about the stack and its backend
|
|
41
|
+
* rather than something chant should run on its own.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* import { PulumiAdoptOp } from "@intentius/chant-lexicon-pulumi";
|
|
46
|
+
*
|
|
47
|
+
* export const { op } = PulumiAdoptOp({
|
|
48
|
+
* name: "adopt-infra",
|
|
49
|
+
* stacks: [{ member: "infra", dir: "./infra", stack: "dev" }],
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
import { OpResource } from "@intentius/chant/op";
|
|
54
|
+
/** One stack to adopt. */
|
|
55
|
+
export interface PulumiAdoptStack {
|
|
56
|
+
/** The member's name. */
|
|
57
|
+
member: string;
|
|
58
|
+
/** The stack's directory, where `Pulumi.yaml` is, relative to the project root. */
|
|
59
|
+
dir: string;
|
|
60
|
+
/** The stack to adopt. */
|
|
61
|
+
stack: string;
|
|
62
|
+
/** The plunge backend URL (`plunge+s3://...`). Default: `plywood.yml`'s, `PULUMI_BACKEND_URL`, `Pulumi.yaml`'s. */
|
|
63
|
+
backend?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Where the checkpoint comes from, when it is not the stock stack at the
|
|
66
|
+
* same root: `backend`, another backend to export from (Pulumi Cloud), or
|
|
67
|
+
* `file`, an export already taken. Either way plunge adopts it with
|
|
68
|
+
* `--file`.
|
|
69
|
+
*/
|
|
70
|
+
from?: {
|
|
71
|
+
backend: string;
|
|
72
|
+
} | {
|
|
73
|
+
file: string;
|
|
74
|
+
};
|
|
75
|
+
/** The bucket to check, as `@intentius/chant/bucket-check` takes it, when the URL does not name it fully (azblob). */
|
|
76
|
+
bucket?: Record<string, unknown>;
|
|
77
|
+
/** Key prefixes a lifecycle rule must cover. Default: the backend URL's path. */
|
|
78
|
+
namespaces?: string[];
|
|
79
|
+
/** Bucket settings waived, as plunge's `allow_insecure`. An unwaivable one stays refused. */
|
|
80
|
+
allowInsecure?: string[];
|
|
81
|
+
}
|
|
82
|
+
export interface PulumiAdoptOpConfig {
|
|
83
|
+
/** Op name (kebab-case). */
|
|
84
|
+
name: string;
|
|
85
|
+
/** The stacks to adopt, one wave each, in this order. */
|
|
86
|
+
stacks: PulumiAdoptStack[];
|
|
87
|
+
/** Directory relative `dir`s resolve against. Default: the running process's cwd. */
|
|
88
|
+
cwd?: string;
|
|
89
|
+
/** The gate's name with one stack; with several, each gate is `<gateName>-<member>-<stack>`. Default: `approve-<name>`. */
|
|
90
|
+
gateName?: string;
|
|
91
|
+
/** How long a recorded pending gate stays valid, as a duration string. Default: core's own (48h). */
|
|
92
|
+
gateTimeout?: string;
|
|
93
|
+
/** Override the gate description shown to the approver. */
|
|
94
|
+
gateDescription?: string;
|
|
95
|
+
/** Rollback on a failed adoption, run as an `onFailure` phase. Refused without a command. */
|
|
96
|
+
compensate?: boolean | {
|
|
97
|
+
command?: string;
|
|
98
|
+
image?: string;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export interface PulumiAdoptOpResources {
|
|
102
|
+
/** Op resource: Check, Export, then Preview, gate and Adopt per stack. */
|
|
103
|
+
op: InstanceType<typeof OpResource>;
|
|
104
|
+
}
|
|
105
|
+
export declare function PulumiAdoptOp(config: PulumiAdoptOpConfig): PulumiAdoptOpResources;
|
|
106
|
+
//# sourceMappingURL=pulumi-adopt-op.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pulumi-adopt-op.d.ts","sourceRoot":"","sources":["../../src/composites/pulumi-adopt-op.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AE,mBAAmB,GAAG,sBAAsB,CAsFjF"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PulumiAdoptOp composite (#4562): adopt stock Pulumi stacks onto plunge's
|
|
3
|
+
* per-resource records, behind a gate, the pulumi twin of the terraform
|
|
4
|
+
* lexicon's `TerraformAdoptOp`. It is the step after `plywood init --engine
|
|
5
|
+
* plunge` (INTENTIUS/plywood#3); plywood supplies the words.
|
|
6
|
+
*
|
|
7
|
+
* plunge refuses a stock checkpoint with no records (`AdoptionRequiredError`)
|
|
8
|
+
* rather than recreate everything, so a stack moves to plunge by `plunge
|
|
9
|
+
* stack adopt`. Adoption writes one record per resource with the
|
|
10
|
+
* checkpoint's IDs and calls no cloud API; the next `plunge up` adds the
|
|
11
|
+
* `plunge-stack` and `plunge-urn` tags in place.
|
|
12
|
+
*
|
|
13
|
+
* Phases:
|
|
14
|
+
*
|
|
15
|
+
* - **Check**: the shared bucket check (#4558) on each stack's backend
|
|
16
|
+
* bucket. A setting that fails, not waived, refuses the run before
|
|
17
|
+
* anything is exported, naming the fix. A `file://` backend is skipped.
|
|
18
|
+
* - **Export**: each stack's stock checkpoint, `pulumi stack export
|
|
19
|
+
* --stack <s>`, kept in a scratch file. It is the back-out copy (`pulumi
|
|
20
|
+
* stack import --file` on a stock backend), and on the route from Pulumi
|
|
21
|
+
* Cloud (`from: { backend }`) or from an export taken by hand (`from: {
|
|
22
|
+
* file }`) it is what plunge adopts with `--file`.
|
|
23
|
+
* - Then one wave per stack, in the order given: **Preview** runs `plunge
|
|
24
|
+
* stack adopt --json` (writes nothing), the **gate** binds that preview's
|
|
25
|
+
* `planDigest`, and **Adopt** runs `plunge stack adopt --json --yes`. A
|
|
26
|
+
* stack whose checkpoint changed after approval previews a new digest,
|
|
27
|
+
* and the old approval does not open the gate for it.
|
|
28
|
+
*
|
|
29
|
+
* Every gate is a fact on the workspace ledger: `chant run` records the
|
|
30
|
+
* pending gate citing the preview's digest and exits gated, `chant approve
|
|
31
|
+
* <op> <gate>` writes the resolution, and the next run walks to the Adopt
|
|
32
|
+
* step. The run itself is a run record on the same ledger (#4551), as for
|
|
33
|
+
* `TerraformAdoptOp`. There is no `gate: "never"`: adoption moves the stack's
|
|
34
|
+
* state onto another backend's records, which nobody should skip reviewing.
|
|
35
|
+
*
|
|
36
|
+
* ## Compensation
|
|
37
|
+
*
|
|
38
|
+
* Refused without a command, as `TerraformAdoptOp` refuses it. Backing out
|
|
39
|
+
* is `plunge stack export --file s.json` then `pulumi stack import --file
|
|
40
|
+
* s.json` on a stock backend, a decision about the stack and its backend
|
|
41
|
+
* rather than something chant should run on its own.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* import { PulumiAdoptOp } from "@intentius/chant-lexicon-pulumi";
|
|
46
|
+
*
|
|
47
|
+
* export const { op } = PulumiAdoptOp({
|
|
48
|
+
* name: "adopt-infra",
|
|
49
|
+
* stacks: [{ member: "infra", dir: "./infra", stack: "dev" }],
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
import { Op, phase, gate, activity } from "@intentius/chant/op";
|
|
54
|
+
import { pulumiAdopt, pulumiAdoptCheck, pulumiAdoptExport, pulumiAdoptPreview } from "../op/builders.js";
|
|
55
|
+
const slug = (s) => s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
56
|
+
export function PulumiAdoptOp(config) {
|
|
57
|
+
const compensateCommand = typeof config.compensate === "object" ? config.compensate.command : undefined;
|
|
58
|
+
const compensateImage = typeof config.compensate === "object" ? config.compensate.image : undefined;
|
|
59
|
+
if (config.compensate !== undefined && config.compensate !== false && compensateCommand === undefined) {
|
|
60
|
+
throw new Error(`PulumiAdoptOp "${config.name}": compensate is enabled, but there is no automatic undo for an adoption. ` +
|
|
61
|
+
`Backing out is plunge stack export --file, then pulumi stack import --file on a stock backend, a decision ` +
|
|
62
|
+
`about the stack and its backend. Supply compensate: { command: "..." } with an undo of your own, or set ` +
|
|
63
|
+
`compensate: false.`);
|
|
64
|
+
}
|
|
65
|
+
if (!Array.isArray(config.stacks) || config.stacks.length === 0) {
|
|
66
|
+
throw new Error(`PulumiAdoptOp "${config.name}": stacks is empty; name at least one { member, dir, stack } to adopt`);
|
|
67
|
+
}
|
|
68
|
+
const seen = new Set();
|
|
69
|
+
for (const s of config.stacks) {
|
|
70
|
+
const key = `${s.member}/${s.stack}`;
|
|
71
|
+
if (seen.has(key))
|
|
72
|
+
throw new Error(`PulumiAdoptOp "${config.name}": ${key} is listed twice`);
|
|
73
|
+
seen.add(key);
|
|
74
|
+
}
|
|
75
|
+
const where = config.cwd ? { cwd: config.cwd } : {};
|
|
76
|
+
const single = config.stacks.length === 1;
|
|
77
|
+
const gateBase = config.gateName ?? `approve-${config.name}`;
|
|
78
|
+
const checks = config.stacks.map((s, i) => pulumiAdoptCheck(s.member, {
|
|
79
|
+
dir: s.dir,
|
|
80
|
+
stack: s.stack,
|
|
81
|
+
...where,
|
|
82
|
+
...(s.backend ? { backend: s.backend } : {}),
|
|
83
|
+
...(s.bucket ? { bucket: s.bucket } : {}),
|
|
84
|
+
...(s.namespaces ? { namespaces: s.namespaces } : {}),
|
|
85
|
+
...(s.allowInsecure ? { allowInsecure: s.allowInsecure } : {}),
|
|
86
|
+
id: `check-${i}`,
|
|
87
|
+
}));
|
|
88
|
+
const exports = config.stacks.map((s, i) => pulumiAdoptExport(s.member, {
|
|
89
|
+
dir: s.dir,
|
|
90
|
+
stack: s.stack,
|
|
91
|
+
...where,
|
|
92
|
+
...(s.backend ? { backend: s.backend } : {}),
|
|
93
|
+
...(s.from ? { from: s.from } : {}),
|
|
94
|
+
id: `export-${i}`,
|
|
95
|
+
profile: "longInfra",
|
|
96
|
+
}));
|
|
97
|
+
const waves = config.stacks.flatMap((s, i) => {
|
|
98
|
+
const file = s.from ? { file: exports[i].out.file } : {};
|
|
99
|
+
const preview = pulumiAdoptPreview(s.member, { dir: s.dir, stack: s.stack, ...where, ...file, id: `preview-${i}` });
|
|
100
|
+
preview.outcomeAttribute = { name: single ? "Adoptable" : `Adoptable-${slug(s.member)}-${slug(s.stack)}`, from: "resources" };
|
|
101
|
+
const adopt = pulumiAdopt(s.member, { dir: s.dir, stack: s.stack, ...where, ...file, planDigest: preview.out.planDigest, id: `adopt-${i}` });
|
|
102
|
+
adopt.outcomeAttribute = { name: single ? "Adopted" : `Adopted-${slug(s.member)}-${slug(s.stack)}`, from: "resources" };
|
|
103
|
+
const label = single ? "" : ` ${s.member}/${s.stack}`;
|
|
104
|
+
return [
|
|
105
|
+
phase(`Preview${label}`, [preview]),
|
|
106
|
+
phase(`Gate${label}`, [
|
|
107
|
+
gate(single ? gateBase : `${gateBase}-${slug(s.member)}-${slug(s.stack)}`, {
|
|
108
|
+
plan: preview.out.planDigest,
|
|
109
|
+
...(config.gateTimeout ? { timeout: config.gateTimeout } : {}),
|
|
110
|
+
description: config.gateDescription ??
|
|
111
|
+
`Approve adopting the Pulumi stack ${s.member}/${s.stack} onto plunge's per-resource records. The ` +
|
|
112
|
+
`preview's adopt document is what is approved: each resource gets a record with the checkpoint's ID, ` +
|
|
113
|
+
`no cloud object changes now, and the next plunge up writes the plunge-stack and plunge-urn tags.`,
|
|
114
|
+
}),
|
|
115
|
+
]),
|
|
116
|
+
phase(`Adopt${label}`, [adopt]),
|
|
117
|
+
];
|
|
118
|
+
});
|
|
119
|
+
const op = Op({
|
|
120
|
+
name: config.name,
|
|
121
|
+
overview: `Adopt ${single ? `the Pulumi stack ${config.stacks[0].member}/${config.stacks[0].stack}` : `${config.stacks.length} Pulumi stacks`} onto plunge's per-resource records`,
|
|
122
|
+
labels: {
|
|
123
|
+
Adopt: "true",
|
|
124
|
+
Surface: "pulumi-adopt",
|
|
125
|
+
},
|
|
126
|
+
phases: [phase("Check", checks), phase("Export", exports), ...waves],
|
|
127
|
+
...(compensateCommand
|
|
128
|
+
? { onFailure: [phase("Rollback", [activity("shellCmd", { cmd: compensateCommand, ...(compensateImage ? { image: compensateImage } : {}) })])] }
|
|
129
|
+
: {}),
|
|
130
|
+
});
|
|
131
|
+
return { op };
|
|
132
|
+
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The engine event stream of `pulumi up --json`, and of `pulumi preview
|
|
3
|
+
* --json` run with `PULUMI_ENABLE_STREAMING_JSON_PREVIEW=true` (#4541,
|
|
4
|
+
* ruling C): one `apitype.EngineEvent` per line, the same shape for stock
|
|
5
|
+
* Pulumi and plunge (`sdk/go/common/apitype/events.go`).
|
|
6
|
+
*
|
|
7
|
+
* The printed preview document drops policy events
|
|
8
|
+
* (`pkg/backend/display/json.go` `ShowPreviewDigest`), so the pulumi-up
|
|
9
|
+
* capability previews with the stream instead, and reads both the change set
|
|
10
|
+
* and CrossGuard's verdict from one engine run:
|
|
11
|
+
*
|
|
12
|
+
* - {@link pulumiStreamPreview}: the stream turned back into the document
|
|
13
|
+
* `pulumiPreviewPart` and `pulumiPreviewDigest` read (`./change-set.ts`).
|
|
14
|
+
* Steps come from `resourcePreEvent`, filtered as the printed document
|
|
15
|
+
* filters them (`shouldShow`: a non-logical replacement step is left out,
|
|
16
|
+
* and `same` steps are kept, since chant always passes `--show-sames`).
|
|
17
|
+
* Each state is normalized to the printed form: a blinded secret envelope
|
|
18
|
+
* becomes `"[secret]"`, an empty `inputs` or `outputs` map and an empty
|
|
19
|
+
* `id` are left out, and `detailedDiff`'s `diffKind` is read as `kind`.
|
|
20
|
+
* The digest of the result equals the digest of the printed document for
|
|
21
|
+
* the same preview (checked against `testdata/pulumi-stream`).
|
|
22
|
+
* - {@link pulumiPolicyEvents} and {@link pulumiPolicyFindings}: the
|
|
23
|
+
* `policyEvent` lines, as `@intentius/chant/gate-policy` findings. A
|
|
24
|
+
* `mandatory` violation denies; `advisory` ones are warnings; `disabled`
|
|
25
|
+
* ones are dropped.
|
|
26
|
+
* - {@link pulumiStreamSummary}: the `summaryEvent`, and plunge's
|
|
27
|
+
* per-resource timings (INTENTIUS/plunge#55) when the steps carry them.
|
|
28
|
+
* - {@link pulumiStreamTimings}: those timings alone, by URN. plunge puts
|
|
29
|
+
* `metadata.plungeTimings` on each `resOutputsEvent` and
|
|
30
|
+
* `resOpFailedEvent` of `up --json`: one entry per provider call (`kind:
|
|
31
|
+
* "provider"`, `call` one of check, diff, create, read, update, delete)
|
|
32
|
+
* and per write or delete of the resource's record (`kind: "record"`),
|
|
33
|
+
* each with `startedAt` and `durationMs`, and `failed` when it failed.
|
|
34
|
+
* Every call is on exactly one event, and a replacement's create and
|
|
35
|
+
* delete steps split a URN's calls over two events, so the reader joins
|
|
36
|
+
* them. Stock Pulumi prints no such field, and the reader then finds none.
|
|
37
|
+
*
|
|
38
|
+
* During `up`, the engine may first preview: those `resourcePreEvent`s carry
|
|
39
|
+
* `planning: true`. {@link pulumiAppliedSteps} keeps only the steps the update
|
|
40
|
+
* ran, which is what the stock apply compares with the approved shape
|
|
41
|
+
* (ruling A).
|
|
42
|
+
*
|
|
43
|
+
* Like `./change-set.ts`, this module imports only `./values` and types, so it
|
|
44
|
+
* bundles without node's process modules.
|
|
45
|
+
*/
|
|
46
|
+
import type { GatePolicyFindings } from "@intentius/chant/gate-policy";
|
|
47
|
+
import type { PulumiStep } from "./change-set.js";
|
|
48
|
+
import { type Json } from "./values.js";
|
|
49
|
+
/** The env var that makes `preview --json` stream engine events instead of printing one document (`sdk/go/common/env/env.go`). */
|
|
50
|
+
export declare const PULUMI_STREAMING_PREVIEW_ENV = "PULUMI_ENABLE_STREAMING_JSON_PREVIEW";
|
|
51
|
+
/** One line of the stream, as far as this module reads it. */
|
|
52
|
+
export interface PulumiEngineEvent {
|
|
53
|
+
sequence?: number;
|
|
54
|
+
timestamp?: number;
|
|
55
|
+
resourcePreEvent?: {
|
|
56
|
+
metadata?: PulumiEventStep;
|
|
57
|
+
planning?: boolean;
|
|
58
|
+
};
|
|
59
|
+
resOutputsEvent?: {
|
|
60
|
+
metadata?: PulumiEventStep;
|
|
61
|
+
planning?: boolean;
|
|
62
|
+
};
|
|
63
|
+
resOpFailedEvent?: {
|
|
64
|
+
metadata?: PulumiEventStep;
|
|
65
|
+
status?: number;
|
|
66
|
+
steps?: number;
|
|
67
|
+
};
|
|
68
|
+
policyEvent?: PulumiPolicyEvent;
|
|
69
|
+
summaryEvent?: PulumiSummaryEvent;
|
|
70
|
+
diagnosticEvent?: {
|
|
71
|
+
urn?: string;
|
|
72
|
+
message?: string;
|
|
73
|
+
severity?: string;
|
|
74
|
+
ephemeral?: boolean;
|
|
75
|
+
};
|
|
76
|
+
preludeEvent?: {
|
|
77
|
+
config?: Record<string, string>;
|
|
78
|
+
};
|
|
79
|
+
cancelEvent?: Record<string, never>;
|
|
80
|
+
errorEvent?: {
|
|
81
|
+
error?: string;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/** `apitype.StepEventMetadata`. */
|
|
85
|
+
export interface PulumiEventStep {
|
|
86
|
+
op?: string;
|
|
87
|
+
urn?: string;
|
|
88
|
+
type?: string;
|
|
89
|
+
old?: PulumiEventState | null;
|
|
90
|
+
new?: PulumiEventState | null;
|
|
91
|
+
keys?: string[];
|
|
92
|
+
diffs?: string[];
|
|
93
|
+
detailedDiff?: Record<string, {
|
|
94
|
+
diffKind?: string;
|
|
95
|
+
inputDiff?: boolean;
|
|
96
|
+
}> | null;
|
|
97
|
+
logical?: boolean;
|
|
98
|
+
provider?: string;
|
|
99
|
+
/** plunge's per-resource timings (INTENTIUS/plunge#55), when the fork prints them. Read with {@link plungeTimingOf}. */
|
|
100
|
+
plungeTimings?: unknown[];
|
|
101
|
+
}
|
|
102
|
+
/** What a plunge timing times: a provider call, or a write of the resource's own record. */
|
|
103
|
+
export type PlungeTimingKind = "provider" | "record";
|
|
104
|
+
/** The calls plunge times (INTENTIUS/plunge#55), by kind. */
|
|
105
|
+
export declare const PLUNGE_TIMING_CALLS: Readonly<Record<PlungeTimingKind, readonly string[]>>;
|
|
106
|
+
/** One entry of `metadata.plungeTimings` (INTENTIUS/plunge#55). */
|
|
107
|
+
export interface PlungeTiming {
|
|
108
|
+
kind: PlungeTimingKind;
|
|
109
|
+
/** For `provider`: check, diff, create, read, update or delete. For `record`: write or delete. */
|
|
110
|
+
call: string;
|
|
111
|
+
/** RFC 3339, to the nanosecond. */
|
|
112
|
+
startedAt: string;
|
|
113
|
+
/** Fractional milliseconds. */
|
|
114
|
+
durationMs: number;
|
|
115
|
+
/** Set when the call failed. A conditional record write that lost to another run counts as failed. */
|
|
116
|
+
failed?: boolean;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* `value` as a {@link PlungeTiming}, or undefined when it is not one. A
|
|
120
|
+
* `call` outside the kind's list is kept, so a newer plunge's calls still
|
|
121
|
+
* read; an entry with no kind, no start or a negative duration is dropped.
|
|
122
|
+
*/
|
|
123
|
+
export declare function plungeTimingOf(value: unknown): PlungeTiming | undefined;
|
|
124
|
+
/** `apitype.StepEventStateMetadata`. */
|
|
125
|
+
export interface PulumiEventState {
|
|
126
|
+
type?: string;
|
|
127
|
+
urn?: string;
|
|
128
|
+
custom?: boolean;
|
|
129
|
+
delete?: boolean;
|
|
130
|
+
id?: string;
|
|
131
|
+
parent?: string;
|
|
132
|
+
provider?: string;
|
|
133
|
+
inputs?: Json | null;
|
|
134
|
+
outputs?: Json | null;
|
|
135
|
+
}
|
|
136
|
+
/** `apitype.PolicyEvent`. */
|
|
137
|
+
export interface PulumiPolicyEvent {
|
|
138
|
+
resourceUrn?: string;
|
|
139
|
+
message?: string;
|
|
140
|
+
policyName?: string;
|
|
141
|
+
policyPackName?: string;
|
|
142
|
+
policyPackVersion?: string;
|
|
143
|
+
/** `advisory`, `mandatory`, `remediate` or `disabled`. */
|
|
144
|
+
enforcementLevel?: string;
|
|
145
|
+
severity?: string;
|
|
146
|
+
}
|
|
147
|
+
/** `apitype.SummaryEvent`. */
|
|
148
|
+
export interface PulumiSummaryEvent {
|
|
149
|
+
maybeCorrupt?: boolean;
|
|
150
|
+
durationSeconds?: number;
|
|
151
|
+
resourceChanges?: Record<string, number>;
|
|
152
|
+
isPreview?: boolean;
|
|
153
|
+
result?: string;
|
|
154
|
+
PolicyPacks?: Record<string, string>;
|
|
155
|
+
}
|
|
156
|
+
/** Every line of `stream` that parses as a JSON object. Other lines (a banner, a progress line) are skipped. */
|
|
157
|
+
export declare function pulumiEngineEvents(stream: string): PulumiEngineEvent[];
|
|
158
|
+
/** One event step as a printed preview step (`getPreviewMetadataStep`). */
|
|
159
|
+
export declare function pulumiStepOfEvent(m: PulumiEventStep): PulumiStep;
|
|
160
|
+
/**
|
|
161
|
+
* A streamed preview as the document `pulumi preview --json` prints without
|
|
162
|
+
* the env var: `steps`, `diagnostics` and, from the summary, `changeSummary`.
|
|
163
|
+
* What `pulumiPreviewPart` and `pulumiPreviewDigest` read.
|
|
164
|
+
*/
|
|
165
|
+
export declare function pulumiStreamPreview(stream: string | readonly PulumiEngineEvent[]): {
|
|
166
|
+
steps: PulumiStep[];
|
|
167
|
+
diagnostics: Array<{
|
|
168
|
+
urn?: string;
|
|
169
|
+
message: string;
|
|
170
|
+
severity: string;
|
|
171
|
+
}>;
|
|
172
|
+
changeSummary?: Record<string, number>;
|
|
173
|
+
};
|
|
174
|
+
/** The steps an `up` ran: its `resourcePreEvent`s outside any preview phase (`planning` unset). */
|
|
175
|
+
export declare function pulumiAppliedSteps(stream: string | readonly PulumiEngineEvent[]): PulumiStep[];
|
|
176
|
+
/** The URNs whose operation failed during an `up` (`resOpFailedEvent`), sorted. */
|
|
177
|
+
export declare function pulumiFailedUrns(stream: string | readonly PulumiEngineEvent[]): string[];
|
|
178
|
+
/** The URNs an `up` finished an operation on (`resOutputsEvent` outside a preview phase, `same` left out), sorted. */
|
|
179
|
+
export declare function pulumiLandedUrns(stream: string | readonly PulumiEngineEvent[]): string[];
|
|
180
|
+
/** A CrossGuard violation the stream reported. */
|
|
181
|
+
export interface PulumiPolicyViolation {
|
|
182
|
+
pack: string;
|
|
183
|
+
packVersion?: string;
|
|
184
|
+
policy: string;
|
|
185
|
+
enforcementLevel: string;
|
|
186
|
+
message: string;
|
|
187
|
+
urn?: string;
|
|
188
|
+
severity?: string;
|
|
189
|
+
}
|
|
190
|
+
/** The `policyEvent` lines of a stream, `disabled` ones left out. */
|
|
191
|
+
export declare function pulumiPolicyEvents(stream: string | readonly PulumiEngineEvent[]): PulumiPolicyViolation[];
|
|
192
|
+
/** The rule id a CrossGuard policy is named by in chant's gate and overrides: `crossguard.<pack>.<policy>`. */
|
|
193
|
+
export declare function crossGuardRule(v: Pick<PulumiPolicyViolation, "pack" | "policy">): string;
|
|
194
|
+
/**
|
|
195
|
+
* CrossGuard's violations as gate findings (`@intentius/chant/gate-policy`):
|
|
196
|
+
* a `mandatory` one denies the plan, an `advisory` (or `remediate`) one is
|
|
197
|
+
* a warning. CrossGuard has no hold.
|
|
198
|
+
*/
|
|
199
|
+
export declare function pulumiPolicyFindings(violations: readonly PulumiPolicyViolation[]): GatePolicyFindings;
|
|
200
|
+
/** What an `up` reported at its end, for the step's output. */
|
|
201
|
+
export interface PulumiApplySummary {
|
|
202
|
+
/** Counts by op, `same` included, as the engine reports them. */
|
|
203
|
+
resourceChanges: Record<string, number>;
|
|
204
|
+
durationSeconds?: number;
|
|
205
|
+
/** `succeeded`, `failed` or `cancelled`, when the engine says. */
|
|
206
|
+
result?: string;
|
|
207
|
+
maybeCorrupt?: boolean;
|
|
208
|
+
/** plunge's per-resource timings (INTENTIUS/plunge#55), by URN, in stream order, when the steps carry them. */
|
|
209
|
+
timings?: Record<string, PlungeTiming[]>;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* plunge's per-resource timings in `up --json` (INTENTIUS/plunge#55), by URN:
|
|
213
|
+
* every valid entry of `metadata.plungeTimings` on each `resOutputsEvent`
|
|
214
|
+
* and `resOpFailedEvent`, joined across a URN's events in stream order. A
|
|
215
|
+
* stock Pulumi stream gives `{}`.
|
|
216
|
+
*/
|
|
217
|
+
export declare function pulumiStreamTimings(stream: string | readonly PulumiEngineEvent[]): Record<string, PlungeTiming[]>;
|
|
218
|
+
/** The stream's `summaryEvent`, with plunge's timings when present. Undefined when the stream has no summary. */
|
|
219
|
+
export declare function pulumiStreamSummary(stream: string | readonly PulumiEngineEvent[]): PulumiApplySummary | undefined;
|
|
220
|
+
/** The first error a stream reported (an error diagnostic or an `errorEvent`), if any. */
|
|
221
|
+
export declare function pulumiStreamError(stream: string | readonly PulumiEngineEvent[]): string | undefined;
|
|
222
|
+
//# sourceMappingURL=engine-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine-events.d.ts","sourceRoot":"","sources":["../src/engine-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,KAAK,EAAE,UAAU,EAAmB,MAAM,cAAc,CAAC;AAChE,OAAO,EAAsE,KAAK,IAAI,EAAE,MAAM,UAAU,CAAC;AAEzG,kIAAkI;AAClI,eAAO,MAAM,4BAA4B,yCAAyC,CAAC;AAEnF,8DAA8D;AAC9D,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,eAAe,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IACtE,eAAe,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,eAAe,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IACrE,gBAAgB,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,eAAe,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;K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