@intentius/chant-lexicon-pulumi 0.124.98 → 0.124.99
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/adopt.d.ts +0 -1
- package/dist/capability-plugin.d.ts +0 -1
- package/dist/change-set.d.ts +0 -1
- package/dist/changed-units.d.ts +0 -1
- package/dist/check-step.d.ts +0 -1
- package/dist/ci-setup.d.ts +0 -1
- package/dist/codegen/docs-cli.d.ts +0 -1
- package/dist/codegen/docs.d.ts +0 -1
- package/dist/codegen/package.d.ts +0 -1
- package/dist/composites/pulumi-adopt-op.d.ts +0 -1
- package/dist/composites/pulumi-watch-op.d.ts +0 -1
- package/dist/config.d.ts +0 -1
- package/dist/describe-resources.d.ts +0 -1
- package/dist/drift-read.d.ts +0 -1
- package/dist/drift-record.d.ts +0 -1
- package/dist/engine-events.d.ts +0 -1
- package/dist/engine-graph.d.ts +0 -1
- package/dist/exit-codes.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/init-templates.d.ts +0 -1
- package/dist/integrity.json +2 -2
- package/dist/lint/audit-catalog.d.ts +0 -1
- package/dist/lint/post-synth/index.d.ts +0 -1
- package/dist/lint/post-synth/member-read-helpers.d.ts +0 -1
- package/dist/lint/post-synth/pul001.d.ts +0 -1
- package/dist/lint/post-synth/pul002.d.ts +0 -1
- package/dist/lint/post-synth/pul003.d.ts +0 -1
- package/dist/lint/post-synth/pul004.d.ts +0 -1
- package/dist/lint/post-synth/pul005.d.ts +0 -1
- package/dist/lint/post-synth/pul006.d.ts +0 -1
- package/dist/lint/post-synth/pul007.d.ts +0 -1
- package/dist/lint/post-synth/pul008.d.ts +0 -1
- package/dist/lint/post-synth/pul009.d.ts +0 -1
- package/dist/lint/post-synth/pul010.d.ts +0 -1
- package/dist/lint/post-synth/pul011.d.ts +0 -1
- package/dist/lint/post-synth/pul012.d.ts +0 -1
- package/dist/lint/post-synth/pul013.d.ts +0 -1
- package/dist/lint/post-synth/pul014.d.ts +0 -1
- package/dist/lint/post-synth/pul015.d.ts +0 -1
- package/dist/lint/rules/index.d.ts +0 -1
- package/dist/lint/rules/member-dir-absolute.d.ts +0 -1
- package/dist/lock-rows.d.ts +0 -1
- package/dist/lsp/completions.d.ts +0 -1
- package/dist/lsp/documents.d.ts +0 -1
- package/dist/lsp/hover.d.ts +0 -1
- package/dist/lsp/keys.d.ts +0 -1
- package/dist/lsp/object-path.d.ts +0 -1
- package/dist/lsp/yaml-cursor.d.ts +0 -1
- package/dist/manifest.json +1 -1
- package/dist/member-engine.d.ts +0 -1
- package/dist/member-outputs.d.ts +0 -1
- package/dist/op/activities/index.d.ts +0 -1
- package/dist/op/activities/pulumi-adopt.d.ts +0 -1
- package/dist/op/activities/pulumi.d.ts +0 -1
- package/dist/op/activity-contracts.d.ts +0 -1
- package/dist/op/builders.d.ts +0 -1
- package/dist/package-cli.d.ts +0 -1
- package/dist/plan-shape.d.ts +0 -1
- package/dist/planned-output-changes.d.ts +0 -1
- package/dist/plugin.d.ts +0 -1
- package/dist/plunge-timings.d.ts +0 -1
- package/dist/preview-tips.d.ts +0 -1
- package/dist/pulumi-up.d.ts +0 -1
- package/dist/release-copy.d.ts +0 -1
- package/dist/review-stack.d.ts +0 -1
- package/dist/run.d.ts +0 -1
- package/dist/serializer.d.ts +0 -1
- package/dist/stack-export-snapshot.d.ts +0 -1
- package/dist/stack-ops.d.ts +0 -1
- package/dist/stack-outputs.d.ts +0 -1
- package/dist/stack-references.d.ts +0 -1
- package/dist/trace-facts.d.ts +0 -1
- package/dist/values.d.ts +0 -1
- package/dist/workspace-member.d.ts +0 -1
- package/package.json +3 -4
- package/dist/adopt.d.ts.map +0 -1
- package/dist/capability-plugin.d.ts.map +0 -1
- package/dist/change-set.d.ts.map +0 -1
- package/dist/changed-units.d.ts.map +0 -1
- package/dist/check-step.d.ts.map +0 -1
- package/dist/ci-setup.d.ts.map +0 -1
- package/dist/codegen/docs-cli.d.ts.map +0 -1
- package/dist/codegen/docs.d.ts.map +0 -1
- package/dist/codegen/package.d.ts.map +0 -1
- package/dist/composites/pulumi-adopt-op.d.ts.map +0 -1
- package/dist/composites/pulumi-watch-op.d.ts.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/describe-resources.d.ts.map +0 -1
- package/dist/drift-read.d.ts.map +0 -1
- package/dist/drift-record.d.ts.map +0 -1
- package/dist/engine-events.d.ts.map +0 -1
- package/dist/engine-graph.d.ts.map +0 -1
- package/dist/exit-codes.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/init-templates.d.ts.map +0 -1
- package/dist/lint/audit-catalog.d.ts.map +0 -1
- package/dist/lint/post-synth/index.d.ts.map +0 -1
- package/dist/lint/post-synth/member-read-helpers.d.ts.map +0 -1
- package/dist/lint/post-synth/pul001.d.ts.map +0 -1
- package/dist/lint/post-synth/pul002.d.ts.map +0 -1
- package/dist/lint/post-synth/pul003.d.ts.map +0 -1
- package/dist/lint/post-synth/pul004.d.ts.map +0 -1
- package/dist/lint/post-synth/pul005.d.ts.map +0 -1
- package/dist/lint/post-synth/pul006.d.ts.map +0 -1
- package/dist/lint/post-synth/pul007.d.ts.map +0 -1
- package/dist/lint/post-synth/pul008.d.ts.map +0 -1
- package/dist/lint/post-synth/pul009.d.ts.map +0 -1
- package/dist/lint/post-synth/pul010.d.ts.map +0 -1
- package/dist/lint/post-synth/pul011.d.ts.map +0 -1
- package/dist/lint/post-synth/pul012.d.ts.map +0 -1
- package/dist/lint/post-synth/pul013.d.ts.map +0 -1
- package/dist/lint/post-synth/pul014.d.ts.map +0 -1
- package/dist/lint/post-synth/pul015.d.ts.map +0 -1
- package/dist/lint/rules/index.d.ts.map +0 -1
- package/dist/lint/rules/member-dir-absolute.d.ts.map +0 -1
- package/dist/lock-rows.d.ts.map +0 -1
- package/dist/lsp/completions.d.ts.map +0 -1
- package/dist/lsp/documents.d.ts.map +0 -1
- package/dist/lsp/hover.d.ts.map +0 -1
- package/dist/lsp/keys.d.ts.map +0 -1
- package/dist/lsp/object-path.d.ts.map +0 -1
- package/dist/lsp/yaml-cursor.d.ts.map +0 -1
- package/dist/member-engine.d.ts.map +0 -1
- package/dist/member-outputs.d.ts.map +0 -1
- package/dist/op/activities/index.d.ts.map +0 -1
- package/dist/op/activities/pulumi-adopt.d.ts.map +0 -1
- package/dist/op/activities/pulumi.d.ts.map +0 -1
- package/dist/op/activity-contracts.d.ts.map +0 -1
- package/dist/op/builders.d.ts.map +0 -1
- package/dist/package-cli.d.ts.map +0 -1
- package/dist/plan-shape.d.ts.map +0 -1
- package/dist/planned-output-changes.d.ts.map +0 -1
- package/dist/plugin.d.ts.map +0 -1
- package/dist/plunge-timings.d.ts.map +0 -1
- package/dist/preview-tips.d.ts.map +0 -1
- package/dist/pulumi-up.d.ts.map +0 -1
- package/dist/release-copy.d.ts.map +0 -1
- package/dist/review-stack.d.ts.map +0 -1
- package/dist/run.d.ts.map +0 -1
- package/dist/serializer.d.ts.map +0 -1
- package/dist/stack-export-snapshot.d.ts.map +0 -1
- package/dist/stack-ops.d.ts.map +0 -1
- package/dist/stack-outputs.d.ts.map +0 -1
- package/dist/stack-references.d.ts.map +0 -1
- package/dist/trace-facts.d.ts.map +0 -1
- package/dist/values.d.ts.map +0 -1
- package/dist/workspace-member.d.ts.map +0 -1
- package/src/adopt.ts +0 -202
- package/src/capability-plugin.ts +0 -34
- package/src/change-set.test.ts +0 -245
- package/src/change-set.ts +0 -508
- package/src/changed-units.test.ts +0 -87
- package/src/changed-units.ts +0 -96
- package/src/check-step.test.ts +0 -191
- package/src/check-step.ts +0 -316
- package/src/ci-setup.test.ts +0 -234
- package/src/ci-setup.ts +0 -224
- package/src/codegen/docs-cli.ts +0 -4
- package/src/codegen/docs.ts +0 -58
- package/src/codegen/package.ts +0 -63
- package/src/composites/pulumi-adopt-op.test.ts +0 -258
- package/src/composites/pulumi-adopt-op.ts +0 -193
- package/src/composites/pulumi-watch-op.test.ts +0 -42
- package/src/composites/pulumi-watch-op.ts +0 -85
- package/src/config.ts +0 -43
- package/src/describe-resources.test.ts +0 -112
- package/src/describe-resources.ts +0 -118
- package/src/drift-read.test.ts +0 -178
- package/src/drift-read.ts +0 -94
- package/src/drift-record.test.ts +0 -197
- package/src/drift-record.ts +0 -326
- package/src/engine-events.test.ts +0 -160
- package/src/engine-events.ts +0 -395
- package/src/engine-graph.test.ts +0 -141
- package/src/engine-graph.ts +0 -149
- package/src/exit-codes.test.ts +0 -21
- package/src/exit-codes.ts +0 -71
- package/src/index.ts +0 -139
- package/src/init-templates.ts +0 -85
- package/src/lint/audit-catalog.test.ts +0 -33
- package/src/lint/audit-catalog.ts +0 -174
- package/src/lint/post-synth/index.ts +0 -35
- package/src/lint/post-synth/member-read-helpers.ts +0 -122
- package/src/lint/post-synth/post-synth.test.ts +0 -245
- package/src/lint/post-synth/pul001.ts +0 -38
- package/src/lint/post-synth/pul002.ts +0 -38
- package/src/lint/post-synth/pul003.ts +0 -43
- package/src/lint/post-synth/pul004.ts +0 -32
- package/src/lint/post-synth/pul005.ts +0 -31
- package/src/lint/post-synth/pul006.ts +0 -31
- package/src/lint/post-synth/pul007.ts +0 -35
- package/src/lint/post-synth/pul008.ts +0 -35
- package/src/lint/post-synth/pul009.ts +0 -32
- package/src/lint/post-synth/pul010.ts +0 -42
- package/src/lint/post-synth/pul011.ts +0 -38
- package/src/lint/post-synth/pul012.ts +0 -35
- package/src/lint/post-synth/pul013.ts +0 -35
- package/src/lint/post-synth/pul014.ts +0 -32
- package/src/lint/post-synth/pul015.ts +0 -39
- package/src/lint/rules/index.ts +0 -7
- package/src/lint/rules/member-dir-absolute.test.ts +0 -37
- package/src/lint/rules/member-dir-absolute.ts +0 -83
- package/src/lock-rows.test.ts +0 -60
- package/src/lock-rows.ts +0 -56
- package/src/lsp/completions.test.ts +0 -69
- package/src/lsp/completions.ts +0 -119
- package/src/lsp/documents.ts +0 -48
- package/src/lsp/hover.test.ts +0 -56
- package/src/lsp/hover.ts +0 -83
- package/src/lsp/keys.ts +0 -169
- package/src/lsp/object-path.ts +0 -71
- package/src/lsp/yaml-cursor.ts +0 -85
- package/src/member-engine.test.ts +0 -112
- package/src/member-engine.ts +0 -97
- package/src/member-outputs.test.ts +0 -339
- package/src/member-outputs.ts +0 -157
- package/src/op/activities/index.ts +0 -36
- package/src/op/activities/pulumi-adopt.ts +0 -345
- package/src/op/activities/pulumi.ts +0 -136
- package/src/op/activity-contracts.ts +0 -129
- package/src/op/builders.ts +0 -67
- package/src/package-cli.ts +0 -14
- package/src/plan-shape.test.ts +0 -91
- package/src/plan-shape.ts +0 -105
- package/src/planned-output-changes.test.ts +0 -85
- package/src/planned-output-changes.ts +0 -141
- package/src/plugin.test.ts +0 -96
- package/src/plugin.ts +0 -272
- package/src/plunge-timings.test.ts +0 -241
- package/src/plunge-timings.ts +0 -115
- package/src/plunge-up-failed.test.ts +0 -54
- package/src/pr-note.test.ts +0 -87
- package/src/preview-generated.test.ts +0 -124
- package/src/preview-tips.test.ts +0 -134
- package/src/preview-tips.ts +0 -128
- package/src/pulumi-up.test.ts +0 -581
- package/src/pulumi-up.ts +0 -1102
- package/src/pulumi-urn-node.test.ts +0 -94
- package/src/release-copy.test.ts +0 -162
- package/src/release-copy.ts +0 -223
- package/src/review-stack.test.ts +0 -254
- package/src/review-stack.ts +0 -266
- package/src/run-plan-flags.test.ts +0 -53
- package/src/run.test.ts +0 -540
- package/src/run.ts +0 -1129
- package/src/serializer.test.ts +0 -9
- package/src/serializer.ts +0 -15
- package/src/skills/chant-pulumi-plunge.md +0 -51
- package/src/skills/chant-pulumi-stack-export.md +0 -54
- package/src/skills/chant-pulumi.md +0 -83
- package/src/stack-export-snapshot.test.ts +0 -192
- package/src/stack-export-snapshot.ts +0 -312
- package/src/stack-ops.fake-binary.test.ts +0 -323
- package/src/stack-ops.test.ts +0 -511
- package/src/stack-ops.ts +0 -1082
- package/src/stack-outputs.ts +0 -66
- package/src/stack-references.test.ts +0 -96
- package/src/stack-references.ts +0 -110
- package/src/testdata/plunge-drift/README.md +0 -10
- package/src/testdata/plunge-drift/assets-drifted.ndjson +0 -3
- package/src/testdata/plunge-drift/component-unsupported.ndjson +0 -3
- package/src/testdata/plunge-drift/role-in-sync.ndjson +0 -3
- package/src/testdata/plunge-drift/settled-empty.ndjson +0 -2
- package/src/testdata/plunge-graph/Pulumi.yaml +0 -4
- package/src/testdata/plunge-graph/README.md +0 -12
- package/src/testdata/plunge-graph/engine-graph.json +0 -158
- package/src/testdata/plunge-graph/stack-export.json +0 -49
- package/src/testdata/plunge-member/Pulumi.yaml +0 -4
- package/src/testdata/plunge-member/README.md +0 -3
- package/src/testdata/plunge-member/stack-export.json +0 -480
- package/src/testdata/plunge-outputs/Pulumi.yaml +0 -9
- package/src/testdata/plunge-outputs/README.md +0 -7
- package/src/testdata/plunge-outputs/stack-export.json +0 -2003
- package/src/testdata/plunge-outputs/stack-output.json +0 -19
- package/src/testdata/pulumi-member/Pulumi.yaml +0 -2
- package/src/testdata/pulumi-member/README.md +0 -50
- package/src/testdata/pulumi-member/recording/Pulumi.dev.yaml +0 -19
- package/src/testdata/pulumi-member/recording/Pulumi.yaml +0 -7
- package/src/testdata/pulumi-member/recording/index.js +0 -47
- package/src/testdata/pulumi-member/recording/package-lock.json +0 -2707
- package/src/testdata/pulumi-member/recording/package.json +0 -9
- package/src/testdata/pulumi-member/stack-export.json +0 -746
- package/src/testdata/pulumi-outputs/Pulumi.yaml +0 -7
- package/src/testdata/pulumi-outputs/README.md +0 -9
- package/src/testdata/pulumi-outputs/preview-replaced.json +0 -2894
- package/src/testdata/pulumi-outputs/preview-settled.json +0 -2894
- package/src/testdata/pulumi-outputs/stack-export.json +0 -1919
- package/src/testdata/pulumi-outputs/stack-output.json +0 -19
- package/src/testdata/pulumi-preview/Pulumi.yaml +0 -7
- package/src/testdata/pulumi-preview/README.md +0 -9
- package/src/testdata/pulumi-preview/preview-create.json +0 -992
- package/src/testdata/pulumi-preview/preview.json +0 -2894
- package/src/testdata/pulumi-preview/stack-export.json +0 -1919
- package/src/testdata/pulumi-refresh/Pulumi.yaml +0 -7
- package/src/testdata/pulumi-refresh/README.md +0 -14
- package/src/testdata/pulumi-refresh/all.json +0 -3742
- package/src/testdata/pulumi-refresh/bucket-edited.json +0 -468
- package/src/testdata/pulumi-refresh/policy-deleted.json +0 -95
- package/src/testdata/pulumi-refresh/queue-edited.json +0 -250
- package/src/testdata/pulumi-refresh/role-same.json +0 -242
- package/src/testdata/pulumi-refresh/secret-edited.json +0 -247
- package/src/testdata/pulumi-refresh/stack-export.json +0 -1907
- package/src/testdata/pulumi-stream/README.md +0 -16
- package/src/testdata/pulumi-stream/preview-stream.ndjson +0 -42
- package/src/testdata/pulumi-stream/up-failed-plunge.ndjson +0 -5
- package/src/testdata/pulumi-unexported/Pulumi.yaml +0 -2
- package/src/testdata/pulumi-urn-node/Pulumi.yaml +0 -7
- package/src/testdata/pulumi-urn-node/README.md +0 -9
- package/src/testdata/pulumi-urn-node/preview.json +0 -2894
- package/src/testdata/pulumi-urn-node/stack-export.json +0 -1919
- package/src/trace-facts.test.ts +0 -38
- package/src/trace-facts.ts +0 -83
- package/src/values.ts +0 -147
- package/src/workspace-kinds.test.ts +0 -47
- package/src/workspace-member.test.ts +0 -127
- package/src/workspace-member.ts +0 -304
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The engine event stream (#4541, ruling C): a preview streamed with
|
|
3
|
-
* `PULUMI_ENABLE_STREAMING_JSON_PREVIEW=true` reads as the printed document,
|
|
4
|
-
* with the same digest, and its policy events become gate findings.
|
|
5
|
-
*
|
|
6
|
-
* `testdata/pulumi-stream/preview-stream.ndjson` is the recorded
|
|
7
|
-
* `testdata/pulumi-preview/preview.json` (pulumi 3.272.0, the plunge corpus
|
|
8
|
-
* on floci, #4475) converted to the stream form; see its README. Nothing
|
|
9
|
-
* here runs Pulumi.
|
|
10
|
-
*/
|
|
11
|
-
import { readFileSync } from "node:fs";
|
|
12
|
-
import { join } from "node:path";
|
|
13
|
-
import { describe, expect, test } from "vitest";
|
|
14
|
-
import { pulumiMayAppearAddress } from "@intentius/chant/pulumi-urn";
|
|
15
|
-
import { pulumiPreviewDigest, pulumiPreviewPart, type PulumiStep } from "./change-set";
|
|
16
|
-
import {
|
|
17
|
-
crossGuardRule,
|
|
18
|
-
pulumiAppliedSteps,
|
|
19
|
-
pulumiEngineEvents,
|
|
20
|
-
pulumiFailedUrns,
|
|
21
|
-
pulumiLandedUrns,
|
|
22
|
-
pulumiPolicyEvents,
|
|
23
|
-
pulumiPolicyFindings,
|
|
24
|
-
pulumiStreamError,
|
|
25
|
-
pulumiStreamPreview,
|
|
26
|
-
pulumiStreamSummary,
|
|
27
|
-
} from "./engine-events";
|
|
28
|
-
|
|
29
|
-
const testdata = join(import.meta.dirname, "testdata");
|
|
30
|
-
const printed = JSON.parse(readFileSync(join(testdata, "pulumi-preview", "preview.json"), "utf-8")) as { steps: Array<{ op: string; urn: string }> };
|
|
31
|
-
const stream = readFileSync(join(testdata, "pulumi-stream", "preview-stream.ndjson"), "utf-8");
|
|
32
|
-
const urn = (type: string, name: string) => `urn:pulumi:floci::corpus-aws-ts::${type}::${name}`;
|
|
33
|
-
|
|
34
|
-
describe("a streamed preview reads as the printed document", () => {
|
|
35
|
-
test("its digest equals the printed document's", () => {
|
|
36
|
-
expect(pulumiPreviewDigest(pulumiStreamPreview(stream))).toBe(pulumiPreviewDigest(printed));
|
|
37
|
-
expect(pulumiPreviewDigest(pulumiStreamPreview(stream), { changedOnly: true })).toBe(pulumiPreviewDigest(printed, { changedOnly: true }));
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
test("the steps are the printed ones, in order: non-logical replacement steps are left out", () => {
|
|
41
|
-
const steps = pulumiStreamPreview(stream).steps;
|
|
42
|
-
expect(steps.map((s) => [s.op, s.urn])).toEqual(printed.steps.map((s) => [s.op, s.urn]));
|
|
43
|
-
expect(steps.some((s) => s.op === "create-replacement" || s.op === "delete-replaced")).toBe(false);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test("a blinded secret envelope reads as [secret], and empty maps and ids are left out", () => {
|
|
47
|
-
const steps = pulumiStreamPreview(stream).steps;
|
|
48
|
-
const stack = steps.find((s) => s.urn?.includes("pulumi:pulumi:Stack"))!;
|
|
49
|
-
expect(stack.oldState?.inputs).toBeUndefined();
|
|
50
|
-
expect(stack.oldState?.id).toBeUndefined();
|
|
51
|
-
expect(stack.oldState?.outputs?.dbPasswordValue).toBe("[secret]");
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test("the part has the printed document's entries and digest", () => {
|
|
55
|
-
const fromStream = pulumiPreviewPart({ member: "site/floci", preview: pulumiStreamPreview(stream), stack: "floci" });
|
|
56
|
-
const fromPrinted = pulumiPreviewPart({ member: "site/floci", preview: printed, stack: "floci" });
|
|
57
|
-
expect(fromStream).toEqual(fromPrinted);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test("a component's state, whose custom: false the stream omits, reads as custom: false", () => {
|
|
61
|
-
expect(stream).not.toContain('"custom":false');
|
|
62
|
-
const steps = pulumiStreamPreview(stream).steps;
|
|
63
|
-
const docs = steps.find((s) => s.urn === urn("corpus:index:Site", "docs"))!;
|
|
64
|
-
expect(docs.oldState?.custom).toBe(false);
|
|
65
|
-
expect(docs.newState?.custom).toBe(false);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
test("change-set signal 1 marks the same components from the stream as from the printed document (#4640)", () => {
|
|
69
|
-
// docs-assets, a child of the docs component, given an input preview does not know.
|
|
70
|
-
const waiting = (steps: PulumiStep[]): PulumiStep[] =>
|
|
71
|
-
structuredClone(steps).map((s) =>
|
|
72
|
-
s.urn?.endsWith("Site$aws:s3/bucket:Bucket::docs-assets")
|
|
73
|
-
? { ...s, op: "update", diffReasons: ["tags"], newState: { ...s.newState!, inputs: { ...(s.newState!.inputs as object), tags: "04da6b54-80e4-46f7-96ec-b56ff0331ba9" } } }
|
|
74
|
-
: s,
|
|
75
|
-
);
|
|
76
|
-
const mayAppear = (steps: PulumiStep[]) =>
|
|
77
|
-
pulumiPreviewPart({ member: "site/floci", preview: { steps: waiting(steps) }, stack: "floci" })
|
|
78
|
-
.entries.filter((e) => e.mayAppear === true)
|
|
79
|
-
.map((e) => e.address);
|
|
80
|
-
const fromPrinted = mayAppear(printed.steps as PulumiStep[]);
|
|
81
|
-
expect(fromPrinted).toEqual([pulumiMayAppearAddress(urn("corpus:index:Site", "docs"))]);
|
|
82
|
-
expect(mayAppear(pulumiStreamPreview(stream).steps)).toEqual(fromPrinted);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
test("an ephemeral diagnostic is left out, and the summary gives changeSummary", () => {
|
|
86
|
-
const doc = pulumiStreamPreview(stream);
|
|
87
|
-
expect(doc.diagnostics.some((d) => d.message === "progress\n")).toBe(false);
|
|
88
|
-
expect(doc.changeSummary).toEqual({ delete: 2, replace: 2, same: 11, update: 2 });
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
test("a line that is not an event is skipped", () => {
|
|
92
|
-
expect(pulumiEngineEvents(`Previewing update (floci)\n${stream}\nnot json {`).length).toBe(pulumiEngineEvents(stream).length);
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
describe("CrossGuard's policy events (ruling 7)", () => {
|
|
97
|
-
test("the advisory violation is a warning, named crossguard.<pack>.<policy>", () => {
|
|
98
|
-
const violations = pulumiPolicyEvents(stream);
|
|
99
|
-
expect(violations).toEqual([
|
|
100
|
-
{
|
|
101
|
-
pack: "corpus-checks",
|
|
102
|
-
packVersion: "0.1.0",
|
|
103
|
-
policy: "sqs-dead-letter",
|
|
104
|
-
enforcementLevel: "advisory",
|
|
105
|
-
message: "Queues should set a dead-letter queue.",
|
|
106
|
-
urn: urn("aws:sqs/queue:Queue", "events"),
|
|
107
|
-
},
|
|
108
|
-
]);
|
|
109
|
-
expect(pulumiPolicyFindings(violations)).toEqual({
|
|
110
|
-
denials: [],
|
|
111
|
-
holds: [],
|
|
112
|
-
warnings: [`crossguard.corpus-checks.sqs-dead-letter: Queues should set a dead-letter queue. (${urn("aws:sqs/queue:Queue", "events")})`],
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
test("a mandatory violation denies, and a disabled one is dropped", () => {
|
|
117
|
-
const line = (level: string) =>
|
|
118
|
-
JSON.stringify({ policyEvent: { message: "no public buckets", policyName: "s3-private", policyPackName: "org", policyPackVersion: "1", enforcementLevel: level, resourceUrn: urn("aws:s3/bucket:Bucket", "site-bucket") } });
|
|
119
|
-
const findings = pulumiPolicyFindings(pulumiPolicyEvents(`${line("mandatory")}\n${line("disabled")}\n`));
|
|
120
|
-
expect(findings.denials).toEqual([{ rule: "crossguard.org.s3-private", message: `no public buckets (${urn("aws:s3/bucket:Bucket", "site-bucket")})` }]);
|
|
121
|
-
expect(findings.warnings).toEqual([]);
|
|
122
|
-
expect(crossGuardRule({ pack: "org", policy: "s3-private" })).toBe("crossguard.org.s3-private");
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
describe("an up's stream", () => {
|
|
127
|
-
// The same events with no preview phase: what `up --json` streams for the steps it runs.
|
|
128
|
-
const up = stream.replaceAll(',"planning":true', "");
|
|
129
|
-
|
|
130
|
-
test("pulumiAppliedSteps keeps only steps outside a preview phase", () => {
|
|
131
|
-
expect(pulumiAppliedSteps(stream)).toEqual([]);
|
|
132
|
-
expect(pulumiAppliedSteps(up).map((s) => s.op)).toEqual(printed.steps.map((s) => s.op));
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
test("the URNs that landed leave out same steps, and a failed operation is named", () => {
|
|
136
|
-
const failed = JSON.stringify({ resOpFailedEvent: { metadata: { op: "update", urn: urn("aws:sqs/queue:Queue", "events") }, status: 1, steps: 0 } });
|
|
137
|
-
expect(pulumiLandedUrns(up)).toContain(urn("aws:ec2/vpc:Vpc", "main"));
|
|
138
|
-
expect(pulumiLandedUrns(up)).not.toContain(urn("aws:iam/role:Role", "app-role"));
|
|
139
|
-
expect(pulumiFailedUrns(`${up}${failed}\n`)).toEqual([urn("aws:sqs/queue:Queue", "events")]);
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
test("the summary carries the counts, and plunge's timings when a step has them (plunge#55)", () => {
|
|
143
|
-
// plunge#55's shape; an entry in any other shape is dropped (#4579).
|
|
144
|
-
const entry = { kind: "provider", call: "update", startedAt: "2026-10-27T12:00:00.123456789Z", durationMs: 812.4 };
|
|
145
|
-
const timed = JSON.stringify({ resOutputsEvent: { metadata: { op: "update", urn: urn("aws:sqs/queue:Queue", "events"), plungeTimings: [entry, { phase: "update", ms: 812 }] } } });
|
|
146
|
-
expect(pulumiStreamSummary(`${up}${timed}\n`)).toEqual({
|
|
147
|
-
resourceChanges: { delete: 2, replace: 2, same: 11, update: 2 },
|
|
148
|
-
durationSeconds: 4,
|
|
149
|
-
result: "succeeded",
|
|
150
|
-
timings: { [urn("aws:sqs/queue:Queue", "events")]: [entry] },
|
|
151
|
-
});
|
|
152
|
-
expect(pulumiStreamSummary("")).toBeUndefined();
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
test("the first error is an errorEvent or an error diagnostic", () => {
|
|
156
|
-
expect(pulumiStreamError(stream)).toBeUndefined();
|
|
157
|
-
expect(pulumiStreamError(`${JSON.stringify({ diagnosticEvent: { message: "error: update failed", severity: "error" } })}\n`)).toBe("error: update failed");
|
|
158
|
-
expect(pulumiStreamError(`${JSON.stringify({ errorEvent: { error: "plan moved" } })}\n`)).toBe("plan moved");
|
|
159
|
-
});
|
|
160
|
-
});
|
package/src/engine-events.ts
DELETED
|
@@ -1,395 +0,0 @@
|
|
|
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
|
-
|
|
47
|
-
import type { GatePolicyFindings } from "@intentius/chant/gate-policy";
|
|
48
|
-
import type { PulumiStep, PulumiStepState } from "./change-set";
|
|
49
|
-
import { isObject, PULUMI_BLINDED_SECRET, PULUMI_SECRET_SIG, PULUMI_SIG_KEY, type Json } from "./values";
|
|
50
|
-
|
|
51
|
-
/** The env var that makes `preview --json` stream engine events instead of printing one document (`sdk/go/common/env/env.go`). */
|
|
52
|
-
export const PULUMI_STREAMING_PREVIEW_ENV = "PULUMI_ENABLE_STREAMING_JSON_PREVIEW";
|
|
53
|
-
|
|
54
|
-
/** One line of the stream, as far as this module reads it. */
|
|
55
|
-
export interface PulumiEngineEvent {
|
|
56
|
-
sequence?: number;
|
|
57
|
-
timestamp?: number;
|
|
58
|
-
resourcePreEvent?: { metadata?: PulumiEventStep; planning?: boolean };
|
|
59
|
-
resOutputsEvent?: { metadata?: PulumiEventStep; planning?: boolean };
|
|
60
|
-
resOpFailedEvent?: { metadata?: PulumiEventStep; status?: number; steps?: number };
|
|
61
|
-
policyEvent?: PulumiPolicyEvent;
|
|
62
|
-
summaryEvent?: PulumiSummaryEvent;
|
|
63
|
-
diagnosticEvent?: { urn?: string; message?: string; severity?: string; ephemeral?: boolean };
|
|
64
|
-
preludeEvent?: { config?: Record<string, string> };
|
|
65
|
-
cancelEvent?: Record<string, never>;
|
|
66
|
-
errorEvent?: { error?: string };
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** `apitype.StepEventMetadata`. */
|
|
70
|
-
export interface PulumiEventStep {
|
|
71
|
-
op?: string;
|
|
72
|
-
urn?: string;
|
|
73
|
-
type?: string;
|
|
74
|
-
old?: PulumiEventState | null;
|
|
75
|
-
new?: PulumiEventState | null;
|
|
76
|
-
keys?: string[];
|
|
77
|
-
diffs?: string[];
|
|
78
|
-
detailedDiff?: Record<string, { diffKind?: string; inputDiff?: boolean }> | null;
|
|
79
|
-
logical?: boolean;
|
|
80
|
-
provider?: string;
|
|
81
|
-
/** plunge's per-resource timings (INTENTIUS/plunge#55), when the fork prints them. Read with {@link plungeTimingOf}. */
|
|
82
|
-
plungeTimings?: unknown[];
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** What a plunge timing times: a provider call, or a write of the resource's own record. */
|
|
86
|
-
export type PlungeTimingKind = "provider" | "record";
|
|
87
|
-
|
|
88
|
-
/** The calls plunge times (INTENTIUS/plunge#55), by kind. */
|
|
89
|
-
export const PLUNGE_TIMING_CALLS: Readonly<Record<PlungeTimingKind, readonly string[]>> = {
|
|
90
|
-
provider: ["check", "diff", "create", "read", "update", "delete"],
|
|
91
|
-
record: ["write", "delete"],
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
/** One entry of `metadata.plungeTimings` (INTENTIUS/plunge#55). */
|
|
95
|
-
export interface PlungeTiming {
|
|
96
|
-
kind: PlungeTimingKind;
|
|
97
|
-
/** For `provider`: check, diff, create, read, update or delete. For `record`: write or delete. */
|
|
98
|
-
call: string;
|
|
99
|
-
/** RFC 3339, to the nanosecond. */
|
|
100
|
-
startedAt: string;
|
|
101
|
-
/** Fractional milliseconds. */
|
|
102
|
-
durationMs: number;
|
|
103
|
-
/** Set when the call failed. A conditional record write that lost to another run counts as failed. */
|
|
104
|
-
failed?: boolean;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* `value` as a {@link PlungeTiming}, or undefined when it is not one. A
|
|
109
|
-
* `call` outside the kind's list is kept, so a newer plunge's calls still
|
|
110
|
-
* read; an entry with no kind, no start or a negative duration is dropped.
|
|
111
|
-
*/
|
|
112
|
-
export function plungeTimingOf(value: unknown): PlungeTiming | undefined {
|
|
113
|
-
if (!isObject(value)) return undefined;
|
|
114
|
-
const v = value as Record<string, unknown>;
|
|
115
|
-
if (v.kind !== "provider" && v.kind !== "record") return undefined;
|
|
116
|
-
if (typeof v.call !== "string" || v.call === "") return undefined;
|
|
117
|
-
if (typeof v.startedAt !== "string" || !Number.isFinite(Date.parse(v.startedAt))) return undefined;
|
|
118
|
-
if (typeof v.durationMs !== "number" || !Number.isFinite(v.durationMs) || v.durationMs < 0) return undefined;
|
|
119
|
-
return { kind: v.kind, call: v.call, startedAt: v.startedAt, durationMs: v.durationMs, ...(v.failed === true ? { failed: true } : {}) };
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/** `apitype.StepEventStateMetadata`. */
|
|
123
|
-
export interface PulumiEventState {
|
|
124
|
-
type?: string;
|
|
125
|
-
urn?: string;
|
|
126
|
-
custom?: boolean;
|
|
127
|
-
delete?: boolean;
|
|
128
|
-
id?: string;
|
|
129
|
-
parent?: string;
|
|
130
|
-
provider?: string;
|
|
131
|
-
inputs?: Json | null;
|
|
132
|
-
outputs?: Json | null;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/** `apitype.PolicyEvent`. */
|
|
136
|
-
export interface PulumiPolicyEvent {
|
|
137
|
-
resourceUrn?: string;
|
|
138
|
-
message?: string;
|
|
139
|
-
policyName?: string;
|
|
140
|
-
policyPackName?: string;
|
|
141
|
-
policyPackVersion?: string;
|
|
142
|
-
/** `advisory`, `mandatory`, `remediate` or `disabled`. */
|
|
143
|
-
enforcementLevel?: string;
|
|
144
|
-
severity?: string;
|
|
145
|
-
}
|
|
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
|
-
|
|
157
|
-
/** Every line of `stream` that parses as a JSON object. Other lines (a banner, a progress line) are skipped. */
|
|
158
|
-
export function pulumiEngineEvents(stream: string): PulumiEngineEvent[] {
|
|
159
|
-
const out: PulumiEngineEvent[] = [];
|
|
160
|
-
for (const line of stream.split("\n")) {
|
|
161
|
-
const text = line.trim();
|
|
162
|
-
if (!text.startsWith("{")) continue;
|
|
163
|
-
try {
|
|
164
|
-
const v = JSON.parse(text) as unknown;
|
|
165
|
-
if (isObject(v)) out.push(v as PulumiEngineEvent);
|
|
166
|
-
} catch {
|
|
167
|
-
// A line that is not one event: the stream's events are one per line.
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return out;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/** Ops that are part of a replacement (`deploy.IsReplacementStep`). */
|
|
174
|
-
const REPLACEMENT_OPS = new Set(["replace", "create-replacement", "delete-replaced", "read-replacement", "discard-replaced", "import-replacement"]);
|
|
175
|
-
|
|
176
|
-
/** The printed document's filter (`shouldShow`), with `--show-sames` on: a non-logical replacement step is left out. */
|
|
177
|
-
function shown(m: PulumiEventStep): boolean {
|
|
178
|
-
return !(m.logical !== true && REPLACEMENT_OPS.has(m.op ?? ""));
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/** A value with every blinded secret envelope read as the printed document's `"[secret]"`. */
|
|
182
|
-
function blinded(v: unknown): unknown {
|
|
183
|
-
if (Array.isArray(v)) return v.map(blinded);
|
|
184
|
-
if (!isObject(v)) return v;
|
|
185
|
-
if (v[PULUMI_SIG_KEY] === PULUMI_SECRET_SIG) return PULUMI_BLINDED_SECRET;
|
|
186
|
-
return Object.fromEntries(Object.entries(v).map(([k, x]) => [k, blinded(x)]));
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* A step state in the printed document's form (`apitype.ResourceV3`, empty
|
|
191
|
-
* fields omitted). The stream's `custom` is `omitempty`, so a state without
|
|
192
|
-
* it is a component: it reads as `custom: false`, as the printed document
|
|
193
|
-
* keeps it (#4640).
|
|
194
|
-
*/
|
|
195
|
-
function stateOf(s: PulumiEventState | null | undefined): PulumiStepState | undefined {
|
|
196
|
-
if (!s || typeof s !== "object" || Array.isArray(s)) return undefined;
|
|
197
|
-
const map = (m: Json | null | undefined): Json | undefined => (isObject(m) && Object.keys(m).length > 0 ? (blinded(m) as Json) : undefined);
|
|
198
|
-
const inputs = map(s.inputs);
|
|
199
|
-
const outputs = map(s.outputs);
|
|
200
|
-
return {
|
|
201
|
-
...(s.urn ? { urn: s.urn } : {}),
|
|
202
|
-
custom: s.custom === true,
|
|
203
|
-
...(s.delete ? { delete: true } : {}),
|
|
204
|
-
...(s.id ? { id: s.id } : {}),
|
|
205
|
-
...(s.type ? { type: s.type } : {}),
|
|
206
|
-
...(s.parent ? { parent: s.parent } : {}),
|
|
207
|
-
...(inputs ? { inputs } : {}),
|
|
208
|
-
...(outputs ? { outputs } : {}),
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/** One event step as a printed preview step (`getPreviewMetadataStep`). */
|
|
213
|
-
export function pulumiStepOfEvent(m: PulumiEventStep): PulumiStep {
|
|
214
|
-
const oldState = stateOf(m.old);
|
|
215
|
-
const newState = stateOf(m.new);
|
|
216
|
-
const detailedDiff = isObject(m.detailedDiff)
|
|
217
|
-
? Object.fromEntries(
|
|
218
|
-
Object.entries(m.detailedDiff).map(([k, d]) => [k, { ...(typeof d?.diffKind === "string" ? { kind: d.diffKind } : {}), ...(typeof d?.inputDiff === "boolean" ? { inputDiff: d.inputDiff } : {}) }]),
|
|
219
|
-
)
|
|
220
|
-
: undefined;
|
|
221
|
-
return {
|
|
222
|
-
...(m.op ? { op: m.op } : {}),
|
|
223
|
-
...(m.urn ? { urn: m.urn } : {}),
|
|
224
|
-
...(m.provider ? { provider: m.provider } : {}),
|
|
225
|
-
...(oldState ? { oldState } : {}),
|
|
226
|
-
...(newState ? { newState } : {}),
|
|
227
|
-
...(m.diffs?.length ? { diffReasons: [...m.diffs] } : {}),
|
|
228
|
-
...(m.keys?.length ? { replaceReasons: [...m.keys] } : {}),
|
|
229
|
-
...(detailedDiff ? { detailedDiff } : {}),
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
function stepsOf(events: readonly PulumiEngineEvent[], keep: (e: { metadata?: PulumiEventStep; planning?: boolean }) => boolean): PulumiStep[] {
|
|
234
|
-
const out: PulumiStep[] = [];
|
|
235
|
-
for (const e of events) {
|
|
236
|
-
const pre = e.resourcePreEvent;
|
|
237
|
-
if (!pre || !isObject(pre.metadata) || typeof pre.metadata.urn !== "string") continue;
|
|
238
|
-
if (!keep(pre) || !shown(pre.metadata)) continue;
|
|
239
|
-
out.push(pulumiStepOfEvent(pre.metadata));
|
|
240
|
-
}
|
|
241
|
-
return out;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/** The diagnostics a stream printed, as the printed document lists them (ephemeral and debug ones left out). */
|
|
245
|
-
function diagnosticsOf(events: readonly PulumiEngineEvent[]): Array<{ urn?: string; message: string; severity: string }> {
|
|
246
|
-
return events
|
|
247
|
-
.map((e) => e.diagnosticEvent)
|
|
248
|
-
.filter((d): d is NonNullable<PulumiEngineEvent["diagnosticEvent"]> => isObject(d) && d.ephemeral !== true && d.severity !== "debug" && typeof d.message === "string")
|
|
249
|
-
.map((d) => ({ ...(d.urn ? { urn: d.urn } : {}), message: d.message!, severity: d.severity ?? "info" }));
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* A streamed preview as the document `pulumi preview --json` prints without
|
|
254
|
-
* the env var: `steps`, `diagnostics` and, from the summary, `changeSummary`.
|
|
255
|
-
* What `pulumiPreviewPart` and `pulumiPreviewDigest` read.
|
|
256
|
-
*/
|
|
257
|
-
export function pulumiStreamPreview(stream: string | readonly PulumiEngineEvent[]): { steps: PulumiStep[]; diagnostics: Array<{ urn?: string; message: string; severity: string }>; changeSummary?: Record<string, number> } {
|
|
258
|
-
const events = typeof stream === "string" ? pulumiEngineEvents(stream) : stream;
|
|
259
|
-
const summary = events.map((e) => e.summaryEvent).find((x): x is PulumiSummaryEvent => isObject(x));
|
|
260
|
-
return {
|
|
261
|
-
steps: stepsOf(events, () => true),
|
|
262
|
-
diagnostics: diagnosticsOf(events),
|
|
263
|
-
...(summary?.resourceChanges ? { changeSummary: summary.resourceChanges } : {}),
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
/** The steps an `up` ran: its `resourcePreEvent`s outside any preview phase (`planning` unset). */
|
|
268
|
-
export function pulumiAppliedSteps(stream: string | readonly PulumiEngineEvent[]): PulumiStep[] {
|
|
269
|
-
const events = typeof stream === "string" ? pulumiEngineEvents(stream) : stream;
|
|
270
|
-
return stepsOf(events, (e) => e.planning !== true);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/** The URNs whose operation failed during an `up` (`resOpFailedEvent`), sorted. */
|
|
274
|
-
export function pulumiFailedUrns(stream: string | readonly PulumiEngineEvent[]): string[] {
|
|
275
|
-
const events = typeof stream === "string" ? pulumiEngineEvents(stream) : stream;
|
|
276
|
-
const urns = events.map((e) => e.resOpFailedEvent?.metadata?.urn).filter((u): u is string => typeof u === "string");
|
|
277
|
-
return [...new Set(urns)].sort();
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/** The URNs an `up` finished an operation on (`resOutputsEvent` outside a preview phase, `same` left out), sorted. */
|
|
281
|
-
export function pulumiLandedUrns(stream: string | readonly PulumiEngineEvent[]): string[] {
|
|
282
|
-
const events = typeof stream === "string" ? pulumiEngineEvents(stream) : stream;
|
|
283
|
-
const urns = events
|
|
284
|
-
.map((e) => e.resOutputsEvent)
|
|
285
|
-
.filter((o) => isObject(o) && o.planning !== true && o.metadata?.op !== "same")
|
|
286
|
-
.map((o) => o!.metadata?.urn)
|
|
287
|
-
.filter((u): u is string => typeof u === "string");
|
|
288
|
-
return [...new Set(urns)].sort();
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
/** A CrossGuard violation the stream reported. */
|
|
292
|
-
export interface PulumiPolicyViolation {
|
|
293
|
-
pack: string;
|
|
294
|
-
packVersion?: string;
|
|
295
|
-
policy: string;
|
|
296
|
-
enforcementLevel: string;
|
|
297
|
-
message: string;
|
|
298
|
-
urn?: string;
|
|
299
|
-
severity?: string;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
/** The `policyEvent` lines of a stream, `disabled` ones left out. */
|
|
303
|
-
export function pulumiPolicyEvents(stream: string | readonly PulumiEngineEvent[]): PulumiPolicyViolation[] {
|
|
304
|
-
const events = typeof stream === "string" ? pulumiEngineEvents(stream) : stream;
|
|
305
|
-
const out: PulumiPolicyViolation[] = [];
|
|
306
|
-
for (const e of events) {
|
|
307
|
-
const p = e.policyEvent;
|
|
308
|
-
if (!p || typeof p !== "object" || p.enforcementLevel === "disabled") continue;
|
|
309
|
-
out.push({
|
|
310
|
-
pack: p.policyPackName ?? "",
|
|
311
|
-
...(p.policyPackVersion ? { packVersion: p.policyPackVersion } : {}),
|
|
312
|
-
policy: p.policyName ?? "",
|
|
313
|
-
enforcementLevel: p.enforcementLevel ?? "advisory",
|
|
314
|
-
message: (p.message ?? "").trim(),
|
|
315
|
-
...(p.resourceUrn ? { urn: p.resourceUrn } : {}),
|
|
316
|
-
...(p.severity ? { severity: p.severity } : {}),
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
return out;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/** The rule id a CrossGuard policy is named by in chant's gate and overrides: `crossguard.<pack>.<policy>`. */
|
|
323
|
-
export function crossGuardRule(v: Pick<PulumiPolicyViolation, "pack" | "policy">): string {
|
|
324
|
-
return `crossguard.${v.pack}.${v.policy}`;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* CrossGuard's violations as gate findings (`@intentius/chant/gate-policy`):
|
|
329
|
-
* a `mandatory` one denies the plan, an `advisory` (or `remediate`) one is
|
|
330
|
-
* a warning. CrossGuard has no hold.
|
|
331
|
-
*/
|
|
332
|
-
export function pulumiPolicyFindings(violations: readonly PulumiPolicyViolation[]): GatePolicyFindings {
|
|
333
|
-
const where = (v: PulumiPolicyViolation): string => (v.urn ? ` (${v.urn})` : "");
|
|
334
|
-
return {
|
|
335
|
-
denials: violations.filter((v) => v.enforcementLevel === "mandatory").map((v) => ({ rule: crossGuardRule(v), message: `${v.message}${where(v)}` })),
|
|
336
|
-
holds: [],
|
|
337
|
-
warnings: violations.filter((v) => v.enforcementLevel !== "mandatory").map((v) => `${crossGuardRule(v)}: ${v.message}${where(v)}`),
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
/** What an `up` reported at its end, for the step's output. */
|
|
342
|
-
export interface PulumiApplySummary {
|
|
343
|
-
/** Counts by op, `same` included, as the engine reports them. */
|
|
344
|
-
resourceChanges: Record<string, number>;
|
|
345
|
-
durationSeconds?: number;
|
|
346
|
-
/** `succeeded`, `failed` or `cancelled`, when the engine says. */
|
|
347
|
-
result?: string;
|
|
348
|
-
maybeCorrupt?: boolean;
|
|
349
|
-
/** plunge's per-resource timings (INTENTIUS/plunge#55), by URN, in stream order, when the steps carry them. */
|
|
350
|
-
timings?: Record<string, PlungeTiming[]>;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* plunge's per-resource timings in `up --json` (INTENTIUS/plunge#55), by URN:
|
|
355
|
-
* every valid entry of `metadata.plungeTimings` on each `resOutputsEvent`
|
|
356
|
-
* and `resOpFailedEvent`, joined across a URN's events in stream order. A
|
|
357
|
-
* stock Pulumi stream gives `{}`.
|
|
358
|
-
*/
|
|
359
|
-
export function pulumiStreamTimings(stream: string | readonly PulumiEngineEvent[]): Record<string, PlungeTiming[]> {
|
|
360
|
-
const events = typeof stream === "string" ? pulumiEngineEvents(stream) : stream;
|
|
361
|
-
const timings: Record<string, PlungeTiming[]> = {};
|
|
362
|
-
for (const e of events) {
|
|
363
|
-
for (const m of [e.resOutputsEvent?.metadata, e.resOpFailedEvent?.metadata]) {
|
|
364
|
-
if (!m?.urn || !Array.isArray(m.plungeTimings)) continue;
|
|
365
|
-
const read = m.plungeTimings.map(plungeTimingOf).filter((t): t is PlungeTiming => t !== undefined);
|
|
366
|
-
if (read.length > 0) (timings[m.urn] ??= []).push(...read);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
return timings;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
/** The stream's `summaryEvent`, with plunge's timings when present. Undefined when the stream has no summary. */
|
|
373
|
-
export function pulumiStreamSummary(stream: string | readonly PulumiEngineEvent[]): PulumiApplySummary | undefined {
|
|
374
|
-
const events = typeof stream === "string" ? pulumiEngineEvents(stream) : stream;
|
|
375
|
-
const s = events.map((e) => e.summaryEvent).find((x): x is PulumiSummaryEvent => isObject(x));
|
|
376
|
-
const timings = pulumiStreamTimings(events);
|
|
377
|
-
if (!s) return undefined;
|
|
378
|
-
return {
|
|
379
|
-
resourceChanges: isObject(s.resourceChanges) ? (s.resourceChanges as Record<string, number>) : {},
|
|
380
|
-
...(typeof s.durationSeconds === "number" ? { durationSeconds: s.durationSeconds } : {}),
|
|
381
|
-
...(typeof s.result === "string" && s.result ? { result: s.result } : {}),
|
|
382
|
-
...(s.maybeCorrupt ? { maybeCorrupt: true } : {}),
|
|
383
|
-
...(Object.keys(timings).length > 0 ? { timings } : {}),
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/** The first error a stream reported (an error diagnostic or an `errorEvent`), if any. */
|
|
388
|
-
export function pulumiStreamError(stream: string | readonly PulumiEngineEvent[]): string | undefined {
|
|
389
|
-
const events = typeof stream === "string" ? pulumiEngineEvents(stream) : stream;
|
|
390
|
-
for (const e of events) {
|
|
391
|
-
if (typeof e.errorEvent?.error === "string" && e.errorEvent.error.trim()) return e.errorEvent.error.trim();
|
|
392
|
-
if (e.diagnosticEvent?.severity === "error" && typeof e.diagnosticEvent.message === "string") return e.diagnosticEvent.message.trim();
|
|
393
|
-
}
|
|
394
|
-
return undefined;
|
|
395
|
-
}
|