@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
package/src/pulumi-up.ts
DELETED
|
@@ -1,1102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `pulumi-up`, the pulumi lexicon's apply capability (#4541): a Pulumi or
|
|
3
|
-
* plunge stack as a component step that plans and applies, the way
|
|
4
|
-
* `terraform-apply` does a root. Ruling 1 on INTENTIUS/plywood#1 widened
|
|
5
|
-
* #4450 and #4476 so chant runs `up`, from an apply job holding the apply
|
|
6
|
-
* identity only; the argv go through `runApplyPulumi` and `runApplyPlunge`
|
|
7
|
-
* (`./run.ts`), each one fixed form.
|
|
8
|
-
*
|
|
9
|
-
* The step is `{ kind: "pulumi-up", dir, stack }`, with optional `member`,
|
|
10
|
-
* `config`, `engine`, `cwd`, `lockGrain` and `policyPacks`. One kind covers
|
|
11
|
-
* both engines; `pulumiMemberEngine` (`./member-engine.ts`, #4559) picks
|
|
12
|
-
* the binary from the step's `engine`, `plywood.yml`, `PULUMI_BACKEND_URL`
|
|
13
|
-
* or `Pulumi.yaml`, and the artifact records which rule answered.
|
|
14
|
-
*
|
|
15
|
-
* ## plan
|
|
16
|
-
*
|
|
17
|
-
* The preview runs with `PULUMI_ENABLE_STREAMING_JSON_PREVIEW=true` (ruling
|
|
18
|
-
* C), so one engine run gives the change set and CrossGuard's verdict
|
|
19
|
-
* (`./engine-events.ts`). On plunge it also writes `--save-plan` into a
|
|
20
|
-
* scratch directory under the OS temp dir, never the working tree, since the
|
|
21
|
-
* file holds secret ciphertext. The plan answers:
|
|
22
|
-
*
|
|
23
|
-
* - `member`: `<member>/<stack>`, the name in the wave's set digest;
|
|
24
|
-
* - `planDigest` and `changeSet` from `pulumiPreviewPart`; for a member on
|
|
25
|
-
* the resource lock grain (the step's `lockGrain`, else `ci.lockGrain`
|
|
26
|
-
* through `DeployContext.lockGrain`, else `resource` on plunge and
|
|
27
|
-
* `target` on stock Pulumi, #4552) the digest leaves `same` and `read`
|
|
28
|
-
* steps out (ruling B);
|
|
29
|
-
* - `resourceDigests`: one digest per resource the preview changes, by URN,
|
|
30
|
-
* whatever the grain (plywood#55);
|
|
31
|
-
* - `outputs` from the stack step's planned outputs;
|
|
32
|
-
* - `shape` from `pulumiPlanShape` (`./plan-shape.ts`);
|
|
33
|
-
* - `artifact`: the engine, the shape, the digest, CrossGuard's findings,
|
|
34
|
-
* and on plunge the plan file.
|
|
35
|
-
*
|
|
36
|
-
* A mandatory CrossGuard violation, or a preview Pulumi fails with its
|
|
37
|
-
* policy code, throws {@link PulumiPolicyDeniedError}: no gate opens. Any
|
|
38
|
-
* other failed preview throws, naming the engine's error.
|
|
39
|
-
*
|
|
40
|
-
* With `DeployContext.unresolvedInputs` set the member is a hole naming the
|
|
41
|
-
* upstreams it waits on, as `terraform-apply`'s `waitingRoot` is. A stand-in
|
|
42
|
-
* preview is later work.
|
|
43
|
-
*
|
|
44
|
-
* ## run
|
|
45
|
-
*
|
|
46
|
-
* - plunge, with the plan's artifact: `plunge up --plan <file> --yes --json
|
|
47
|
-
* --stack <s>`. plunge checks the plan's stamp and refuses a plan whose
|
|
48
|
-
* records moved, or one with no stamp, before anything changes (exit 40),
|
|
49
|
-
* which throws {@link PulumiPlanMovedError}: the table's moved code, 4.
|
|
50
|
-
* - stock Pulumi, with the artifact: preview again and throw core's
|
|
51
|
-
* `PlanShapeMovedError` when the fresh shape goes beyond the approved one;
|
|
52
|
-
* then `pulumi up --yes --json --stack <s>`, and compare the steps in its
|
|
53
|
-
* event stream with the approved shape (ruling A). A difference fails the
|
|
54
|
-
* step with {@link PulumiAppliedShapeError}, whose message the apply
|
|
55
|
-
* record keeps. It is failed, never moved: resources changed.
|
|
56
|
-
* - no approved plan (`chant run --components`, a release promote, a fan-out
|
|
57
|
-
* with no wave gate): preview and `up` in one go (ruling D), as
|
|
58
|
-
* `terraform-apply` does with no plan.
|
|
59
|
-
*
|
|
60
|
-
* Every engine exit goes through `pulumiExitOf` (`./exit-codes.ts`, #4553):
|
|
61
|
-
* plunge's 40 is moved, Pulumi's policy code is denied, anything else is
|
|
62
|
-
* failed with the stream's error and the URNs that landed.
|
|
63
|
-
*
|
|
64
|
-
* After `up`, the stack's outputs come from `stack output --json
|
|
65
|
-
* --show-secrets=false`, secrets as `[secret]`. Then `stack export --stack
|
|
66
|
-
* <s>` runs, its secrets are stripped, and it goes to the index store as
|
|
67
|
-
* the member's snapshot (#4546, `./stack-export-snapshot.ts`), at
|
|
68
|
-
* `<env>/<stack>__pulumi-export` on `refs/chant/snapshots` by default. The
|
|
69
|
-
* graph and the member's reads take it from there, so the member needs no
|
|
70
|
-
* checked-in `stack-export.json`. A failed export or write leaves the apply
|
|
71
|
-
* standing and says why in `exportSnapshot`.
|
|
72
|
-
*
|
|
73
|
-
* ## policy packs at base (#4613)
|
|
74
|
-
*
|
|
75
|
-
* Under a pull request or an op wave the caller sets
|
|
76
|
-
* `DeployContext.policyBase`, and the plan copies its CrossGuard packs out
|
|
77
|
-
* of that commit into the step's scratch directory before the preview
|
|
78
|
-
* (`@intentius/chant/policy-packs`): every `ci.policy.packs` entry of the
|
|
79
|
-
* declaration at base (or of `ci.policy.source`), then each step pack that
|
|
80
|
-
* is in the repository. A step pack the base lacks, or one that differs on
|
|
81
|
-
* the head, is a note on stderr and in the artifact; the base's copy is the
|
|
82
|
-
* one that runs. `run` hands `up` the same copies. A base or source that
|
|
83
|
-
* cannot be read throws, so no gate opens on a plan no policy judged.
|
|
84
|
-
*
|
|
85
|
-
* ## config
|
|
86
|
-
*
|
|
87
|
-
* `config` (a dependent's `stackOutput()` wiring) is written into a scratch
|
|
88
|
-
* copy of `Pulumi.<stack>.yaml` and passed with `--config-file`; `--config`
|
|
89
|
-
* is never used, since it saves into the working tree's file. A key with no
|
|
90
|
-
* `:` is the project's own (`<project>:<key>`).
|
|
91
|
-
*
|
|
92
|
-
* ## StackReference (#4547)
|
|
93
|
-
*
|
|
94
|
-
* `declaredReads` reads each step's export for its `StackReference`s
|
|
95
|
-
* (`./stack-references.ts`) and reports each as a read of the other
|
|
96
|
-
* `pulumi-up` step that applies the referenced stack, so core orders the
|
|
97
|
-
* reader after it, holds the reader when it fails, and leaves the reader a
|
|
98
|
-
* hole while the upstream's plan cannot say an output it reads. A reference
|
|
99
|
-
* to a stack no step applies adds no edge and is named on the plan's
|
|
100
|
-
* artifact under `stackReferences.outside`.
|
|
101
|
-
*
|
|
102
|
-
* ## releases (#4542)
|
|
103
|
-
*
|
|
104
|
-
* `releaseInputs` answers the stack's directory, so a release cut records it
|
|
105
|
-
* and a promote or rollback under the release previews and applies the
|
|
106
|
-
* recorded copy, under the release gate with that copy's plan. A stack whose
|
|
107
|
-
* backend is a file path relative to its directory is unbound: a copy
|
|
108
|
-
* elsewhere would read no state.
|
|
109
|
-
*
|
|
110
|
-
* The cut records tracked files, so a Node program's copy has no
|
|
111
|
-
* `node_modules`. Before the copy's first preview, `plan` and `run` call
|
|
112
|
-
* `prepareProgram` (`./release-copy.ts`), which runs `pulumi install`
|
|
113
|
-
* (`plunge install`) in the copy when its runtime needs one, and refuses a
|
|
114
|
-
* Node copy with no lockfile by name, since an install would take today's
|
|
115
|
-
* versions rather than the release's.
|
|
116
|
-
*
|
|
117
|
-
* A CI job's checkout has the same gap, so the same call prepares the
|
|
118
|
-
* step's own directory by the same rule (plywood#22): a Node program with
|
|
119
|
-
* no `node_modules` in its directory or above it, and a lockfile beside its
|
|
120
|
-
* package.json, gets one `<engine> install` before the job's first engine
|
|
121
|
-
* run; with no lockfile the step refuses by name.
|
|
122
|
-
*
|
|
123
|
-
* ## review stacks (#4609)
|
|
124
|
-
*
|
|
125
|
-
* When `DeployContext.env` is a pull request's environment `pr-<n>` (`chant
|
|
126
|
-
* components pr-env up`), the step applies its review stack instead of its
|
|
127
|
-
* own: the step's stack with the last segment replaced by `pr-<n>` (or
|
|
128
|
-
* `pr-<n>-<reviewSuffix>`), so `acme/shop/dev` becomes `acme/shop/pr-12`.
|
|
129
|
-
* Before the first preview, `plan` runs `stack init <pr-stack> --no-select
|
|
130
|
-
* --copy-config-from <template>` (`initReviewStack`, `./review-stack.ts`),
|
|
131
|
-
* where the template is `CHANT_ENV_TEMPLATE`'s stack when it names a stack of
|
|
132
|
-
* this project (`<project>/<stack>`, plywood's `review_stacks.template`),
|
|
133
|
-
* else the step's own stack. A stack that exists already is updated. The
|
|
134
|
-
* plan gives core the stack's `location`, `<engine>:<dir>#<stack>`, which
|
|
135
|
-
* `pr-env up` keeps on the environment's record and `pr-env down` and the
|
|
136
|
-
* TTL sweep read back to destroy and remove it (`reviewStackTeardown`).
|
|
137
|
-
*/
|
|
138
|
-
|
|
139
|
-
import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
140
|
-
import { tmpdir } from "node:os";
|
|
141
|
-
import { basename, isAbsolute, join, relative, resolve } from "node:path";
|
|
142
|
-
import type { ChangeSetPart } from "@intentius/chant/change-set";
|
|
143
|
-
import type {
|
|
144
|
-
Capability,
|
|
145
|
-
CapabilityPlan,
|
|
146
|
-
DeclaredRead,
|
|
147
|
-
DeclaredReadMember,
|
|
148
|
-
DeclaredReadsContext,
|
|
149
|
-
DeployContext,
|
|
150
|
-
ReleaseInputs,
|
|
151
|
-
ReleaseInputsContext,
|
|
152
|
-
ReleaseInputsUnbound,
|
|
153
|
-
} from "@intentius/chant/components/capability";
|
|
154
|
-
import { PlanShapeMovedError, type PlanShape } from "@intentius/chant/components/covered-round";
|
|
155
|
-
import type { GatePolicyFindings } from "@intentius/chant/gate-policy";
|
|
156
|
-
import { computePlanDigest } from "@intentius/chant/lifecycle/plan-digest";
|
|
157
|
-
import type { SnapshotStore } from "@intentius/chant/lifecycle/snapshot-store";
|
|
158
|
-
import { parseYAML } from "@intentius/chant/yaml";
|
|
159
|
-
import { pulumiPreviewPart, pulumiResourceDigests } from "./change-set";
|
|
160
|
-
import {
|
|
161
|
-
PULUMI_STREAMING_PREVIEW_ENV,
|
|
162
|
-
pulumiAppliedSteps,
|
|
163
|
-
pulumiFailedUrns,
|
|
164
|
-
pulumiLandedUrns,
|
|
165
|
-
pulumiPolicyEvents,
|
|
166
|
-
pulumiPolicyFindings,
|
|
167
|
-
pulumiStreamError,
|
|
168
|
-
pulumiStreamPreview,
|
|
169
|
-
pulumiStreamSummary,
|
|
170
|
-
pulumiStreamTimings,
|
|
171
|
-
type PulumiApplySummary,
|
|
172
|
-
} from "./engine-events";
|
|
173
|
-
import { CHANT_EXIT } from "@intentius/chant/exit-codes";
|
|
174
|
-
import { pulumiExitOf } from "./exit-codes";
|
|
175
|
-
import { pulumiMemberEngine, type PulumiMemberEngine, type PulumiMemberEngineSource } from "./member-engine";
|
|
176
|
-
import { ciEngineDir, ciRelease, CI_ENGINE_ROOT } from "./ci-setup";
|
|
177
|
-
import { pulumiMemberPlannedOutputs } from "./member-outputs";
|
|
178
|
-
import type { PulumiOutputChange } from "./planned-output-changes";
|
|
179
|
-
import { pulumiPlanShape, pulumiShapeDifferences } from "./plan-shape";
|
|
180
|
-
import { pulumiLockRows } from "./lock-rows";
|
|
181
|
-
import { stackRowKey } from "@intentius/chant/lifecycle/lock-rows";
|
|
182
|
-
import { pulumiTraceFacts } from "./trace-facts";
|
|
183
|
-
import {
|
|
184
|
-
defaultPlungeRunner,
|
|
185
|
-
defaultPulumiRunner,
|
|
186
|
-
engineRunnerAt,
|
|
187
|
-
plungeUpArgs,
|
|
188
|
-
pulumiMemberStackOutputs,
|
|
189
|
-
pulumiRunFailure,
|
|
190
|
-
pulumiUpArgs,
|
|
191
|
-
pulumiUpPreviewArgs,
|
|
192
|
-
memberExportOf,
|
|
193
|
-
runAllowedPlunge,
|
|
194
|
-
runAllowedPulumi,
|
|
195
|
-
runApplyPlunge,
|
|
196
|
-
runApplyPulumi,
|
|
197
|
-
type PulumiPolicyPack,
|
|
198
|
-
type PulumiRunner,
|
|
199
|
-
} from "./run";
|
|
200
|
-
import type { PulumiStep } from "./change-set";
|
|
201
|
-
import { writePulumiExportSnapshot, type PulumiExportWrite } from "./stack-export-snapshot";
|
|
202
|
-
import { pointerSegment, pulumiStackReferences, stackReferenceOwner } from "./stack-references";
|
|
203
|
-
import { isObject } from "./values";
|
|
204
|
-
import { prepareProgram } from "./release-copy";
|
|
205
|
-
import { initReviewStack, reviewConfigSource, reviewStackFor, reviewStackLocation } from "./review-stack";
|
|
206
|
-
|
|
207
|
-
/** The lock grain values of `ci.lockGrain` (#4552's ruling A). */
|
|
208
|
-
export type PulumiLockGrain = "target" | "resource" | "repo";
|
|
209
|
-
|
|
210
|
-
/** The `pulumi-up` step's input. */
|
|
211
|
-
export interface PulumiUpStepInput {
|
|
212
|
-
/** The stack's directory, where `Pulumi.yaml` is. Relative paths resolve against `cwd`. */
|
|
213
|
-
dir: string;
|
|
214
|
-
/** The stack to preview and apply, passed as `--stack`. */
|
|
215
|
-
stack: string;
|
|
216
|
-
/** The member's name in the set digest. Default: `Pulumi.yaml`'s `name`, else the directory's name. */
|
|
217
|
-
member?: string;
|
|
218
|
-
/** Stack config values, written into a scratch copy of `Pulumi.<stack>.yaml` (never `--config`). */
|
|
219
|
-
config?: Record<string, unknown>;
|
|
220
|
-
/** `pulumi` or `plunge`; see `pulumiMemberEngine`. */
|
|
221
|
-
engine?: PulumiMemberEngine;
|
|
222
|
-
/**
|
|
223
|
-
* The stack's backend URL (INTENTIUS/plywood#22), such as
|
|
224
|
-
* `plunge+s3://...` or `s3://...`: every engine command the step runs
|
|
225
|
-
* (preview, up, the stack output and export reads, a review stack's init)
|
|
226
|
-
* gets it as `PULUMI_BACKEND_URL`, over the job's own. It also answers the
|
|
227
|
-
* engine where `pulumiMemberEngine` would read `PULUMI_BACKEND_URL`.
|
|
228
|
-
* Absent: the job's `PULUMI_BACKEND_URL` or `Pulumi.yaml`'s, as before.
|
|
229
|
-
*/
|
|
230
|
-
backend?: string;
|
|
231
|
-
/**
|
|
232
|
-
* The engine release this stack is pinned to (#4592): the step runs
|
|
233
|
-
* `<engineRoot>/<engine>-<engineVersion>/<engine>`, the path the pulumi
|
|
234
|
-
* lexicon's install lines write (`pulumiInstallLine`, `plungeInstallLine`,
|
|
235
|
-
* `ciEngineDir`), instead of the binary on PATH. A semver such as
|
|
236
|
-
* `3.272.0`, or for plunge its own release such as `0.1.0`. Absent: the
|
|
237
|
-
* binary on PATH, as before.
|
|
238
|
-
*/
|
|
239
|
-
engineVersion?: string;
|
|
240
|
-
/** Where the versioned installs live, as the install lines' `root` (#4592). Default `/opt/chant`. Needs `engineVersion`. */
|
|
241
|
-
engineRoot?: string;
|
|
242
|
-
/** Where a relative `dir` resolves from. Default: the process's working directory. */
|
|
243
|
-
cwd?: string;
|
|
244
|
-
/** The member's lock grain (#4552), over `ci.lockGrain`. Default: `ci.lockGrain`, else `resource` on plunge, `target` on stock Pulumi. */
|
|
245
|
-
lockGrain?: PulumiLockGrain;
|
|
246
|
-
/**
|
|
247
|
-
* CrossGuard packs for the preview and `up` (ruling 7). Under a pull
|
|
248
|
-
* request or an op wave (`DeployContext.policyBase`, #4613) each one in
|
|
249
|
-
* the repository is read at base, and `ci.policy.packs` at base is added.
|
|
250
|
-
*/
|
|
251
|
-
policyPacks?: PulumiPolicyPack[];
|
|
252
|
-
/**
|
|
253
|
-
* The outputs of other stacks this stack's program reads through
|
|
254
|
-
* `StackReference` (#4547), by the reference's name, then output. Core
|
|
255
|
-
* writes them from `declaredReads` as `stackOutput()` references, so the
|
|
256
|
-
* stack plans after the ones it reads and waits while their plans cannot
|
|
257
|
-
* say a value. Never passed to the engine: the program reads them itself.
|
|
258
|
-
*/
|
|
259
|
-
stackReferences?: Record<string, Record<string, unknown>>;
|
|
260
|
-
/**
|
|
261
|
-
* In a pull request's environment (#4609), the review stack is
|
|
262
|
-
* `pr-<n>-<reviewSuffix>` rather than `pr-<n>`: lowercase letters, digits
|
|
263
|
-
* and `-`, as plywood's `review_stacks.name` allows. Ignored elsewhere.
|
|
264
|
-
*/
|
|
265
|
-
reviewSuffix?: string;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/** What `run` returns. */
|
|
269
|
-
export interface PulumiUpStepOutput {
|
|
270
|
-
/** `<member>/<stack>`. */
|
|
271
|
-
member: string;
|
|
272
|
-
stack: string;
|
|
273
|
-
engine: PulumiMemberEngine;
|
|
274
|
-
planDigest: string;
|
|
275
|
-
/** Whether `run` applied the plan the wave handed it, rather than one it made itself. */
|
|
276
|
-
fromWavePlan: boolean;
|
|
277
|
-
/** `stack output --json --show-secrets=false` after `up`, secrets as `[secret]`. */
|
|
278
|
-
outputs: Record<string, unknown>;
|
|
279
|
-
/** The `summaryEvent` of `up --json`, with plunge's timings when present. */
|
|
280
|
-
summary?: PulumiApplySummary;
|
|
281
|
-
/** CrossGuard's findings from the preview the apply ran under. */
|
|
282
|
-
policy?: GatePolicyFindings;
|
|
283
|
-
/** The stack export written to the index store after `up` (#4546), or why it was not. */
|
|
284
|
-
exportSnapshot?: PulumiExportWrite;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
/** What `plan` hands `run` through `DeployContext.plans[member]`. */
|
|
288
|
-
export interface PulumiUpArtifact {
|
|
289
|
-
kind: "pulumi-up";
|
|
290
|
-
member: string;
|
|
291
|
-
stack: string;
|
|
292
|
-
engine: PulumiMemberEngine;
|
|
293
|
-
/** The rule `pulumiMemberEngine` answered with (#4559), for the plan output. */
|
|
294
|
-
engineSource: PulumiMemberEngineSource;
|
|
295
|
-
engineBecause: string;
|
|
296
|
-
planDigest: string;
|
|
297
|
-
shape: PlanShape;
|
|
298
|
-
/** The scratch directory holding the plan file and config copy. */
|
|
299
|
-
scratch: string;
|
|
300
|
-
/** plunge's saved plan. plunge only. */
|
|
301
|
-
planFile?: string;
|
|
302
|
-
/** The scratch copy of the stack's config, when the step has `config`. */
|
|
303
|
-
configFile?: string;
|
|
304
|
-
/** CrossGuard's findings from the plan's preview. */
|
|
305
|
-
policy: GatePolicyFindings;
|
|
306
|
-
/**
|
|
307
|
-
* The packs the preview ran when they were read at base (#4613): the
|
|
308
|
-
* commit, each pack's copy under `scratch` and where it came from, the
|
|
309
|
-
* notes on step packs left out or read from base, and the shared source
|
|
310
|
-
* `ci.policy.packs` came from. `run` passes the same copies to `up`.
|
|
311
|
-
*/
|
|
312
|
-
policyPacks?: PulumiUpPolicyPacks;
|
|
313
|
-
/**
|
|
314
|
-
* The stack's `StackReference`s (#4547): `read`, wired to another step of
|
|
315
|
-
* the project, and `outside`, which add no edge, each with why.
|
|
316
|
-
* `lastUpdate` is when the stack last updated, from its export's
|
|
317
|
-
* `deployment.manifest.time` (#4617): the pull request note compares it
|
|
318
|
-
* with the control repo's record of the owner's last apply to mark each
|
|
319
|
-
* outside reference stale, current or unknown.
|
|
320
|
-
*/
|
|
321
|
-
stackReferences?: { read: string[]; outside: { name: string; why: string }[]; lastUpdate?: string };
|
|
322
|
-
/**
|
|
323
|
-
* Each stack output's verdict from the preview (#4635,
|
|
324
|
-
* `./planned-output-changes.ts`): `changing` and `untraced` ones are
|
|
325
|
-
* unknown to the stacks that read them, `unchanged` ones keep the
|
|
326
|
-
* export's value. Absent when the preview planned nothing to apply.
|
|
327
|
-
*/
|
|
328
|
-
plannedOutputs?: PulumiOutputChange[];
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
/** The CrossGuard packs a plan read at base (#4613). */
|
|
332
|
-
export interface PulumiUpPolicyPacks {
|
|
333
|
-
base: string;
|
|
334
|
-
packs: Array<{ dir: string; config?: string; from: "declaration" | "step"; name: string }>;
|
|
335
|
-
notes: string[];
|
|
336
|
-
source?: { repo: string; ref: string; commit: string; path: string };
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* The packs a preview runs (#4613). With `ctx.policyBase` each step pack in
|
|
341
|
-
* the repository and every `ci.policy.packs` entry is copied from base into
|
|
342
|
-
* `scratch`, and the notes say which step packs did not run as the head has
|
|
343
|
-
* them. Without it, the step's packs as they stand. Throws when the base or
|
|
344
|
-
* the policy source cannot be read: the preview then does not run.
|
|
345
|
-
*/
|
|
346
|
-
async function policyPacksFor(ctx: DeployContext, r: Pick<Resolved, "dir" | "member">, input: PulumiUpStepInput, scratch: string): Promise<{ packs: PulumiPolicyPack[]; read?: PulumiUpPolicyPacks }> {
|
|
347
|
-
const own = input.policyPacks ?? [];
|
|
348
|
-
if (!ctx.policyBase) return { packs: own };
|
|
349
|
-
let mod: typeof import("@intentius/chant/policy-packs") | undefined;
|
|
350
|
-
try {
|
|
351
|
-
mod = await import("@intentius/chant/policy-packs");
|
|
352
|
-
} catch {
|
|
353
|
-
mod = undefined;
|
|
354
|
-
}
|
|
355
|
-
if (!mod) throw new Error(`pulumi-up: "${r.member}": the policy packs are read at base ${ctx.policyBase.slice(0, 12)}, and this chant has no reader for them; update @intentius/chant`);
|
|
356
|
-
const got = await mod.policyPacksAtBase({ cwd: r.dir, base: ctx.policyBase, stepPacks: own, tmp: scratch });
|
|
357
|
-
if ("error" in got) throw new Error(`pulumi-up: "${r.member}": ${got.error}, so the preview did not run`);
|
|
358
|
-
for (const note of got.notes) console.error(`pulumi-up: "${r.member}": ${note}`);
|
|
359
|
-
if (got.source) console.error(`pulumi-up: "${r.member}": ci.policy.packs read from ${got.source.repo}@${got.source.ref} at commit ${got.source.commit}`);
|
|
360
|
-
const read: PulumiUpPolicyPacks = {
|
|
361
|
-
base: got.base,
|
|
362
|
-
packs: got.packs.map((p) => ({ dir: p.dir, ...(p.config ? { config: p.config } : {}), from: p.from, name: p.name })),
|
|
363
|
-
notes: got.notes,
|
|
364
|
-
...(got.source ? { source: { ...got.source } } : {}),
|
|
365
|
-
};
|
|
366
|
-
return { packs: got.packs.map((p) => ({ dir: p.dir, ...(p.config ? { config: p.config } : {}) })), read };
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
/** plunge refused a saved plan whose records moved, or one with no stamp (exit 40). `planMoved` is core's moved mark. */
|
|
370
|
-
export class PulumiPlanMovedError extends Error {
|
|
371
|
-
readonly planMoved = true;
|
|
372
|
-
constructor(
|
|
373
|
-
public readonly member: string,
|
|
374
|
-
message: string,
|
|
375
|
-
) {
|
|
376
|
-
super(message);
|
|
377
|
-
this.name = "PulumiPlanMovedError";
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
/** CrossGuard denied the plan: a mandatory violation, or the engine's policy exit. No gate opens. */
|
|
382
|
-
export class PulumiPolicyDeniedError extends Error {
|
|
383
|
-
readonly policyDenied = true;
|
|
384
|
-
/** The table's code for it (#4553, ruling B: 7 everywhere). */
|
|
385
|
-
readonly exitCode = CHANT_EXIT.denied;
|
|
386
|
-
constructor(
|
|
387
|
-
public readonly member: string,
|
|
388
|
-
public readonly findings: GatePolicyFindings,
|
|
389
|
-
detail?: string,
|
|
390
|
-
) {
|
|
391
|
-
const denied = findings.denials.map((d) => `${d.rule}: ${d.message}`).join("; ");
|
|
392
|
-
super(`"${member}": CrossGuard denied the plan${denied ? `: ${denied}` : ""}${detail ? ` (${detail})` : ""}`);
|
|
393
|
-
this.name = "PulumiPolicyDeniedError";
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* A stock `pulumi up` ran steps the approved shape does not hold (ruling A).
|
|
399
|
-
* The update has run, so this is a failure, not a moved plan: the step fails
|
|
400
|
-
* and the differences land on the apply record through the message.
|
|
401
|
-
*/
|
|
402
|
-
export class PulumiAppliedShapeError extends Error {
|
|
403
|
-
constructor(
|
|
404
|
-
public readonly member: string,
|
|
405
|
-
public readonly differences: string[],
|
|
406
|
-
public readonly summary?: PulumiApplySummary,
|
|
407
|
-
) {
|
|
408
|
-
super(`"${member}": pulumi up ran steps the approved plan did not hold: ${differences.join("; ")}. The update ran; check the stack and plan it again.`);
|
|
409
|
-
this.name = "PulumiAppliedShapeError";
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* An `up` that failed (#4553's failed outcome). It carries the stream's
|
|
415
|
-
* summary, plunge's per-resource timings included (#4579), so the run record
|
|
416
|
-
* and the trace (`./trace-facts.ts` reads `member` and `summary` off the
|
|
417
|
-
* error) keep what ran before it stopped.
|
|
418
|
-
*/
|
|
419
|
-
export class PulumiUpFailedError extends Error {
|
|
420
|
-
constructor(
|
|
421
|
-
public readonly member: string,
|
|
422
|
-
message: string,
|
|
423
|
-
public readonly summary?: PulumiApplySummary,
|
|
424
|
-
) {
|
|
425
|
-
super(message);
|
|
426
|
-
this.name = "PulumiUpFailedError";
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
/** A stock Pulumi member set to the resource grain (#4552): the backend's stack lock already orders its updates. */
|
|
431
|
-
export class PulumiResourceGrainRefusedError extends Error {
|
|
432
|
-
constructor(public readonly member: string) {
|
|
433
|
-
super(`"${member}": the resource lock grain needs plunge; a stock Pulumi stack keeps the stack grain, since its backend's stack lock orders updates (ci.lockGrain: target)`);
|
|
434
|
-
this.name = "PulumiResourceGrainRefusedError";
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
/** The default lock grain for an engine (#4552's design): resource on plunge, the stack (target) on stock Pulumi. */
|
|
439
|
-
export function pulumiDefaultLockGrain(engine: PulumiMemberEngine): PulumiLockGrain {
|
|
440
|
-
return engine === "plunge" ? "resource" : "target";
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
/** Runners and scratch, injectable so the tests run no binary. */
|
|
444
|
-
export interface PulumiUpOptions {
|
|
445
|
-
run?: PulumiRunner;
|
|
446
|
-
plunge?: PulumiRunner;
|
|
447
|
-
/** The runner for a pinned binary (#4592), by its path. Default: {@link engineRunnerAt}. */
|
|
448
|
-
runAt?: (bin: string) => PulumiRunner;
|
|
449
|
-
/** The job environment the engine is picked from. Default: `process.env`. */
|
|
450
|
-
env?: Record<string, string | undefined>;
|
|
451
|
-
/** Where scratch directories go. Default: the OS temp dir. */
|
|
452
|
-
tmp?: string;
|
|
453
|
-
/** The index store the stack export goes to after `up` and the prior export is read from (#4546). Default: the project's; `null` writes nothing and reads the checked-in file only. */
|
|
454
|
-
snapshots?: SnapshotStore | null;
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
const STREAMING = { [PULUMI_STREAMING_PREVIEW_ENV]: "true" };
|
|
458
|
-
|
|
459
|
-
function stackDir(input: PulumiUpStepInput): string {
|
|
460
|
-
return isAbsolute(input.dir) ? input.dir : resolve(input.cwd ?? process.cwd(), input.dir);
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
function readProject(dir: string): Record<string, unknown> | undefined {
|
|
464
|
-
for (const name of ["Pulumi.yaml", "Pulumi.yml"]) {
|
|
465
|
-
const file = join(dir, name);
|
|
466
|
-
if (!existsSync(file)) continue;
|
|
467
|
-
try {
|
|
468
|
-
return parseYAML(readFileSync(file, "utf-8"));
|
|
469
|
-
} catch {
|
|
470
|
-
return undefined;
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
return undefined;
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
function requireInput(input: PulumiUpStepInput): void {
|
|
477
|
-
if (typeof input?.dir !== "string" || input.dir === "") throw new Error('pulumi-up: the step needs "dir", the directory holding Pulumi.yaml');
|
|
478
|
-
if (typeof input.stack !== "string" || input.stack === "" || input.stack.startsWith("-")) throw new Error('pulumi-up: the step needs "stack", the stack to apply');
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
/** `<member>/<stack>`: the member's name in the wave's set digest. */
|
|
482
|
-
export function pulumiUpMember(input: PulumiUpStepInput): string {
|
|
483
|
-
const dir = stackDir(input);
|
|
484
|
-
const named = input.member ?? (readProject(dir)?.name as string | undefined) ?? basename(dir);
|
|
485
|
-
return `${named}/${input.stack}`;
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
/**
|
|
489
|
-
* The stack's config with `config` written over it, as the text of a
|
|
490
|
-
* `Pulumi.<stack>.yaml` (JSON, which YAML reads). A key with no `:` is the
|
|
491
|
-
* project's own. A value left `undefined` or `null` is not written.
|
|
492
|
-
*/
|
|
493
|
-
export function pulumiScratchConfig(dir: string, stack: string, config: Record<string, unknown>): string {
|
|
494
|
-
const project = readProject(dir)?.name;
|
|
495
|
-
const file = join(dir, `Pulumi.${stack}.yaml`);
|
|
496
|
-
let doc: Record<string, unknown> = {};
|
|
497
|
-
if (existsSync(file)) {
|
|
498
|
-
try {
|
|
499
|
-
doc = parseYAML(readFileSync(file, "utf-8")) ?? {};
|
|
500
|
-
} catch (err) {
|
|
501
|
-
throw new Error(`pulumi-up: ${file} does not read as YAML, so its config cannot be copied: ${err instanceof Error ? err.message : String(err)}`);
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
const merged: Record<string, unknown> = { ...((doc.config as Record<string, unknown> | undefined) ?? {}) };
|
|
505
|
-
for (const [key, value] of Object.entries(config)) {
|
|
506
|
-
if (value === undefined || value === null) continue;
|
|
507
|
-
const full = key.includes(":") || typeof project !== "string" ? key : `${project}:${key}`;
|
|
508
|
-
merged[full] = value;
|
|
509
|
-
}
|
|
510
|
-
return `${JSON.stringify({ ...doc, config: merged }, null, 2)}\n`;
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
/** The variable `pr-env up` sets to `ci.prEnvironment.template` (core's `PR_ENV_TEMPLATE_VAR`). */
|
|
514
|
-
export const PR_ENV_TEMPLATE_VARIABLE = "CHANT_ENV_TEMPLATE";
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* The step as it applies in `env` (#4609): with its review stack in place of
|
|
518
|
-
* its own stack in a pull request's environment, and the stack it copies its
|
|
519
|
-
* config from. The step unchanged, with no review, anywhere else.
|
|
520
|
-
*/
|
|
521
|
-
export function pulumiReviewStep(input: PulumiUpStepInput, env: string | undefined, template?: string): { step: PulumiUpStepInput; review?: { stack: string; copyConfigFrom?: string } } {
|
|
522
|
-
requireInput(input);
|
|
523
|
-
const stack = reviewStackFor(input.stack, env, input.reviewSuffix);
|
|
524
|
-
if (!stack) return { step: input };
|
|
525
|
-
const project = readProject(stackDir(input))?.name;
|
|
526
|
-
const copyConfigFrom = reviewConfigSource({ stack: input.stack, ...(typeof project === "string" ? { project } : {}) }, template, stack);
|
|
527
|
-
return { step: { ...input, stack }, review: { stack, ...(copyConfigFrom ? { copyConfigFrom } : {}) } };
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
function templateOf(opts: PulumiUpOptions): string | undefined {
|
|
531
|
-
const v = (opts.env ?? process.env)[PR_ENV_TEMPLATE_VARIABLE];
|
|
532
|
-
return typeof v === "string" && v !== "" ? v : undefined;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
/** The review stack's location on the environment's record: `<engine>:<dir>#<stack>`, `dir` relative to the working directory core runs in. */
|
|
536
|
-
function locationOf(r: Resolved, stack: string): string {
|
|
537
|
-
return reviewStackLocation(r.engine, relative(process.cwd(), r.dir) || ".", stack);
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
/** A plan file name with nothing a path could read into. */
|
|
541
|
-
const fileSafe = (s: string): string => s.replace(/[^A-Za-z0-9._-]+/g, "_");
|
|
542
|
-
|
|
543
|
-
/** What one streamed preview gave. */
|
|
544
|
-
interface StackPreview {
|
|
545
|
-
part: ChangeSetPart;
|
|
546
|
-
preview: { steps: PulumiStep[] };
|
|
547
|
-
shape: PlanShape;
|
|
548
|
-
policy: GatePolicyFindings;
|
|
549
|
-
prior: unknown;
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
interface Resolved {
|
|
553
|
-
dir: string;
|
|
554
|
-
member: string;
|
|
555
|
-
engine: PulumiMemberEngine;
|
|
556
|
-
/** The pinned binary's absolute path (#4592), when the step names `engineVersion`. */
|
|
557
|
-
engineBin?: string;
|
|
558
|
-
engineSource: PulumiMemberEngineSource;
|
|
559
|
-
engineBecause: string;
|
|
560
|
-
grain: PulumiLockGrain;
|
|
561
|
-
/** The step's `backend`, every engine command's `PULUMI_BACKEND_URL`. */
|
|
562
|
-
backend?: string;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
/** The environment the engine is picked from: the job's, with the step's backend as `PULUMI_BACKEND_URL`. */
|
|
566
|
-
function engineEnv(input: Pick<PulumiUpStepInput, "backend">, opts: PulumiUpOptions): { env?: Record<string, string | undefined> } {
|
|
567
|
-
if (input.backend === undefined) return opts.env ? { env: opts.env } : {};
|
|
568
|
-
return { env: { ...(opts.env ?? process.env), PULUMI_BACKEND_URL: input.backend } };
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
/** `run` with `PULUMI_BACKEND_URL` set to the step's backend over whatever env the call passes. */
|
|
572
|
-
function withBackend(run: PulumiRunner, backend: string): PulumiRunner {
|
|
573
|
-
return (args, o) => run(args, { ...o, env: { ...(o.env ?? {}), PULUMI_BACKEND_URL: backend } });
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
function resolveStep(input: PulumiUpStepInput, opts: PulumiUpOptions, declared?: PulumiLockGrain): Resolved {
|
|
577
|
-
requireInput(input);
|
|
578
|
-
if (input.backend !== undefined && (typeof input.backend !== "string" || input.backend.trim() === "")) {
|
|
579
|
-
throw new Error('pulumi-up: "backend" is the stack\'s backend URL, such as plunge+s3://<bucket> or s3://<bucket>');
|
|
580
|
-
}
|
|
581
|
-
const dir = stackDir(input);
|
|
582
|
-
const member = pulumiUpMember(input);
|
|
583
|
-
const picked = pulumiMemberEngine(dir, input.engine, engineEnv(input, opts));
|
|
584
|
-
// #4552: the step's own grain, else ci.lockGrain as the caller read it at base, else the engine's default.
|
|
585
|
-
const grain = input.lockGrain ?? declared ?? pulumiDefaultLockGrain(picked.engine);
|
|
586
|
-
if (grain === "resource" && picked.engine === "pulumi") throw new PulumiResourceGrainRefusedError(member);
|
|
587
|
-
const engineBin = pulumiUpEngineBin(input, picked.engine);
|
|
588
|
-
return { dir, member, engine: picked.engine, ...(engineBin ? { engineBin } : {}), engineSource: picked.source, engineBecause: picked.because, grain, ...(input.backend ? { backend: input.backend } : {}) };
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
/**
|
|
592
|
-
* The binary a step pinned with `engineVersion` runs (#4592): the versioned
|
|
593
|
-
* path the install lines write. Undefined without `engineVersion`, so the
|
|
594
|
-
* binary on PATH runs. A version or root a shell or path would read as
|
|
595
|
-
* more is refused, as the install lines refuse it.
|
|
596
|
-
*/
|
|
597
|
-
export function pulumiUpEngineBin(input: Pick<PulumiUpStepInput, "engineVersion" | "engineRoot">, engine: PulumiMemberEngine): string | undefined {
|
|
598
|
-
if (input.engineVersion === undefined) {
|
|
599
|
-
if (input.engineRoot !== undefined) throw new Error('pulumi-up: "engineRoot" needs "engineVersion", the release installed under it');
|
|
600
|
-
return undefined;
|
|
601
|
-
}
|
|
602
|
-
try {
|
|
603
|
-
ciRelease(engine, input.engineVersion);
|
|
604
|
-
return `${ciEngineDir(engine, input.engineVersion, input.engineRoot ?? CI_ENGINE_ROOT)}/${engine}`;
|
|
605
|
-
} catch (err) {
|
|
606
|
-
throw new Error(`pulumi-up: ${err instanceof Error ? err.message : String(err)}`);
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
/** The `run` and `plunge` options for the stack output and export reads: the pinned binary's for both when the step names one (#4592), else the caller's. */
|
|
611
|
-
function runnerOptions(r: Pick<Resolved, "engineBin" | "backend">, opts: PulumiUpOptions): { run?: PulumiRunner; plunge?: PulumiRunner } {
|
|
612
|
-
if (r.engineBin || r.backend) {
|
|
613
|
-
const { pulumi, plunge } = runnersFor(r, opts);
|
|
614
|
-
return { run: pulumi, plunge };
|
|
615
|
-
}
|
|
616
|
-
return { ...(opts.run ? { run: opts.run } : {}), ...(opts.plunge ? { plunge: opts.plunge } : {}) };
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
/** The runners a resolved step uses: the pinned binary's when it names one, else the options' or the PATH default. */
|
|
620
|
-
function runnersFor(r: Pick<Resolved, "engineBin" | "backend">, opts: PulumiUpOptions): { pulumi: PulumiRunner; plunge: PulumiRunner } {
|
|
621
|
-
let out: { pulumi: PulumiRunner; plunge: PulumiRunner };
|
|
622
|
-
if (r.engineBin) {
|
|
623
|
-
const pinned = opts.runAt ? opts.runAt(r.engineBin) : engineRunnerAt(r.engineBin);
|
|
624
|
-
out = { pulumi: pinned, plunge: pinned };
|
|
625
|
-
} else {
|
|
626
|
-
out = { pulumi: opts.run ?? defaultPulumiRunner, plunge: opts.plunge ?? defaultPlungeRunner };
|
|
627
|
-
}
|
|
628
|
-
// plywood#22: the step's backend reaches every command, whichever call site runs it.
|
|
629
|
-
return r.backend ? { pulumi: withBackend(out.pulumi, r.backend), plunge: withBackend(out.plunge, r.backend) } : out;
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
/** The scratch directory, the config copy in it and plunge's plan file path. */
|
|
633
|
-
function scratchFor(r: Resolved, input: PulumiUpStepInput, opts: PulumiUpOptions): { scratch: string; configFile?: string; planFile?: string } {
|
|
634
|
-
const scratch = mkdtempSync(join(opts.tmp ?? tmpdir(), "chant-pulumi-up-"));
|
|
635
|
-
let configFile: string | undefined;
|
|
636
|
-
if (input.config && Object.keys(input.config).length > 0) {
|
|
637
|
-
configFile = join(scratch, `Pulumi.${input.stack}.yaml`);
|
|
638
|
-
writeFileSync(configFile, pulumiScratchConfig(r.dir, input.stack, input.config), { mode: 0o600 });
|
|
639
|
-
}
|
|
640
|
-
const planFile = r.engine === "plunge" ? join(scratch, `${fileSafe(r.member)}.plan.json`) : undefined;
|
|
641
|
-
return { scratch, ...(configFile ? { configFile } : {}), ...(planFile ? { planFile } : {}) };
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
function dropScratch(scratch: string | undefined): void {
|
|
645
|
-
if (!scratch) return;
|
|
646
|
-
try {
|
|
647
|
-
rmSync(scratch, { recursive: true, force: true });
|
|
648
|
-
} catch {
|
|
649
|
-
// A scratch dir that stays behind holds nothing a later run reads.
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
/** The streamed preview, as part, shape and CrossGuard findings. Throws for a failed preview or a denial. */
|
|
654
|
-
async function previewStack(
|
|
655
|
-
ctx: DeployContext,
|
|
656
|
-
r: Resolved,
|
|
657
|
-
input: PulumiUpStepInput,
|
|
658
|
-
opts: PulumiUpOptions,
|
|
659
|
-
files: { configFile?: string; planFile?: string; policyPacks?: readonly PulumiPolicyPack[] },
|
|
660
|
-
): Promise<StackPreview> {
|
|
661
|
-
const targets = ctx.targets && ctx.targets.length > 0 ? ctx.targets : undefined;
|
|
662
|
-
// #4613: the packs read at base when the caller gave them, else the step's as they stand.
|
|
663
|
-
const packs = files.policyPacks ?? input.policyPacks ?? [];
|
|
664
|
-
const args = pulumiUpPreviewArgs({
|
|
665
|
-
stack: input.stack,
|
|
666
|
-
...(files.planFile ? { savePlan: files.planFile } : {}),
|
|
667
|
-
...(files.configFile ? { configFile: files.configFile } : {}),
|
|
668
|
-
// #4627: --refresh and --target-dependents pass to the preview as they came.
|
|
669
|
-
...(ctx.refresh ? { refresh: true } : {}),
|
|
670
|
-
...(targets ? { targets } : {}),
|
|
671
|
-
...(targets && ctx.targetDependents ? { targetDependents: true } : {}),
|
|
672
|
-
...(packs.length ? { policyPacks: packs } : {}),
|
|
673
|
-
});
|
|
674
|
-
let stdout: string;
|
|
675
|
-
try {
|
|
676
|
-
({ stdout } =
|
|
677
|
-
r.engine === "plunge"
|
|
678
|
-
? await runAllowedPlunge(runnersFor(r, opts).plunge, args, r.dir, STREAMING)
|
|
679
|
-
: await runAllowedPulumi(runnersFor(r, opts).pulumi, args, r.dir, STREAMING));
|
|
680
|
-
} catch (err) {
|
|
681
|
-
const f = pulumiRunFailure(err);
|
|
682
|
-
if (f.missingBinary) throw new Error(`pulumi-up: "${r.member}": the ${r.engine} binary was not found on PATH; install ${r.engine} to plan this stack`);
|
|
683
|
-
const stream = f.stdout ?? "";
|
|
684
|
-
const policy = pulumiPolicyFindings(pulumiPolicyEvents(stream));
|
|
685
|
-
if (policy.denials.length > 0 || pulumiExitOf(f.exitCode) === CHANT_EXIT.denied) throw new PulumiPolicyDeniedError(r.member, policy, pulumiStreamError(stream));
|
|
686
|
-
const why = pulumiStreamError(stream) ?? (f.stderr?.trim() || f.message);
|
|
687
|
-
throw new Error(`pulumi-up: "${r.member}": ${r.engine} preview failed: ${why}`);
|
|
688
|
-
}
|
|
689
|
-
const preview = pulumiStreamPreview(stdout);
|
|
690
|
-
const policy = pulumiPolicyFindings(pulumiPolicyEvents(stdout));
|
|
691
|
-
// A mandatory violation that left the exit at 0 still denies: the gate reads the events, never the code alone.
|
|
692
|
-
if (policy.denials.length > 0) throw new PulumiPolicyDeniedError(r.member, policy);
|
|
693
|
-
const prior = await memberExportOf(r.dir, { stack: input.stack, ...(opts.snapshots !== undefined ? { store: opts.snapshots } : {}) });
|
|
694
|
-
const part = pulumiPreviewPart({
|
|
695
|
-
member: r.member,
|
|
696
|
-
preview,
|
|
697
|
-
stack: input.stack,
|
|
698
|
-
...(prior !== undefined ? { prior } : {}),
|
|
699
|
-
...(targets ? { targeted: true } : {}),
|
|
700
|
-
...(r.grain === "resource" ? { digest: { changedOnly: true } } : {}),
|
|
701
|
-
});
|
|
702
|
-
const shape = pulumiPlanShape(part, r.member);
|
|
703
|
-
return { part, preview, shape, policy, prior };
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
/** The member of a stack whose `config` or `StackReference`s read outputs not known yet: a hole naming them, no plan. */
|
|
707
|
-
function waitingStack(ctx: DeployContext, r: Resolved, input: PulumiUpStepInput, unresolved: string[]): CapabilityPlan {
|
|
708
|
-
const config = Object.fromEntries(Object.entries(input.config ?? {}).map(([k, v]) => [k, v === undefined ? null : v]));
|
|
709
|
-
const planDigest = computePlanDigest("pulumi-up-unresolved", { env: ctx.env, member: r.member, stack: input.stack, config, unresolved });
|
|
710
|
-
const changeSet: ChangeSetPart = {
|
|
711
|
-
member: {
|
|
712
|
-
member: r.member,
|
|
713
|
-
lexicon: "pulumi",
|
|
714
|
-
planner: "pulumi",
|
|
715
|
-
scope: input.stack,
|
|
716
|
-
status: "planned",
|
|
717
|
-
planDigest,
|
|
718
|
-
holes: [
|
|
719
|
-
{
|
|
720
|
-
address: r.member,
|
|
721
|
-
type: "pulumi:pulumi:Stack",
|
|
722
|
-
reason: `the stack reads ${unresolved.join(", ")}, known only once ${unresolved.length === 1 ? "that applies" : "those apply"}; it is planned again then`,
|
|
723
|
-
},
|
|
724
|
-
],
|
|
725
|
-
},
|
|
726
|
-
entries: [],
|
|
727
|
-
};
|
|
728
|
-
return { member: r.member, planDigest, changeSet, ...(ctx.targets?.length ? { targets: ctx.targets } : {}) };
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
function isArtifact(value: unknown): value is PulumiUpArtifact {
|
|
732
|
-
const v = value as Partial<PulumiUpArtifact> | undefined;
|
|
733
|
-
return v?.kind === "pulumi-up" && typeof v.planDigest === "string" && typeof v.shape === "object" && v.shape !== null;
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
/** The program's directory, a release's copy (#4542) or the checkout in place (plywood#22), made runnable before its first engine run. */
|
|
737
|
-
async function readyProgram(r: Resolved, opts: PulumiUpOptions): Promise<void> {
|
|
738
|
-
const runners = runnersFor(r, opts);
|
|
739
|
-
await prepareProgram({ dir: r.dir, member: r.member, engine: r.engine, run: r.engine === "plunge" ? runners.plunge : runners.pulumi });
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
async function planStack(ctx: DeployContext, original: PulumiUpStepInput, opts: PulumiUpOptions): Promise<CapabilityPlan> {
|
|
743
|
-
// #4609: in pr-<n>, the review stack, made from the template before its first preview.
|
|
744
|
-
const { step: input, review } = pulumiReviewStep(original, ctx.env, templateOf(opts));
|
|
745
|
-
const r = resolveStep(input, opts, ctx.lockGrain);
|
|
746
|
-
const location = review ? { location: locationOf(r, review.stack) } : {};
|
|
747
|
-
const unresolved = [...(ctx.unresolvedInputs ?? [])].sort();
|
|
748
|
-
if (unresolved.length > 0) return { ...waitingStack(ctx, r, input, unresolved), ...location };
|
|
749
|
-
await readyProgram(r, opts);
|
|
750
|
-
if (review) {
|
|
751
|
-
const runners = runnersFor(r, opts);
|
|
752
|
-
await initReviewStack({
|
|
753
|
-
dir: r.dir,
|
|
754
|
-
stack: review.stack,
|
|
755
|
-
engine: r.engine,
|
|
756
|
-
run: r.engine === "plunge" ? runners.plunge : runners.pulumi,
|
|
757
|
-
...(review.copyConfigFrom ? { template: review.copyConfigFrom } : {}),
|
|
758
|
-
});
|
|
759
|
-
}
|
|
760
|
-
const files = scratchFor(r, input, opts);
|
|
761
|
-
let read: StackPreview;
|
|
762
|
-
let packs: Awaited<ReturnType<typeof policyPacksFor>>;
|
|
763
|
-
try {
|
|
764
|
-
packs = await policyPacksFor(ctx, r, input, files.scratch);
|
|
765
|
-
read = await previewStack(ctx, r, input, opts, { ...files, policyPacks: packs.packs });
|
|
766
|
-
} catch (err) {
|
|
767
|
-
dropScratch(files.scratch);
|
|
768
|
-
throw err;
|
|
769
|
-
}
|
|
770
|
-
const planDigest = read.part.member.planDigest!;
|
|
771
|
-
const references = stackReferencesOf(read.prior, input);
|
|
772
|
-
const planned = pulumiMemberPlannedOutputs(r.member, {
|
|
773
|
-
part: read.part,
|
|
774
|
-
preview: read.preview,
|
|
775
|
-
...(read.prior !== undefined ? { exported: read.prior } : {}),
|
|
776
|
-
...(ctx.targets?.length ? { targeted: true } : {}),
|
|
777
|
-
});
|
|
778
|
-
const artifact: PulumiUpArtifact = {
|
|
779
|
-
kind: "pulumi-up",
|
|
780
|
-
member: r.member,
|
|
781
|
-
stack: input.stack,
|
|
782
|
-
engine: r.engine,
|
|
783
|
-
engineSource: r.engineSource,
|
|
784
|
-
engineBecause: r.engineBecause,
|
|
785
|
-
planDigest,
|
|
786
|
-
shape: read.shape,
|
|
787
|
-
scratch: files.scratch,
|
|
788
|
-
...(files.planFile ? { planFile: files.planFile } : {}),
|
|
789
|
-
...(files.configFile ? { configFile: files.configFile } : {}),
|
|
790
|
-
policy: read.policy,
|
|
791
|
-
...(packs.read ? { policyPacks: packs.read } : {}),
|
|
792
|
-
...(references ? { stackReferences: references } : {}),
|
|
793
|
-
...(planned.outputChanges ? { plannedOutputs: planned.outputChanges } : {}),
|
|
794
|
-
};
|
|
795
|
-
return {
|
|
796
|
-
member: r.member,
|
|
797
|
-
planDigest,
|
|
798
|
-
artifact,
|
|
799
|
-
changeSet: read.part,
|
|
800
|
-
// plywood#55: each changed resource's own digest, which a merged wave compares with the pull request's per resource.
|
|
801
|
-
resourceDigests: pulumiResourceDigests(read.preview),
|
|
802
|
-
outputs: { known: planned.known, unknown: planned.unknown },
|
|
803
|
-
shape: read.shape,
|
|
804
|
-
...(ctx.targets?.length ? { targets: ctx.targets } : {}),
|
|
805
|
-
...location,
|
|
806
|
-
};
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
/** The export's `StackReference`s, split into the ones core wired into `stackReferences` and the rest; undefined when it holds none. */
|
|
810
|
-
function stackReferencesOf(exported: unknown, input: PulumiUpStepInput): PulumiUpArtifact["stackReferences"] | undefined {
|
|
811
|
-
const refs = pulumiStackReferences(exported);
|
|
812
|
-
if (refs.length === 0) return undefined;
|
|
813
|
-
const wired = new Set(Object.keys(input.stackReferences ?? {}));
|
|
814
|
-
const read = refs.filter((r) => wired.has(r.name)).map((r) => r.name);
|
|
815
|
-
const outside = refs
|
|
816
|
-
.filter((r) => !wired.has(r.name))
|
|
817
|
-
.map((r) => ({
|
|
818
|
-
name: r.name,
|
|
819
|
-
why:
|
|
820
|
-
r.outputs.length === 0 && r.secretOutputs.length > 0
|
|
821
|
-
? "every output the export recorded for it is secret, and chant reads outputs blind"
|
|
822
|
-
: r.outputs.length === 0
|
|
823
|
-
? "the export recorded no output for it"
|
|
824
|
-
: "no other pulumi-up step in this project applies that stack",
|
|
825
|
-
}));
|
|
826
|
-
const lastUpdate = exportUpdatedAt(exported);
|
|
827
|
-
return { read: [...new Set(read)].sort(), outside, ...(lastUpdate ? { lastUpdate } : {}) };
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
/** When the exported stack last updated (#4617): `deployment.manifest.time`, when it is a time. */
|
|
831
|
-
export function exportUpdatedAt(exported: unknown): string | undefined {
|
|
832
|
-
const deployment = isObject(exported) && isObject(exported.deployment) ? exported.deployment : undefined;
|
|
833
|
-
const time = deployment && isObject(deployment.manifest) ? deployment.manifest.time : undefined;
|
|
834
|
-
return typeof time === "string" && !Number.isNaN(Date.parse(time)) ? time : undefined;
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
/**
|
|
838
|
-
* `declaredReads` (#4547): each step's `StackReference`s, read from its
|
|
839
|
-
* export (the index store's, else the checked-in one), as reads of the one
|
|
840
|
-
* other `pulumi-up` step whose project and stack the reference names, one
|
|
841
|
-
* per output the export recorded that is not secret, placed at
|
|
842
|
-
* `/stackReferences/<reference name>/<output>`.
|
|
843
|
-
*/
|
|
844
|
-
export async function pulumiDeclaredReads(
|
|
845
|
-
ctx: DeclaredReadsContext,
|
|
846
|
-
members: readonly DeclaredReadMember[],
|
|
847
|
-
opts: { exportStore?: SnapshotStore | null } = {},
|
|
848
|
-
): Promise<DeclaredRead[]> {
|
|
849
|
-
const steps = members
|
|
850
|
-
.map((m) => {
|
|
851
|
-
const step = m.step as unknown as PulumiUpStepInput;
|
|
852
|
-
if (typeof step?.dir !== "string" || typeof step.stack !== "string") return undefined;
|
|
853
|
-
const dir = isAbsolute(step.dir) ? step.dir : resolve(ctx.root, step.cwd ?? ".", step.dir);
|
|
854
|
-
const project = readProject(dir)?.name;
|
|
855
|
-
return { m, step, dir, project: typeof project === "string" ? project : basename(dir) };
|
|
856
|
-
})
|
|
857
|
-
.filter((x): x is NonNullable<typeof x> => x !== undefined);
|
|
858
|
-
const owners = steps.map((s) => ({ component: s.m.component, project: s.project, stack: s.step.stack }));
|
|
859
|
-
const out: DeclaredRead[] = [];
|
|
860
|
-
for (const s of steps) {
|
|
861
|
-
const exported = await memberExportOf(s.dir, { stack: s.step.stack, ...(opts.exportStore !== undefined ? { store: opts.exportStore } : {}) });
|
|
862
|
-
for (const ref of pulumiStackReferences(exported)) {
|
|
863
|
-
const found = stackReferenceOwner(ref, { component: s.m.component, project: s.project }, owners);
|
|
864
|
-
if (!("owner" in found)) continue;
|
|
865
|
-
for (const output of ref.outputs) {
|
|
866
|
-
out.push({ reader: s.m.component, index: s.m.index, upstream: found.owner.component, output, at: `/stackReferences/${pointerSegment(ref.name)}/${pointerSegment(output)}` });
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
return out;
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
/** An `up` that exited non-zero, read through the exit-code table (#4553). */
|
|
874
|
-
function upFailure(r: Resolved, err: unknown, policy: GatePolicyFindings): Error {
|
|
875
|
-
const f = pulumiRunFailure(err);
|
|
876
|
-
if (f.missingBinary) return new Error(`pulumi-up: "${r.member}": the ${r.engine} binary was not found on PATH; nothing was applied`);
|
|
877
|
-
const stream = f.stdout ?? "";
|
|
878
|
-
const why = pulumiStreamError(stream) ?? (f.stderr?.trim() || f.message).split("\n").slice(-3).join("\n");
|
|
879
|
-
const outcome = pulumiExitOf(f.exitCode);
|
|
880
|
-
if (outcome === CHANT_EXIT.moved) {
|
|
881
|
-
return new PulumiPlanMovedError(r.member, `"${r.member}": refusing to apply. plunge refused the saved plan, since a record it planned against moved or the plan has no stamp: ${why}. Plan it again.`);
|
|
882
|
-
}
|
|
883
|
-
const events = pulumiPolicyFindings(pulumiPolicyEvents(stream));
|
|
884
|
-
if (outcome === CHANT_EXIT.denied || events.denials.length > 0) {
|
|
885
|
-
return new PulumiPolicyDeniedError(r.member, events.denials.length > 0 ? events : policy, why);
|
|
886
|
-
}
|
|
887
|
-
const landed = pulumiLandedUrns(stream);
|
|
888
|
-
const failed = pulumiFailedUrns(stream);
|
|
889
|
-
const detail = [
|
|
890
|
-
...(failed.length > 0 ? [`failed: ${failed.join(", ")}`] : []),
|
|
891
|
-
...(landed.length > 0 ? [`landed before it stopped: ${landed.join(", ")}`] : ["nothing landed"]),
|
|
892
|
-
].join("; ");
|
|
893
|
-
return new PulumiUpFailedError(r.member, `pulumi-up: "${r.member}": ${r.engine} up failed (exit ${f.exitCode ?? "unknown"}): ${why}. ${detail}`, failedUpSummary(stream));
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
/**
|
|
897
|
-
* What a failed `up`'s stream still says (#4579): its `summaryEvent`, or,
|
|
898
|
-
* when the engine stopped before printing one, the per-resource timings
|
|
899
|
-
* plunge put on the steps that ran (`resOutputsEvent`, `resOpFailedEvent`),
|
|
900
|
-
* under `result: "failed"`. Undefined when the stream holds neither.
|
|
901
|
-
*/
|
|
902
|
-
export function failedUpSummary(stream: string): PulumiApplySummary | undefined {
|
|
903
|
-
const summary = pulumiStreamSummary(stream);
|
|
904
|
-
if (summary) return summary;
|
|
905
|
-
const timings = pulumiStreamTimings(stream);
|
|
906
|
-
return Object.keys(timings).length > 0 ? { resourceChanges: {}, result: "failed", timings } : undefined;
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
async function runStack(ctx: DeployContext, original: PulumiUpStepInput, opts: PulumiUpOptions): Promise<PulumiUpStepOutput> {
|
|
910
|
-
// #4609: in pr-<n>, the review stack the plan made and previewed.
|
|
911
|
-
const { step: input } = pulumiReviewStep(original, ctx.env, templateOf(opts));
|
|
912
|
-
const r = resolveStep(input, opts, ctx.lockGrain);
|
|
913
|
-
const handed = ctx.plans?.[r.member];
|
|
914
|
-
const fromWave = isArtifact(handed);
|
|
915
|
-
const targets = ctx.targets && ctx.targets.length > 0 ? ctx.targets : undefined;
|
|
916
|
-
await readyProgram(r, opts);
|
|
917
|
-
|
|
918
|
-
// Ruling D: no approved plan handed in, so plan here and apply that.
|
|
919
|
-
let approved: PulumiUpArtifact;
|
|
920
|
-
if (fromWave) {
|
|
921
|
-
approved = handed;
|
|
922
|
-
} else {
|
|
923
|
-
const planned = await planStack(ctx, original, opts);
|
|
924
|
-
if (!isArtifact(planned.artifact)) {
|
|
925
|
-
throw new Error(`pulumi-up: "${r.member}": the stack's config reads outputs not known yet (${(ctx.unresolvedInputs ?? []).join(", ")}), so it cannot apply`);
|
|
926
|
-
}
|
|
927
|
-
approved = planned.artifact;
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
// The config copy: the plan's when it is still there, else written again (its text is the same).
|
|
931
|
-
const own = existsSync(approved.scratch) ? undefined : scratchFor(r, input, opts);
|
|
932
|
-
const configFile = approved.configFile && existsSync(approved.configFile) ? approved.configFile : own?.configFile;
|
|
933
|
-
// #4613: the packs the plan read at base, the same copies, else read again at that base; a plan that read none runs the step's own.
|
|
934
|
-
let policyPacks: readonly PulumiPolicyPack[] | undefined = input.policyPacks;
|
|
935
|
-
if (approved.policyPacks) {
|
|
936
|
-
const copies = approved.policyPacks.packs;
|
|
937
|
-
if (copies.every((p) => existsSync(p.dir) && (!p.config || existsSync(p.config)))) {
|
|
938
|
-
policyPacks = copies.map((p) => ({ dir: p.dir, ...(p.config ? { config: p.config } : {}) }));
|
|
939
|
-
} else {
|
|
940
|
-
try {
|
|
941
|
-
policyPacks = (await policyPacksFor({ ...ctx, policyBase: approved.policyPacks.base }, r, input, own?.scratch ?? approved.scratch)).packs;
|
|
942
|
-
} catch (err) {
|
|
943
|
-
dropScratch(approved.scratch);
|
|
944
|
-
dropScratch(own?.scratch);
|
|
945
|
-
throw err;
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
const tail = {
|
|
950
|
-
...(configFile ? { configFile } : {}),
|
|
951
|
-
...(targets ? { targets } : {}),
|
|
952
|
-
...(targets && ctx.targetDependents ? { targetDependents: true } : {}),
|
|
953
|
-
...(policyPacks?.length ? { policyPacks } : {}),
|
|
954
|
-
};
|
|
955
|
-
|
|
956
|
-
try {
|
|
957
|
-
let stdout: string;
|
|
958
|
-
if (r.engine === "plunge") {
|
|
959
|
-
if (!approved.planFile || !existsSync(approved.planFile)) {
|
|
960
|
-
throw new Error(`pulumi-up: "${r.member}": the saved plan ${approved.planFile ?? "(none)"} is not on this machine; plan the stack in the apply job, then apply`);
|
|
961
|
-
}
|
|
962
|
-
try {
|
|
963
|
-
({ stdout } = await runApplyPlunge(runnersFor(r, opts).plunge, plungeUpArgs({ plan: approved.planFile, stack: input.stack, ...tail }), r.dir));
|
|
964
|
-
} catch (err) {
|
|
965
|
-
throw upFailure(r, err, approved.policy);
|
|
966
|
-
}
|
|
967
|
-
} else {
|
|
968
|
-
if (fromWave) {
|
|
969
|
-
// Preview again, and hold it to the approved shape before anything changes.
|
|
970
|
-
const fresh = await previewStack(ctx, r, input, opts, { ...(configFile ? { configFile } : {}), ...(policyPacks ? { policyPacks } : {}) });
|
|
971
|
-
const differences = pulumiShapeDifferences(approved.shape, fresh.shape, fresh.preview.steps);
|
|
972
|
-
if (differences.length > 0) throw new PlanShapeMovedError(r.member, differences);
|
|
973
|
-
}
|
|
974
|
-
try {
|
|
975
|
-
// #4627: stock up plans again, so it refreshes as its preview did; plunge applies the saved plan, whose preview refreshed.
|
|
976
|
-
({ stdout } = await runApplyPulumi(runnersFor(r, opts).pulumi, pulumiUpArgs({ stack: input.stack, ...tail, ...(ctx.refresh ? { refresh: true } : {}) }), r.dir));
|
|
977
|
-
} catch (err) {
|
|
978
|
-
throw upFailure(r, err, approved.policy);
|
|
979
|
-
}
|
|
980
|
-
// Ruling A: the steps the update ran, held to the approved shape.
|
|
981
|
-
const steps = pulumiAppliedSteps(stdout);
|
|
982
|
-
const ran = pulumiPreviewPart({ member: r.member, preview: { steps }, stack: input.stack });
|
|
983
|
-
const differences = pulumiShapeDifferences(approved.shape, pulumiPlanShape(ran, r.member), steps);
|
|
984
|
-
if (differences.length > 0) throw new PulumiAppliedShapeError(r.member, differences, pulumiStreamSummary(stdout));
|
|
985
|
-
}
|
|
986
|
-
const outputs = await pulumiMemberStackOutputs({
|
|
987
|
-
dir: r.dir,
|
|
988
|
-
stack: input.stack,
|
|
989
|
-
engine: r.engine,
|
|
990
|
-
...runnerOptions(r, opts),
|
|
991
|
-
});
|
|
992
|
-
const summary = pulumiStreamSummary(stdout);
|
|
993
|
-
const exportSnapshot = await writePulumiExportSnapshot({
|
|
994
|
-
dir: r.dir,
|
|
995
|
-
stack: input.stack,
|
|
996
|
-
environment: ctx.env,
|
|
997
|
-
engine: r.engine,
|
|
998
|
-
...runnerOptions(r, opts),
|
|
999
|
-
...(opts.snapshots !== undefined ? { store: opts.snapshots } : {}),
|
|
1000
|
-
});
|
|
1001
|
-
const hasPolicy = approved.policy.warnings.length > 0 || approved.policy.denials.length > 0;
|
|
1002
|
-
return {
|
|
1003
|
-
member: r.member,
|
|
1004
|
-
stack: input.stack,
|
|
1005
|
-
engine: r.engine,
|
|
1006
|
-
planDigest: approved.planDigest,
|
|
1007
|
-
fromWavePlan: fromWave,
|
|
1008
|
-
outputs,
|
|
1009
|
-
...(summary ? { summary } : {}),
|
|
1010
|
-
...(hasPolicy ? { policy: approved.policy } : {}),
|
|
1011
|
-
exportSnapshot,
|
|
1012
|
-
};
|
|
1013
|
-
} finally {
|
|
1014
|
-
dropScratch(approved.scratch);
|
|
1015
|
-
dropScratch(own?.scratch);
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
/** `releaseInputs` (#4542): the stack's directory, or unbound when its state is a file relative to it. */
|
|
1020
|
-
export function pulumiReleaseInputs(input: PulumiUpStepInput, ctx: ReleaseInputsContext): ReleaseInputs | ReleaseInputsUnbound | null {
|
|
1021
|
-
if (typeof input?.dir !== "string" || input.dir === "" || typeof input.stack !== "string") return null;
|
|
1022
|
-
const base = resolve(ctx.memberDir, input.cwd ?? ".");
|
|
1023
|
-
const dir = isAbsolute(input.dir) ? input.dir : resolve(base, input.dir);
|
|
1024
|
-
const project = readProject(dir);
|
|
1025
|
-
if (!project) return null;
|
|
1026
|
-
const toPosix = (p: string): string => p.split("\\").join("/") || ".";
|
|
1027
|
-
const fromMember = (abs: string): string => toPosix(relative(ctx.memberDir, abs));
|
|
1028
|
-
const backend = (project.backend as { url?: unknown } | undefined)?.url;
|
|
1029
|
-
if (typeof backend === "string") {
|
|
1030
|
-
const m = /^(?:plunge\+)?file:\/\/(.*)$/.exec(backend);
|
|
1031
|
-
if (m && !m[1].startsWith("/") && !m[1].startsWith("~")) {
|
|
1032
|
-
return {
|
|
1033
|
-
unbound: `stack "${input.stack}" keeps its state at ${backend}, a path relative to ${fromMember(dir)}, so a preview of a recorded copy would read no state; roll it back with chant lifecycle rollback --to <ref>`,
|
|
1034
|
-
};
|
|
1035
|
-
}
|
|
1036
|
-
}
|
|
1037
|
-
const paths = [fromMember(dir)];
|
|
1038
|
-
const main = typeof project.main === "string" ? resolve(dir, project.main) : undefined;
|
|
1039
|
-
if (main && relative(dir, main).startsWith("..")) paths.push(fromMember(main));
|
|
1040
|
-
return { field: "dir", dir: fromMember(dir), paths: [...new Set(paths)].sort() };
|
|
1041
|
-
}
|
|
1042
|
-
|
|
1043
|
-
/** The `pulumi-up` capability, with injectable runners for tests. */
|
|
1044
|
-
export function createPulumiUpCapability(opts: PulumiUpOptions = {}): Capability<PulumiUpStepInput, PulumiUpStepOutput> {
|
|
1045
|
-
return {
|
|
1046
|
-
kind: "pulumi-up",
|
|
1047
|
-
// A stack's update has no undo short of applying the previous program, which is a change of its own.
|
|
1048
|
-
rollbackPolicy: "needs-opt-out",
|
|
1049
|
-
// Each target passes as `--target <urn>` to the preview and to `up`.
|
|
1050
|
-
targets: "accept",
|
|
1051
|
-
// #4627: `--refresh` and `--target-dependents` pass to the preview, and to `pulumi up`; the digest binds them.
|
|
1052
|
-
planFlags: { refresh: "accept", targetDependents: "accept" },
|
|
1053
|
-
plan: (ctx, input) => planStack(ctx, input, opts),
|
|
1054
|
-
run: (ctx, input) => runStack(ctx, input, opts),
|
|
1055
|
-
// The outputs standing now, for a dependent planned before this stack applies.
|
|
1056
|
-
async outputs(ctx, original) {
|
|
1057
|
-
const { step: input } = pulumiReviewStep(original, ctx.env, templateOf(opts));
|
|
1058
|
-
const r = resolveStep(input, opts);
|
|
1059
|
-
return pulumiMemberStackOutputs({
|
|
1060
|
-
dir: r.dir,
|
|
1061
|
-
stack: input.stack,
|
|
1062
|
-
engine: r.engine,
|
|
1063
|
-
...runnerOptions(r, opts),
|
|
1064
|
-
});
|
|
1065
|
-
},
|
|
1066
|
-
releaseInputs: (input, ctx) => pulumiReleaseInputs(input, ctx),
|
|
1067
|
-
// #4552: resource on plunge, the stack (target) on stock Pulumi.
|
|
1068
|
-
defaultLockGrain(input) {
|
|
1069
|
-
requireInput(input);
|
|
1070
|
-
return pulumiDefaultLockGrain(pulumiMemberEngine(stackDir(input), input.engine, engineEnv(input, opts)).engine);
|
|
1071
|
-
},
|
|
1072
|
-
// Stock Pulumi keeps the stack grain: its backend's stack lock already orders updates, and nothing in it is per resource.
|
|
1073
|
-
lockGrainRefusal(input, grain) {
|
|
1074
|
-
if (grain !== "resource") return undefined;
|
|
1075
|
-
requireInput(input);
|
|
1076
|
-
const engine = pulumiMemberEngine(stackDir(input), input.engine, engineEnv(input, opts)).engine;
|
|
1077
|
-
return engine === "pulumi" ? new PulumiResourceGrainRefusedError(pulumiUpMember(input)).message : undefined;
|
|
1078
|
-
},
|
|
1079
|
-
// The ruling for ci-products (2026-10-28): a stock stack waits for its stack row on the ledger in place of the backend's lock.
|
|
1080
|
-
// plunge keeps the resource grain, and a plunge stack declared on the target grain waits on the same row.
|
|
1081
|
-
targetLockRow(input, plan) {
|
|
1082
|
-
requireInput(input);
|
|
1083
|
-
const project = readProject(stackDir(input))?.name;
|
|
1084
|
-
const stack = plan && isArtifact(plan.artifact) ? plan.artifact.stack : input.stack;
|
|
1085
|
-
if (typeof project !== "string" || !stack) return undefined;
|
|
1086
|
-
return { key: stackRowKey(project, stack), target: pulumiUpMember(input), address: `${project}/${stack}` };
|
|
1087
|
-
},
|
|
1088
|
-
// URN rows, object rows, and the stack row when something may appear only at apply (./lock-rows.ts).
|
|
1089
|
-
lockRows(input, plan) {
|
|
1090
|
-
if (!plan.changeSet) return [];
|
|
1091
|
-
const project = readProject(stackDir(input))?.name;
|
|
1092
|
-
// #4609: the stack the plan previewed, the review stack in pr-<n>.
|
|
1093
|
-
const stack = isArtifact(plan.artifact) ? plan.artifact.stack : input.stack;
|
|
1094
|
-
return pulumiLockRows(plan.changeSet, plan.member, { ...(typeof project === "string" ? { project } : {}), stack });
|
|
1095
|
-
},
|
|
1096
|
-
// #4555: the stack, the engine and the summary's counts, for the step's span and run record.
|
|
1097
|
-
traceFacts: (input, outcome) => pulumiTraceFacts(input, outcome),
|
|
1098
|
-
declaredReads: (ctx, members) => pulumiDeclaredReads(ctx, members, opts.snapshots !== undefined ? { exportStore: opts.snapshots } : {}),
|
|
1099
|
-
};
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
export const pulumiUpCapability = createPulumiUpCapability();
|