@intentius/chant-lexicon-pulumi 0.124.97 → 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/run.ts
DELETED
|
@@ -1,1129 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Running `pulumi` for a Pulumi member (#4453). The ruling on #4450 let
|
|
3
|
-
* chant run `pulumi preview` and `pulumi refresh --preview-only` for a
|
|
4
|
-
* Pulumi member; both read the provider and change no stack. The ruling on
|
|
5
|
-
* #4476 (2026-10-25) widened it to the list main ships, and that list is the
|
|
6
|
-
* whole of what chant runs:
|
|
7
|
-
*
|
|
8
|
-
* - `pulumi preview` (with `--json`),
|
|
9
|
-
* - `pulumi refresh --preview-only` (with `--json`, and `--target <urn>`),
|
|
10
|
-
* - `pulumi stack output --json`, with `--show-secrets` absent or
|
|
11
|
-
* `--show-secrets=false` (#4455): the member's applied outputs. It reads
|
|
12
|
-
* the backend's last deployment, calls no provider, and with secrets shown
|
|
13
|
-
* it is refused;
|
|
14
|
-
* - for a member on plunge, `plunge preview`, the same blind
|
|
15
|
-
* `plunge stack output --json`, and `plunge drift --resource <urn> --stream`;
|
|
16
|
-
* - `pulumi stack export --stack <stack>` (`plunge stack export` on plunge),
|
|
17
|
-
* exactly that, for the export the `pulumi-up` capability writes to the
|
|
18
|
-
* index store after an apply (#4546, `./stack-export-snapshot.ts`). The
|
|
19
|
-
* default export keeps secret ciphertext, which is stripped before the
|
|
20
|
-
* store sees it; `--show-secrets`, `--file` and `--version` are refused;
|
|
21
|
-
* - for a stack being adopted onto plunge (#4562), `plunge stack adopt
|
|
22
|
-
* --json --stack <stack> [--file <file>]`, which classifies and writes
|
|
23
|
-
* nothing; the `--yes` form is {@link runAdoptPlunge}'s alone;
|
|
24
|
-
* - plunge's resource move plan (#4578, INTENTIUS/plunge#56), `plunge stack
|
|
25
|
-
* move --stack <s> --dest <d> <urn>... --json`, which writes nothing; the
|
|
26
|
-
* writes of the gated stack operations are {@link runGatedPulumi}'s and
|
|
27
|
-
* {@link runGatedPlunge}'s alone;
|
|
28
|
-
* - for a review stack alone (`pr-<n>`, INTENTIUS/plywood#15), `stack
|
|
29
|
-
* init`, `destroy --yes` and `stack rm --yes`, through
|
|
30
|
-
* {@link runReviewStackPulumi} and {@link runReviewStackPlunge} only;
|
|
31
|
-
* - for the check stage (#4633, `./check-step.ts`), `pulumi install` and
|
|
32
|
-
* `pulumi about --json [--stack <stack>]`, or the same under `plunge`,
|
|
33
|
-
* through {@link runCheckPulumi} alone. The install fetches the program's
|
|
34
|
-
* dependencies and plugins; `about` reads the engine, plugins and backend.
|
|
35
|
-
* Neither writes a stack, and both run with no forge token or cloud
|
|
36
|
-
* credential in their environment;
|
|
37
|
-
* - for a member on plunge, its engine graph (#4529, ruled on #4520), as
|
|
38
|
-
* exactly one of `plunge graph --json`, `plunge graph --json --stack
|
|
39
|
-
* <stack>`, `plunge graph --json --versions` and `plunge graph --json
|
|
40
|
-
* --stack <stack> --versions` ({@link PLUNGE_GRAPH_COMMANDS}). plunge
|
|
41
|
-
* reads the stack's records and calls no provider. An outputs or secrets
|
|
42
|
-
* flag on it is refused, like any other argv off the list.
|
|
43
|
-
*
|
|
44
|
-
* Each of these may carry `--stack <name>` (#4496 for the drift read, #4514
|
|
45
|
-
* for the preview and `stack output`). That stays inside #4476's ruling: it
|
|
46
|
-
* picks which stack the same read reads and changes no stack, so it adds no
|
|
47
|
-
* command. The allow-list was extended for that flag alone: a `--stack` must
|
|
48
|
-
* be followed by a name that is not itself a flag, and an argv where it is
|
|
49
|
-
* not is refused like any other. The stack is the member's declared one,
|
|
50
|
-
* else the one the checked-in export's URNs name ({@link memberStack}).
|
|
51
|
-
*
|
|
52
|
-
* {@link PULUMI_ALLOWED_COMMANDS} is the pulumi half, and
|
|
53
|
-
* {@link runAllowedPulumi} and {@link runAllowedPlunge} refuse any argv
|
|
54
|
-
* outside the list before it reaches the runner, so no read path can make
|
|
55
|
-
* this module apply. A preview is also refused with `--show-secrets` or
|
|
56
|
-
* `--import-file` (#4541), which write files chant never wants written.
|
|
57
|
-
*
|
|
58
|
-
* ## Applies (#4541)
|
|
59
|
-
*
|
|
60
|
-
* Ruling 1 on INTENTIUS/plywood#1 widened #4450 and #4476: the `pulumi-up`
|
|
61
|
-
* capability (`./pulumi-up.ts`) applies a stack, from an apply job holding
|
|
62
|
-
* the apply identity only. It does so through two separate entry points,
|
|
63
|
-
* {@link runApplyPulumi} and {@link runApplyPlunge}, each checking the argv
|
|
64
|
-
* against one fixed form in {@link PULUMI_APPLY_COMMANDS}. Nothing but that
|
|
65
|
-
* capability's `run` calls them, and the read entry points above still
|
|
66
|
-
* refuse `up`.
|
|
67
|
-
*
|
|
68
|
-
* A workspace that wants nothing run for applied outputs
|
|
69
|
-
* sets `CHANT_PULUMI_APPLIED_OUTPUTS=export` (or `applied: "export"` on the
|
|
70
|
-
* source), and they are read from the checked-in `stack-export.json`.
|
|
71
|
-
*
|
|
72
|
-
* - {@link previewPulumiMember}: `pulumi preview --json` in the member's
|
|
73
|
-
* directory, as the member's change-set part (`./change-set.ts`), with the
|
|
74
|
-
* checked-in `stack-export.json` as the last deployment, so what the
|
|
75
|
-
* preview cannot list is `mayAppear` rather than left out.
|
|
76
|
-
* - {@link refreshPulumiMember}: `pulumi refresh --preview-only --json
|
|
77
|
-
* --target <urn>` once per resource, as drift records
|
|
78
|
-
* (`./drift-record.ts`). The URNs default to the export's resources. With
|
|
79
|
-
* no export, one untargeted refresh. A member on plunge reads each
|
|
80
|
-
* resource with `plunge drift --resource <urn> --stream` instead.
|
|
81
|
-
* - {@link pulumiMemberStackOutputs}: `pulumi stack output --json
|
|
82
|
-
* --show-secrets=false`, the member's applied outputs (#4455).
|
|
83
|
-
* - {@link plungeMemberGraph}: `plunge graph --json --stack <stack>`, a
|
|
84
|
-
* member on plunge's engine graph, for the lexicon's `describeResources`
|
|
85
|
-
* (`./describe-resources.ts`, #4529). A stock member has no such read.
|
|
86
|
-
*
|
|
87
|
-
* Each passes `--stack` when {@link memberStack} names one; without it
|
|
88
|
-
* the CLI reads whatever stack is selected, and a checked-in member has none.
|
|
89
|
-
*
|
|
90
|
-
* A member on plunge runs the same argv under `plunge` (a fork of the
|
|
91
|
-
* pulumi CLI) for its preview and stack outputs; {@link runAllowedPlunge}
|
|
92
|
-
* lets those, `plunge drift --resource <urn> --stream` and the four
|
|
93
|
-
* `plunge graph` argv through.
|
|
94
|
-
*
|
|
95
|
-
* ## Which members run on plunge
|
|
96
|
-
*
|
|
97
|
-
* {@link pulumiMemberEngine} decides, first rule that answers:
|
|
98
|
-
*
|
|
99
|
-
* 1. the member's config says `engine: "pulumi"` or `"plunge"`;
|
|
100
|
-
* 2. the nearest `plywood.yml` (the member's directory up to the repo
|
|
101
|
-
* root) says `engine:`, or names a `backend:` URL starting with `plunge`;
|
|
102
|
-
* 3. `PULUMI_BACKEND_URL` in the job environment starts with `plunge`;
|
|
103
|
-
* 4. `Pulumi.yaml` names a backend whose URL starts with `plunge`
|
|
104
|
-
* (`backend: { url: "plunge+file:///..." }`, `plunge://...`), plunge's
|
|
105
|
-
* backend scheme;
|
|
106
|
-
* 5. otherwise `pulumi`.
|
|
107
|
-
*
|
|
108
|
-
* The result carries `source`, the rule that answered, for the plan output.
|
|
109
|
-
* Rule 3 reads the job's environment, so a machine that logs in to a plunge
|
|
110
|
-
* backend by variable gets plunge, as the CLI does; the checked-in files
|
|
111
|
-
* (rules 2 and 4) give the same answer wherever the member is checked out.
|
|
112
|
-
*
|
|
113
|
-
* The runner is injectable, so the tests run no binary.
|
|
114
|
-
*/
|
|
115
|
-
import { execFile } from "node:child_process";
|
|
116
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
117
|
-
import { join } from "node:path";
|
|
118
|
-
import { promisify } from "node:util";
|
|
119
|
-
import type { ChangeSetPart } from "@intentius/chant/change-set";
|
|
120
|
-
import type { DriftAdapterBase, DriftRecord } from "@intentius/chant/drift-record";
|
|
121
|
-
import type { SnapshotStore } from "@intentius/chant/lifecycle/snapshot-store";
|
|
122
|
-
import type { UnobservedReason } from "@intentius/chant/observation";
|
|
123
|
-
import { isPulumiNodeless, parsePulumiUrn } from "@intentius/chant/pulumi-urn";
|
|
124
|
-
import { pulumiExportResources, pulumiPreviewPart } from "./change-set";
|
|
125
|
-
import { pulumiRefreshArgs, pulumiRefreshDocumentRecords, pulumiRefreshDriftRecords, type PulumiRefreshRead } from "./drift-record";
|
|
126
|
-
import { plungeDriftArgs, plungeDriftStreamRecords, type PlungeDriftRead } from "./drift-record";
|
|
127
|
-
import { pulumiMemberEngine, type PulumiMemberEngine } from "./member-engine";
|
|
128
|
-
import { PULUMI_EXPORT_FILE } from "./workspace-member";
|
|
129
|
-
|
|
130
|
-
const execFileAsync = promisify(execFile);
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Runs the pulumi binary with these arguments in `cwd`. Injectable so tests
|
|
134
|
-
* need no binary. `env` holds variables added to the engine's environment
|
|
135
|
-
* ({@link engineEnv}) for this run only, such as
|
|
136
|
-
* `PULUMI_ENABLE_STREAMING_JSON_PREVIEW` for the pulumi-up preview (#4541).
|
|
137
|
-
*/
|
|
138
|
-
export type PulumiRunner = (args: string[], opts: { cwd: string; env?: Record<string, string> }) => Promise<{ stdout: string }>;
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* The engine's environment: no update check, and no PULUMI_SKIP_CONFIRMATIONS, which stands for `--yes` and
|
|
142
|
-
* makes `refresh --preview-only` refuse ("--yes and --preview-only cannot be used together", recorded, #4475).
|
|
143
|
-
*/
|
|
144
|
-
export function engineEnv(env: NodeJS.ProcessEnv = process.env): NodeJS.ProcessEnv {
|
|
145
|
-
const out: NodeJS.ProcessEnv = { ...env, PULUMI_SKIP_UPDATE_CHECK: "true" };
|
|
146
|
-
delete out.PULUMI_SKIP_CONFIRMATIONS;
|
|
147
|
-
return out;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export const defaultPulumiRunner: PulumiRunner = (args, opts) =>
|
|
151
|
-
execFileAsync("pulumi", args, { cwd: opts.cwd, maxBuffer: 256 * 1024 * 1024, env: engineEnv({ ...process.env, ...opts.env }) });
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* The only `pulumi` commands chant runs (ruling on #4450, widened by the
|
|
155
|
-
* ruling on #4476 to keep #4455's `stack output`): each argv must start
|
|
156
|
-
* with one of these. Any of them may name its stack with `--stack <name>`
|
|
157
|
-
* (#4496, #4514), which {@link wellFormedStack} checks.
|
|
158
|
-
*/
|
|
159
|
-
export const PULUMI_ALLOWED_COMMANDS: readonly (readonly string[])[] = [["preview"], ["refresh", "--preview-only"], ["stack", "output"], ["stack", "export"]];
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Exactly `stack export --stack <stack>` (#4546): the export printed to
|
|
163
|
-
* stdout with secrets encrypted. `--file` writes the working tree,
|
|
164
|
-
* `--show-secrets` prints plaintext and `--version` reads another update, so
|
|
165
|
-
* none is allowed.
|
|
166
|
-
*/
|
|
167
|
-
function allowedStackExport(args: string[]): boolean {
|
|
168
|
-
return args.length === 4 && args[0] === "stack" && args[1] === "export" && args[2] === "--stack" && wellFormedStack(args);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* A `stack output` argv that prints no secret: `--json`, and
|
|
173
|
-
* `--show-secrets` only as `--show-secrets=false`.
|
|
174
|
-
*/
|
|
175
|
-
function blindStackOutput(args: string[]): boolean {
|
|
176
|
-
return args.includes("--json") && args.every((a) => !a.startsWith("--show-secrets") || a === "--show-secrets=false");
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Every `--stack` in the argv is followed by a stack name, not by another
|
|
181
|
-
* flag or nothing (#4514). The one allow-list extension for `--stack`: it
|
|
182
|
-
* selects the stack an allowed read reads, inside #4476's ruling, and a
|
|
183
|
-
* dash-led "name" would smuggle a flag past the list.
|
|
184
|
-
*/
|
|
185
|
-
function wellFormedStack(args: string[]): boolean {
|
|
186
|
-
return args.every((a, i) => a !== "--stack" || (typeof args[i + 1] === "string" && args[i + 1].length > 0 && !args[i + 1].startsWith("-")));
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* A preview flag that writes what chant must not have written (#4541): any
|
|
191
|
-
* form of `--show-secrets`, which with `--save-plan` puts plaintext secrets
|
|
192
|
-
* in the plan file (plunge `preview.go:723-726`), and `--import-file`, which
|
|
193
|
-
* writes a file chant never reads.
|
|
194
|
-
*/
|
|
195
|
-
const PREVIEW_REFUSED_FLAGS = ["--show-secrets", "--import-file"];
|
|
196
|
-
|
|
197
|
-
function refusedPreviewFlag(args: string[]): boolean {
|
|
198
|
-
return args.some((a) => PREVIEW_REFUSED_FLAGS.some((f) => a === f || a.startsWith(`${f}=`)));
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
function allowedRead(args: string[]): boolean {
|
|
202
|
-
if (!wellFormedStack(args)) return false;
|
|
203
|
-
if (!PULUMI_ALLOWED_COMMANDS.some((prefix) => prefix.every((a, i) => args[i] === a))) return false;
|
|
204
|
-
if (args[0] === "refresh") return args.includes("--preview-only");
|
|
205
|
-
if (args[0] === "stack" && args[1] === "export") return allowedStackExport(args);
|
|
206
|
-
if (args[0] === "stack") return blindStackOutput(args);
|
|
207
|
-
if (args[0] === "preview") return !refusedPreviewFlag(args);
|
|
208
|
-
return true;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/** Run `args` through `run`, refusing any argv that is not an allowed read. `env` is added to the engine's environment. */
|
|
212
|
-
export async function runAllowedPulumi(run: PulumiRunner, args: string[], cwd: string, env?: Record<string, string>): Promise<{ stdout: string }> {
|
|
213
|
-
if (!allowedRead(args)) {
|
|
214
|
-
throw new Error(
|
|
215
|
-
`chant runs only pulumi preview and pulumi refresh --preview-only, pulumi stack output --json --show-secrets=false and pulumi stack export --stack <stack>, for a Pulumi member, not pulumi ${args.join(" ")}`,
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
return run(args, env ? { cwd, env } : { cwd });
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* The four `plunge graph` argv chant runs (#4529, ruled on #4520 Q4 and Q6),
|
|
223
|
-
* in this order of flags and no other. `<stack>` stands for a stack name.
|
|
224
|
-
*/
|
|
225
|
-
export const PLUNGE_GRAPH_COMMANDS: readonly string[] = [
|
|
226
|
-
"plunge graph --json",
|
|
227
|
-
"plunge graph --json --stack <stack>",
|
|
228
|
-
"plunge graph --json --versions",
|
|
229
|
-
"plunge graph --json --stack <stack> --versions",
|
|
230
|
-
];
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* The argv chant runs for a plunge member's engine graph (#4529): `--stack`
|
|
234
|
-
* when {@link memberStack} names one, `--versions` only when asked, since it
|
|
235
|
-
* costs one version listing per record.
|
|
236
|
-
*/
|
|
237
|
-
export function plungeGraphArgs(opts: { stack?: string; versions?: boolean } = {}): string[] {
|
|
238
|
-
return ["graph", "--json", ...(opts.stack ? ["--stack", opts.stack] : []), ...(opts.versions ? ["--versions"] : [])];
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Exactly one of {@link PLUNGE_GRAPH_COMMANDS}. Nothing else gets through:
|
|
243
|
-
* no other flag, no repeated flag, no other order. An outputs or secrets
|
|
244
|
-
* flag (`--show-secrets`, `--outputs`) is refused with the rest, since chant
|
|
245
|
-
* never asks plunge for an output value. The stack name follows
|
|
246
|
-
* {@link wellFormedStack}'s rule (#4514).
|
|
247
|
-
*/
|
|
248
|
-
function allowedPlungeGraph(args: string[]): boolean {
|
|
249
|
-
if (args[0] !== "graph" || args[1] !== "--json") return false;
|
|
250
|
-
let rest = args.slice(2);
|
|
251
|
-
if (rest[0] === "--stack") {
|
|
252
|
-
if (!wellFormedStack(rest)) return false;
|
|
253
|
-
rest = rest.slice(2);
|
|
254
|
-
}
|
|
255
|
-
if (rest[0] === "--versions") rest = rest.slice(1);
|
|
256
|
-
return rest.length === 0;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* The plunge commands chant runs: a single resource's drift stream, the
|
|
261
|
-
* same preview and blind stack output it runs under `pulumi`, and the
|
|
262
|
-
* stack's engine graph from its records (#4529). None writes.
|
|
263
|
-
*/
|
|
264
|
-
export async function runAllowedPlunge(run: PulumiRunner, args: string[], cwd: string, env?: Record<string, string>): Promise<{ stdout: string }> {
|
|
265
|
-
const drift = args[0] === "drift" && args.includes("--resource") && args.includes("--stream") && wellFormedStack(args);
|
|
266
|
-
const allowed =
|
|
267
|
-
drift ||
|
|
268
|
-
((args[0] === "preview" || args[0] === "stack") && allowedRead(args)) ||
|
|
269
|
-
allowedPlungeGraph(args) ||
|
|
270
|
-
allowedPlungeAdopt(args, false) ||
|
|
271
|
-
allowedPlungeMove(args, false);
|
|
272
|
-
if (!allowed) {
|
|
273
|
-
throw new Error(
|
|
274
|
-
`chant runs only plunge drift --resource <urn> --stream, plunge preview, plunge stack output --json --show-secrets=false, plunge stack export --stack <stack>, ${PLUNGE_ADOPT_COMMANDS[0]}, ${PLUNGE_GATED_COMMANDS[0]} and ${PLUNGE_GRAPH_COMMANDS.join(", ")} for a Pulumi member, not plunge ${args.join(" ")}`,
|
|
275
|
-
);
|
|
276
|
-
}
|
|
277
|
-
return run(args, env ? { cwd, env } : { cwd });
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
export const defaultPlungeRunner: PulumiRunner = (args, opts) =>
|
|
281
|
-
execFileAsync("plunge", args, { cwd: opts.cwd, maxBuffer: 256 * 1024 * 1024, env: engineEnv({ ...process.env, ...opts.env }) });
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* A runner for the engine binary at `bin`, an absolute path (#4592): a
|
|
285
|
-
* stack pinned to its own release runs the binary its install line wrote
|
|
286
|
-
* (`ciEngineDir` in ./ci-setup.ts) rather than whichever is on PATH. Only
|
|
287
|
-
* the binary changes; the argv still goes through the same allowlists
|
|
288
|
-
* (`runAllowedPulumi`, `runAllowedPlunge`, the apply checks) before it runs.
|
|
289
|
-
*/
|
|
290
|
-
export function engineRunnerAt(bin: string): PulumiRunner {
|
|
291
|
-
if (!bin.startsWith("/")) throw new Error(`an engine binary is an absolute path, not ${JSON.stringify(bin)}`);
|
|
292
|
-
return (args, opts) => execFileAsync(bin, args, { cwd: opts.cwd, maxBuffer: 256 * 1024 * 1024, env: engineEnv({ ...process.env, ...opts.env }) });
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* The two `up` argv chant runs, for the `pulumi-up` capability's `run` alone
|
|
297
|
-
* (#4541; ruling 1 on INTENTIUS/plywood#1 widened #4450 and #4476 so the
|
|
298
|
-
* capability applies, from an apply job holding the apply identity only).
|
|
299
|
-
* The order is fixed and nothing else gets through. `<…>` stands for a value
|
|
300
|
-
* that is not empty and does not start with `-`; `[…]` is optional; `…`
|
|
301
|
-
* repeats.
|
|
302
|
-
*
|
|
303
|
-
* `up` is refused with `--skip-preview`, `--show-secrets`, `--replace`,
|
|
304
|
-
* `--target-replace`, `--exclude`, `--remote`, `--continue-on-error`,
|
|
305
|
-
* `--config` and any flag not here, since none of them is in the list.
|
|
306
|
-
* `--refresh` and `--target-dependents` (#4627) come in the tail's order,
|
|
307
|
-
* `--target-dependents` only after a `--target`. plunge's `up --plan`
|
|
308
|
-
* applies a saved plan whose preview did the refresh, so it takes no
|
|
309
|
-
* `--refresh`.
|
|
310
|
-
*/
|
|
311
|
-
export const PULUMI_APPLY_COMMANDS: readonly string[] = [
|
|
312
|
-
"plunge up --plan <file> --yes --json --stack <stack> [--config-file <file>] [--target <urn>... [--target-dependents]] [--policy-pack <dir> [--policy-pack-config <file>]]...",
|
|
313
|
-
"pulumi up --yes --json --stack <stack> [--config-file <file>] [--refresh] [--target <urn>... [--target-dependents]] [--policy-pack <dir> [--policy-pack-config <file>]]...",
|
|
314
|
-
];
|
|
315
|
-
|
|
316
|
-
/** A CrossGuard pack the preview and `up` run (ruling 7: in the preview job, feeding chant's gate). */
|
|
317
|
-
export interface PulumiPolicyPack {
|
|
318
|
-
/** The pack's directory. */
|
|
319
|
-
dir: string;
|
|
320
|
-
/** Its `--policy-pack-config` file. */
|
|
321
|
-
config?: string;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
/** What the apply argv carry after the stack. */
|
|
325
|
-
export interface PulumiApplyTail {
|
|
326
|
-
/** A scratch copy of the stack's config file, passed as `--config-file` (#4541): never `--config`, which writes the working tree's file. */
|
|
327
|
-
configFile?: string;
|
|
328
|
-
targets?: readonly string[];
|
|
329
|
-
/** `--refresh` (#4627): refresh the stack's state before the preview or `pulumi up`. */
|
|
330
|
-
refresh?: boolean;
|
|
331
|
-
/** `--target-dependents` (#4627): with `targets`, their dependents too. */
|
|
332
|
-
targetDependents?: boolean;
|
|
333
|
-
policyPacks?: readonly PulumiPolicyPack[];
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
function tailArgs(t: PulumiApplyTail): string[] {
|
|
337
|
-
const targets = t.targets ?? [];
|
|
338
|
-
return [
|
|
339
|
-
...(t.configFile ? ["--config-file", t.configFile] : []),
|
|
340
|
-
...(t.refresh ? ["--refresh"] : []),
|
|
341
|
-
...targets.flatMap((u) => ["--target", u]),
|
|
342
|
-
...(t.targetDependents && targets.length > 0 ? ["--target-dependents"] : []),
|
|
343
|
-
...(t.policyPacks ?? []).flatMap((p) => ["--policy-pack", p.dir, ...(p.config ? ["--policy-pack-config", p.config] : [])]),
|
|
344
|
-
];
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
/**
|
|
348
|
-
* The preview the `pulumi-up` capability runs (#4541): the member's preview
|
|
349
|
-
* argv, with `--save-plan <file>` on plunge, then the apply tail. It goes
|
|
350
|
-
* through {@link runAllowedPulumi} or {@link runAllowedPlunge} like every
|
|
351
|
-
* other preview.
|
|
352
|
-
*/
|
|
353
|
-
export function pulumiUpPreviewArgs(opts: { stack: string; savePlan?: string } & PulumiApplyTail): string[] {
|
|
354
|
-
return ["preview", "--json", "--show-sames", "--stack", opts.stack, ...(opts.savePlan ? ["--save-plan", opts.savePlan] : []), ...tailArgs(opts)];
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
/** `plunge up --plan <file> --yes --json --stack <stack>` and the tail: the first of {@link PULUMI_APPLY_COMMANDS}. */
|
|
358
|
-
export function plungeUpArgs(opts: { plan: string; stack: string } & PulumiApplyTail): string[] {
|
|
359
|
-
return ["up", "--plan", opts.plan, "--yes", "--json", "--stack", opts.stack, ...tailArgs(opts)];
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
/** `pulumi up --yes --json --stack <stack>` and the tail: the second of {@link PULUMI_APPLY_COMMANDS}. */
|
|
363
|
-
export function pulumiUpArgs(opts: { stack: string } & PulumiApplyTail): string[] {
|
|
364
|
-
return ["up", "--yes", "--json", "--stack", opts.stack, ...tailArgs(opts)];
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
const isValue = (v: string | undefined): v is string => typeof v === "string" && v.length > 0 && !v.startsWith("-");
|
|
368
|
-
|
|
369
|
-
/** Whether `rest` is exactly an apply tail, in its order; `refresh` says whether `--refresh` may stand in it (#4627). */
|
|
370
|
-
function wellFormedTail(rest: string[], refresh = true): boolean {
|
|
371
|
-
let i = 0;
|
|
372
|
-
if (rest[i] === "--config-file") {
|
|
373
|
-
if (!isValue(rest[i + 1])) return false;
|
|
374
|
-
i += 2;
|
|
375
|
-
}
|
|
376
|
-
if (refresh && rest[i] === "--refresh") i += 1;
|
|
377
|
-
let targets = 0;
|
|
378
|
-
while (rest[i] === "--target") {
|
|
379
|
-
if (!isValue(rest[i + 1])) return false;
|
|
380
|
-
i += 2;
|
|
381
|
-
targets++;
|
|
382
|
-
}
|
|
383
|
-
if (targets > 0 && rest[i] === "--target-dependents") i += 1;
|
|
384
|
-
while (rest[i] === "--policy-pack") {
|
|
385
|
-
if (!isValue(rest[i + 1])) return false;
|
|
386
|
-
i += 2;
|
|
387
|
-
if (rest[i] === "--policy-pack-config") {
|
|
388
|
-
if (!isValue(rest[i + 1])) return false;
|
|
389
|
-
i += 2;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
return i === rest.length;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
/** Exactly `plunge up --plan <file> --yes --json --stack <stack>` and a tail. */
|
|
396
|
-
function allowedPlungeUp(args: string[]): boolean {
|
|
397
|
-
return (
|
|
398
|
-
args[0] === "up" &&
|
|
399
|
-
args[1] === "--plan" &&
|
|
400
|
-
isValue(args[2]) &&
|
|
401
|
-
args[3] === "--yes" &&
|
|
402
|
-
args[4] === "--json" &&
|
|
403
|
-
args[5] === "--stack" &&
|
|
404
|
-
isValue(args[6]) &&
|
|
405
|
-
wellFormedTail(args.slice(7), false)
|
|
406
|
-
);
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
/** Exactly `pulumi up --yes --json --stack <stack>` and a tail. */
|
|
410
|
-
function allowedPulumiUp(args: string[]): boolean {
|
|
411
|
-
return args[0] === "up" && args[1] === "--yes" && args[2] === "--json" && args[3] === "--stack" && isValue(args[4]) && wellFormedTail(args.slice(5));
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
* Run `pulumi up` for the `pulumi-up` capability (#4541), refusing any argv
|
|
416
|
-
* but the stock form in {@link PULUMI_APPLY_COMMANDS}. Only the capability's
|
|
417
|
-
* `run` calls this; no read path reaches it, and {@link runAllowedPulumi}
|
|
418
|
-
* still refuses `up`.
|
|
419
|
-
*/
|
|
420
|
-
export async function runApplyPulumi(run: PulumiRunner, args: string[], cwd: string, env?: Record<string, string>): Promise<{ stdout: string }> {
|
|
421
|
-
if (!allowedPulumiUp(args)) {
|
|
422
|
-
throw new Error(`chant applies a Pulumi stack only as ${PULUMI_APPLY_COMMANDS[1]}, not pulumi ${args.join(" ")}`);
|
|
423
|
-
}
|
|
424
|
-
return run(args, env ? { cwd, env } : { cwd });
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* Run `plunge up --plan` for the `pulumi-up` capability (#4541), refusing
|
|
429
|
-
* any argv but the plunge form in {@link PULUMI_APPLY_COMMANDS}. plunge
|
|
430
|
-
* refuses a saved plan whose records moved, or one with no stamp, before
|
|
431
|
-
* anything changes (exit 40).
|
|
432
|
-
*/
|
|
433
|
-
export async function runApplyPlunge(run: PulumiRunner, args: string[], cwd: string, env?: Record<string, string>): Promise<{ stdout: string }> {
|
|
434
|
-
if (!allowedPlungeUp(args)) {
|
|
435
|
-
throw new Error(`chant applies a plunge stack only as ${PULUMI_APPLY_COMMANDS[0]}, not plunge ${args.join(" ")}`);
|
|
436
|
-
}
|
|
437
|
-
return run(args, env ? { cwd, env } : { cwd });
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* The two `plunge stack adopt` argv chant runs (#4562), for
|
|
442
|
-
* `PulumiAdoptOp`'s activities alone. The first classifies and writes
|
|
443
|
-
* nothing (plunge's `--json` without `--yes`), so it passes through
|
|
444
|
-
* {@link runAllowedPlunge} like any read. The second writes the records and
|
|
445
|
-
* goes through {@link runAdoptPlunge} only, after the Op's gate. `--adopt`
|
|
446
|
-
* and `--index-store` (an adoption file over an index version) are refused,
|
|
447
|
-
* as is any other flag.
|
|
448
|
-
*/
|
|
449
|
-
export const PLUNGE_ADOPT_COMMANDS: readonly string[] = [
|
|
450
|
-
"plunge stack adopt --json --stack <stack> [--file <file>]",
|
|
451
|
-
"plunge stack adopt --json --yes --stack <stack> [--file <file>]",
|
|
452
|
-
];
|
|
453
|
-
|
|
454
|
-
/** `stack adopt --json [--yes] --stack <stack> [--file <file>]`, in that order. */
|
|
455
|
-
export function plungeAdoptArgs(opts: { stack: string; file?: string; yes?: boolean }): string[] {
|
|
456
|
-
return ["stack", "adopt", "--json", ...(opts.yes ? ["--yes"] : []), "--stack", opts.stack, ...(opts.file ? ["--file", opts.file] : [])];
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
function allowedPlungeAdopt(args: string[], yes: boolean): boolean {
|
|
460
|
-
if (args[0] !== "stack" || args[1] !== "adopt" || args[2] !== "--json") return false;
|
|
461
|
-
let i = 3;
|
|
462
|
-
if (yes) {
|
|
463
|
-
if (args[i] !== "--yes") return false;
|
|
464
|
-
i++;
|
|
465
|
-
}
|
|
466
|
-
if (args[i] !== "--stack" || !isValue(args[i + 1])) return false;
|
|
467
|
-
i += 2;
|
|
468
|
-
if (args[i] === "--file") {
|
|
469
|
-
if (!isValue(args[i + 1])) return false;
|
|
470
|
-
i += 2;
|
|
471
|
-
}
|
|
472
|
-
return i === args.length;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
/**
|
|
476
|
-
* Run `plunge stack adopt --json --yes` for `PulumiAdoptOp`'s Adopt step
|
|
477
|
-
* (#4562), refusing any argv but the second form in
|
|
478
|
-
* {@link PLUNGE_ADOPT_COMMANDS}. It writes plunge's records and touches no
|
|
479
|
-
* cloud object.
|
|
480
|
-
*/
|
|
481
|
-
export async function runAdoptPlunge(run: PulumiRunner, args: string[], cwd: string, env?: Record<string, string>): Promise<{ stdout: string }> {
|
|
482
|
-
if (!allowedPlungeAdopt(args, true)) {
|
|
483
|
-
throw new Error(`chant adopts a stack onto plunge only as ${PLUNGE_ADOPT_COMMANDS[1]}, not plunge ${args.join(" ")}`);
|
|
484
|
-
}
|
|
485
|
-
return run(args, env ? { cwd, env } : { cwd });
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
/**
|
|
489
|
-
* The gated stack operations' writes (#4578), for `./stack-ops.ts` alone,
|
|
490
|
-
* each run only after its gated request (#4551) is approved and spent on the
|
|
491
|
-
* ledger. Fixed forms; any other flag, order or value is refused:
|
|
492
|
-
*
|
|
493
|
-
* - `pulumi cancel --yes --stack <stack>`: releases a stuck update's lock;
|
|
494
|
-
* - `pulumi state move --source <stack> --dest <stack> --yes <urn>...`: moves
|
|
495
|
-
* resources between stock stacks, never `--include-parents`;
|
|
496
|
-
* - `pulumi up --yes --target <urn> --replace <urn> --stack <stack>`: a
|
|
497
|
-
* day-2 action (#4654), the replacement of one `command:` resource, the
|
|
498
|
-
* same URN in both places. Its preview, `preview --json --target <urn>
|
|
499
|
-
* --replace <urn> --stack <stack>`, is a read and passes
|
|
500
|
-
* {@link runAllowedPulumi}. `up` takes `--replace` here only:
|
|
501
|
-
* {@link PULUMI_APPLY_COMMANDS} still refuses it.
|
|
502
|
-
*/
|
|
503
|
-
export const PULUMI_GATED_COMMANDS: readonly string[] = [
|
|
504
|
-
"pulumi cancel --yes --stack <stack>",
|
|
505
|
-
"pulumi state move --source <stack> --dest <stack> --yes <urn>...",
|
|
506
|
-
"pulumi up --yes --target <urn> --replace <urn> --stack <stack>",
|
|
507
|
-
];
|
|
508
|
-
|
|
509
|
-
/** A stack action's preview (#4654): `preview --json --target <urn> --replace <urn> --stack <stack>`, a read. */
|
|
510
|
-
export function pulumiActionPreviewArgs(opts: { stack: string; urn: string }): string[] {
|
|
511
|
-
return ["preview", "--json", "--target", opts.urn, "--replace", opts.urn, "--stack", opts.stack];
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
/** A stack action's update (#4654): `up --yes --target <urn> --replace <urn> --stack <stack>`, under `pulumi` or `plunge`. */
|
|
515
|
-
export function pulumiActionUpArgs(opts: { stack: string; urn: string }): string[] {
|
|
516
|
-
return ["up", "--yes", "--target", opts.urn, "--replace", opts.urn, "--stack", opts.stack];
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
/** Exactly {@link pulumiActionUpArgs}' form: one URN, targeted and replaced, on one stack. */
|
|
520
|
-
function allowedActionUp(args: readonly string[]): boolean {
|
|
521
|
-
return (
|
|
522
|
-
args.length === 8 &&
|
|
523
|
-
args[0] === "up" &&
|
|
524
|
-
args[1] === "--yes" &&
|
|
525
|
-
args[2] === "--target" &&
|
|
526
|
-
isUrn(args[3]) &&
|
|
527
|
-
args[4] === "--replace" &&
|
|
528
|
-
args[5] === args[3] &&
|
|
529
|
-
args[6] === "--stack" &&
|
|
530
|
-
isValue(args[7])
|
|
531
|
-
);
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
/**
|
|
535
|
-
* plunge's resource move (INTENTIUS/plunge#56) in its two forms. The first
|
|
536
|
-
* prints the plan and writes nothing, so it passes {@link runAllowedPlunge};
|
|
537
|
-
* the second moves and passes {@link runGatedPlunge} only.
|
|
538
|
-
*/
|
|
539
|
-
export const PLUNGE_GATED_COMMANDS: readonly string[] = [
|
|
540
|
-
"plunge stack move --stack <stack> --dest <stack> <urn>... --json",
|
|
541
|
-
"plunge stack move --stack <stack> --dest <stack> <urn>... --json --yes",
|
|
542
|
-
"plunge up --yes --target <urn> --replace <urn> --stack <stack>",
|
|
543
|
-
];
|
|
544
|
-
|
|
545
|
-
const isUrn = (v: string | undefined): v is string => typeof v === "string" && v.startsWith("urn:pulumi:");
|
|
546
|
-
|
|
547
|
-
/** `cancel --yes --stack <stack>`. */
|
|
548
|
-
export function pulumiCancelArgs(opts: { stack: string }): string[] {
|
|
549
|
-
return ["cancel", "--yes", "--stack", opts.stack];
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
/** `state move --source <s> --dest <d> --yes <urn>...`. */
|
|
553
|
-
export function pulumiStateMoveArgs(opts: { source: string; dest: string; urns: readonly string[] }): string[] {
|
|
554
|
-
return ["state", "move", "--source", opts.source, "--dest", opts.dest, "--yes", ...opts.urns];
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
/** `stack move --stack <s> --dest <d> <urn>... --json [--yes]`. */
|
|
558
|
-
export function plungeMoveArgs(opts: { source: string; dest: string; urns: readonly string[]; yes?: boolean }): string[] {
|
|
559
|
-
return ["stack", "move", "--stack", opts.source, "--dest", opts.dest, ...opts.urns, "--json", ...(opts.yes ? ["--yes"] : [])];
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
function allowedPlungeMove(args: string[], yes: boolean): boolean {
|
|
563
|
-
if (args[0] !== "stack" || args[1] !== "move" || args[2] !== "--stack" || !isValue(args[3]) || args[4] !== "--dest" || !isValue(args[5])) return false;
|
|
564
|
-
const tail = yes ? ["--json", "--yes"] : ["--json"];
|
|
565
|
-
const urns = args.slice(6, args.length - tail.length);
|
|
566
|
-
return urns.length > 0 && urns.every(isUrn) && tail.every((t, i) => args[args.length - tail.length + i] === t);
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
function allowedGatedPulumi(args: string[]): boolean {
|
|
570
|
-
if (args[0] === "cancel") return args.length === 4 && args[1] === "--yes" && args[2] === "--stack" && isValue(args[3]);
|
|
571
|
-
if (args[0] === "state" && args[1] === "move") {
|
|
572
|
-
const urns = args.slice(7);
|
|
573
|
-
return args[2] === "--source" && isValue(args[3]) && args[4] === "--dest" && isValue(args[5]) && args[6] === "--yes" && urns.length > 0 && urns.every(isUrn);
|
|
574
|
-
}
|
|
575
|
-
if (args[0] === "up") return allowedActionUp(args);
|
|
576
|
-
return false;
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
/**
|
|
580
|
-
* The reads a gated stack export makes to name and fetch one version
|
|
581
|
-
* (#4808), for `./stack-ops.ts` alone. They stay off
|
|
582
|
-
* {@link runAllowedPulumi}'s list, which refuses `--version`, so no other
|
|
583
|
-
* caller reads an older update:
|
|
584
|
-
*
|
|
585
|
-
* - `pulumi stack history --json --page-size 1 --stack <stack>`: the newest
|
|
586
|
-
* update's number, on a backend that numbers its updates (Pulumi Cloud).
|
|
587
|
-
* A file backend answers `0`. Config secrets print as `[secret]`;
|
|
588
|
-
* - `pulumi stack export --stack <stack> --version <n>`: that update's
|
|
589
|
-
* export, run only after the export's request is approved and spent.
|
|
590
|
-
*/
|
|
591
|
-
export const PULUMI_STACK_OP_READS: readonly string[] = ["pulumi stack history --json --page-size 1 --stack <stack>", "pulumi stack export --stack <stack> --version <n>"];
|
|
592
|
-
|
|
593
|
-
/** `stack history --json --page-size 1 --stack <stack>`. */
|
|
594
|
-
export function pulumiStackHistoryArgs(stack: string): string[] {
|
|
595
|
-
return ["stack", "history", "--json", "--page-size", "1", "--stack", stack];
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
/** `stack export --stack <stack> --version <n>`. */
|
|
599
|
-
export function pulumiStackExportVersionArgs(stack: string, version: string): string[] {
|
|
600
|
-
return ["stack", "export", "--stack", stack, "--version", version];
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
function allowedStackOpRead(args: string[]): boolean {
|
|
604
|
-
if (args[0] !== "stack") return false;
|
|
605
|
-
if (args[1] === "history") return args.length === 7 && args[2] === "--json" && args[3] === "--page-size" && args[4] === "1" && args[5] === "--stack" && isValue(args[6]);
|
|
606
|
-
if (args[1] === "export") return args.length === 6 && args[2] === "--stack" && isValue(args[3]) && args[4] === "--version" && /^[1-9][0-9]*$/.test(args[5] ?? "");
|
|
607
|
-
return false;
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
/** Run one of {@link PULUMI_STACK_OP_READS}, refusing any other argv. Only `./stack-ops.ts` calls it. */
|
|
611
|
-
export async function runStackOpReadPulumi(run: PulumiRunner, args: string[], cwd: string, env?: Record<string, string>): Promise<{ stdout: string }> {
|
|
612
|
-
if (!allowedStackOpRead(args)) throw new Error(`chant reads a stack's versions only as ${PULUMI_STACK_OP_READS.join(" or ")}, not pulumi ${args.join(" ")}`);
|
|
613
|
-
return run(args, env ? { cwd, env } : { cwd });
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
/** Run one of {@link PULUMI_GATED_COMMANDS}, refusing any other argv. Only `./stack-ops.ts` calls it, after the request is spent. */
|
|
617
|
-
export async function runGatedPulumi(run: PulumiRunner, args: string[], cwd: string, env?: Record<string, string>): Promise<{ stdout: string }> {
|
|
618
|
-
if (!allowedGatedPulumi(args)) {
|
|
619
|
-
throw new Error(`chant runs a gated Pulumi stack operation only as ${PULUMI_GATED_COMMANDS.join(" or ")}, not pulumi ${args.join(" ")}`);
|
|
620
|
-
}
|
|
621
|
-
return run(args, env ? { cwd, env } : { cwd });
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
/** Run a writing form of {@link PLUNGE_GATED_COMMANDS}, the move or a stack action's update, refusing any other argv. Only `./stack-ops.ts` calls it, after the request is spent. */
|
|
625
|
-
export async function runGatedPlunge(run: PulumiRunner, args: string[], cwd: string, env?: Record<string, string>): Promise<{ stdout: string }> {
|
|
626
|
-
if (args[0] === "up") {
|
|
627
|
-
if (!allowedActionUp(args)) throw new Error(`chant runs a plunge stack action only as ${PLUNGE_GATED_COMMANDS[2]}, not plunge ${args.join(" ")}`);
|
|
628
|
-
} else if (!allowedPlungeMove(args, true)) {
|
|
629
|
-
throw new Error(`chant moves plunge resources only as ${PLUNGE_GATED_COMMANDS[1]}, not plunge ${args.join(" ")}`);
|
|
630
|
-
}
|
|
631
|
-
return run(args, env ? { cwd, env } : { cwd });
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
/**
|
|
635
|
-
* Review stacks (#4541's deferral, INTENTIUS/plywood#15): a stack per open
|
|
636
|
-
* pull request, made from a template stack's config and removed when the
|
|
637
|
-
* pull request closes or its TTL passes. Fixed forms, for a review stack
|
|
638
|
-
* name only ({@link isReviewStackName}), so no path here can create,
|
|
639
|
-
* destroy or remove any other stack:
|
|
640
|
-
*
|
|
641
|
-
* - `stack init <pr-stack> --no-select [--copy-config-from <stack>]`: the
|
|
642
|
-
* review stack, with the template's config. It selects nothing, so the
|
|
643
|
-
* checkout's selected stack stays as it was;
|
|
644
|
-
* - `destroy --yes --json --stack <pr-stack>`: deletes the review stack's
|
|
645
|
-
* resources, never `--target`, `--exclude` or `--remove`;
|
|
646
|
-
* - `stack rm --yes --stack <pr-stack>`: removes the emptied stack, never
|
|
647
|
-
* `--force`, so a stack that still holds resources is refused by the
|
|
648
|
-
* engine itself.
|
|
649
|
-
*
|
|
650
|
-
* The same three run under `plunge` for a member on plunge.
|
|
651
|
-
* {@link runReviewStackPulumi} and {@link runReviewStackPlunge} refuse any
|
|
652
|
-
* other argv; the read entry points above refuse all three.
|
|
653
|
-
*/
|
|
654
|
-
export const PULUMI_REVIEW_STACK_COMMANDS: readonly string[] = [
|
|
655
|
-
"pulumi stack init <pr-stack> --no-select [--copy-config-from <stack>]",
|
|
656
|
-
"pulumi destroy --yes --json --stack <pr-stack>",
|
|
657
|
-
"pulumi stack rm --yes --stack <pr-stack>",
|
|
658
|
-
];
|
|
659
|
-
|
|
660
|
-
/** A review stack's own name: `pr-<n>`, or `pr-<n>-<suffix>` in lowercase letters, digits and `-`. */
|
|
661
|
-
export const REVIEW_STACK_NAME = /^pr-[0-9]+(?:-[a-z0-9][a-z0-9-]*)?$/;
|
|
662
|
-
|
|
663
|
-
/**
|
|
664
|
-
* Whether `stack` names a review stack: its last segment matches
|
|
665
|
-
* {@link REVIEW_STACK_NAME}, after at most an organization and a project
|
|
666
|
-
* (`acme/shop/pr-12`).
|
|
667
|
-
*/
|
|
668
|
-
export function isReviewStackName(stack: string | undefined): stack is string {
|
|
669
|
-
if (typeof stack !== "string") return false;
|
|
670
|
-
const parts = stack.split("/");
|
|
671
|
-
return parts.length <= 3 && parts.slice(0, -1).every((p) => /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(p)) && REVIEW_STACK_NAME.test(parts[parts.length - 1]!);
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
/** `stack init <pr-stack> --no-select [--copy-config-from <stack>]`. */
|
|
675
|
-
export function reviewStackInitArgs(opts: { stack: string; copyConfigFrom?: string }): string[] {
|
|
676
|
-
return ["stack", "init", opts.stack, "--no-select", ...(opts.copyConfigFrom ? ["--copy-config-from", opts.copyConfigFrom] : [])];
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
/** `destroy --yes --json --stack <pr-stack>`. */
|
|
680
|
-
export function reviewStackDestroyArgs(opts: { stack: string }): string[] {
|
|
681
|
-
return ["destroy", "--yes", "--json", "--stack", opts.stack];
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
/** `stack rm --yes --stack <pr-stack>`. */
|
|
685
|
-
export function reviewStackRmArgs(opts: { stack: string }): string[] {
|
|
686
|
-
return ["stack", "rm", "--yes", "--stack", opts.stack];
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
/** Exactly one of {@link PULUMI_REVIEW_STACK_COMMANDS}, on a review stack. */
|
|
690
|
-
export function allowedReviewStack(args: readonly string[]): boolean {
|
|
691
|
-
if (args[0] === "stack" && args[1] === "init") {
|
|
692
|
-
if (!isReviewStackName(args[2]) || args[3] !== "--no-select") return false;
|
|
693
|
-
if (args.length === 4) return true;
|
|
694
|
-
return args.length === 6 && args[4] === "--copy-config-from" && isValue(args[5]) && args[5] !== args[2];
|
|
695
|
-
}
|
|
696
|
-
if (args[0] === "destroy") return args.length === 5 && args[1] === "--yes" && args[2] === "--json" && args[3] === "--stack" && isReviewStackName(args[4]);
|
|
697
|
-
if (args[0] === "stack" && args[1] === "rm") return args.length === 5 && args[2] === "--yes" && args[3] === "--stack" && isReviewStackName(args[4]);
|
|
698
|
-
return false;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
function reviewStackRefusal(engine: "pulumi" | "plunge", args: readonly string[]): Error {
|
|
702
|
-
return new Error(
|
|
703
|
-
`chant creates, destroys and removes only review stacks (pr-<n>), as ${PULUMI_REVIEW_STACK_COMMANDS.map((c) => c.replace(/^pulumi/, engine)).join(", ")}; not ${engine} ${args.join(" ")}`,
|
|
704
|
-
);
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
/** Run one of {@link PULUMI_REVIEW_STACK_COMMANDS} under `pulumi`, refusing any other argv or stack. */
|
|
708
|
-
export async function runReviewStackPulumi(run: PulumiRunner, args: string[], cwd: string, env?: Record<string, string>): Promise<{ stdout: string }> {
|
|
709
|
-
if (!allowedReviewStack(args)) throw reviewStackRefusal("pulumi", args);
|
|
710
|
-
return run(args, env ? { cwd, env } : { cwd });
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
/** The same forms under `plunge`, for a member on plunge. */
|
|
714
|
-
export async function runReviewStackPlunge(run: PulumiRunner, args: string[], cwd: string, env?: Record<string, string>): Promise<{ stdout: string }> {
|
|
715
|
-
if (!allowedReviewStack(args)) throw reviewStackRefusal("plunge", args);
|
|
716
|
-
return run(args, env ? { cwd, env } : { cwd });
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
/**
|
|
720
|
-
* The install chant runs in a program's directory before its first engine
|
|
721
|
-
* run, a release's recorded copy (#4542) or a job's checkout (plywood#22),
|
|
722
|
-
* for `./release-copy.ts` alone: exactly `pulumi install` or `plunge
|
|
723
|
-
* install`, no flag. Neither has `node_modules` or a virtualenv; the CLI's
|
|
724
|
-
* install follows `Pulumi.yaml`'s runtime options and the lockfile.
|
|
725
|
-
*/
|
|
726
|
-
export const PULUMI_INSTALL_COMMANDS: readonly string[] = ["pulumi install", "plunge install"];
|
|
727
|
-
|
|
728
|
-
/** Run `install` with no flag in a release copy, refusing any other argv. The runner picks the binary. */
|
|
729
|
-
export async function runReleaseInstall(run: PulumiRunner, args: string[], cwd: string, env?: Record<string, string>): Promise<{ stdout: string }> {
|
|
730
|
-
if (args.length !== 1 || args[0] !== "install") {
|
|
731
|
-
throw new Error(`chant installs a release copy's dependencies only as ${PULUMI_INSTALL_COMMANDS.join(" or ")}, not ${args.join(" ")}`);
|
|
732
|
-
}
|
|
733
|
-
return run(args, env ? { cwd, env } : { cwd });
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
/**
|
|
737
|
-
* The two argv the check stage runs for a member (#4633, `./check-step.ts`):
|
|
738
|
-
* `install` with no flag, and `about --json`, optionally with `--stack
|
|
739
|
-
* <stack>`. Under `pulumi` or `plunge`; the runner picks the binary.
|
|
740
|
-
*/
|
|
741
|
-
export const PULUMI_CHECK_COMMANDS: readonly string[] = ["pulumi install", "pulumi about --json [--stack <stack>]", "plunge install", "plunge about --json [--stack <stack>]"];
|
|
742
|
-
|
|
743
|
-
/** Whether `args` is one of {@link PULUMI_CHECK_COMMANDS}' argv. */
|
|
744
|
-
export function allowedCheck(args: readonly string[]): boolean {
|
|
745
|
-
if (args.length === 1) return args[0] === "install";
|
|
746
|
-
if (args[0] !== "about" || args[1] !== "--json") return false;
|
|
747
|
-
if (args.length === 2) return true;
|
|
748
|
-
return args.length === 4 && args[2] === "--stack" && isValue(args[3]);
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
/** Run a check-stage argv, refusing any other. The runner picks the binary. */
|
|
752
|
-
export async function runCheckPulumi(run: PulumiRunner, args: string[], cwd: string, env?: Record<string, string>): Promise<{ stdout: string }> {
|
|
753
|
-
if (!allowedCheck(args)) {
|
|
754
|
-
throw new Error(`the check stage runs only ${PULUMI_CHECK_COMMANDS.join(", ")} for a Pulumi member, not ${args.join(" ")}`);
|
|
755
|
-
}
|
|
756
|
-
return run(args, env ? { cwd, env } : { cwd });
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
export { pulumiMemberEngine, readPlywoodEngine, type PulumiMemberEngine, type PulumiMemberEngineSource, type PulumiMemberEngineOptions } from "./member-engine";
|
|
760
|
-
|
|
761
|
-
/** The argv chant runs for a member's applied outputs, after `pulumi` (#4455). Secrets stay blinded. */
|
|
762
|
-
export function pulumiStackOutputArgs(opts: { stack?: string } = {}): string[] {
|
|
763
|
-
return ["stack", "output", "--json", "--show-secrets=false", ...(opts.stack ? ["--stack", opts.stack] : [])];
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
/** The argv chant runs for a member's preview, after `pulumi`. */
|
|
767
|
-
export function pulumiPreviewArgs(opts: { stack?: string; targets?: readonly string[] } = {}): string[] {
|
|
768
|
-
// --show-sames: without it `preview --json` lists no unchanged resource but the stack (recorded, #4475), and the
|
|
769
|
-
// change-set adapter reads a resource the export holds and the preview never lists as one an apply() may register.
|
|
770
|
-
return ["preview", "--json", "--show-sames", ...(opts.stack ? ["--stack", opts.stack] : []), ...(opts.targets ?? []).flatMap((t) => ["--target", t])];
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
/**
|
|
774
|
-
* The stack a `pulumi stack export` names in its URNs
|
|
775
|
-
* (`urn:pulumi:<stack>::<project>::...`, #4496), or undefined when it holds
|
|
776
|
-
* no URN that parses or its URNs name more than one stack.
|
|
777
|
-
*/
|
|
778
|
-
export function pulumiExportStack(exported: unknown): string | undefined {
|
|
779
|
-
return soleStack(pulumiExportResources(exported).map((r) => r.urn));
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
/** The one stack a list of URNs names, or undefined when none parses or they disagree. */
|
|
783
|
-
function soleStack(urns: readonly string[]): string | undefined {
|
|
784
|
-
const stacks = new Set(urns.map((u) => parsePulumiUrn(u)?.stack).filter((s): s is string => typeof s === "string" && s.length > 0));
|
|
785
|
-
return stacks.size === 1 ? [...stacks][0] : undefined;
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
/**
|
|
789
|
-
* The stack a member's reads pass as `--stack` (#4496, #4514): the declared
|
|
790
|
-
* one, else the one the checked-in export's URNs name, else the one the
|
|
791
|
-
* given URNs name. Undefined when none says, and the CLI reads the selected
|
|
792
|
-
* stack.
|
|
793
|
-
*/
|
|
794
|
-
export function memberStack(opts: { declared?: string; exported?: unknown; urns?: readonly string[] }): string | undefined {
|
|
795
|
-
return opts.declared || pulumiExportStack(opts.exported) || (opts.urns?.length ? soleStack(opts.urns) : undefined);
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
/**
|
|
799
|
-
* The checked-in `pulumi stack export`, parsed, or undefined when there is
|
|
800
|
-
* none or it does not read. The member's reads below take the index store's
|
|
801
|
-
* export first ({@link memberExportOf}, #4546) and come here when it has none.
|
|
802
|
-
*/
|
|
803
|
-
export function readMemberExport(dir: string): unknown {
|
|
804
|
-
const file = join(dir, PULUMI_EXPORT_FILE);
|
|
805
|
-
if (!existsSync(file)) return undefined;
|
|
806
|
-
try {
|
|
807
|
-
return JSON.parse(readFileSync(file, "utf-8")) as unknown;
|
|
808
|
-
} catch {
|
|
809
|
-
return undefined;
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
/**
|
|
814
|
-
* The member's export for a read (#4546): the one the `pulumi-up` capability
|
|
815
|
-
* wrote to the index store after the stack's last apply through chant, else
|
|
816
|
-
* the checked-in {@link PULUMI_EXPORT_FILE}. `store: null` skips the store.
|
|
817
|
-
* Loaded lazily, since `./stack-export-snapshot.ts` imports this module.
|
|
818
|
-
*/
|
|
819
|
-
export async function memberExportOf(dir: string, opts: { stack?: string; store?: SnapshotStore | null } = {}): Promise<unknown> {
|
|
820
|
-
if (opts.store === null) return readMemberExport(dir);
|
|
821
|
-
const { readMemberExportStored } = await import("./stack-export-snapshot");
|
|
822
|
-
return (await readMemberExportStored(dir, { ...(opts.stack ? { stack: opts.stack } : {}), ...(opts.store !== undefined ? { store: opts.store } : {}) }))?.doc;
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
/** What a failed engine run left: its output, its exit status when it ran, and whether the binary was missing. */
|
|
826
|
-
export interface PulumiRunFailure {
|
|
827
|
-
stdout?: string;
|
|
828
|
-
stderr?: string;
|
|
829
|
-
message: string;
|
|
830
|
-
missingBinary: boolean;
|
|
831
|
-
/** The process's exit status, when it ran and exited (`execFile`'s numeric `code`). */
|
|
832
|
-
exitCode?: number;
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
type RunFailure = PulumiRunFailure;
|
|
836
|
-
|
|
837
|
-
/** A runner's thrown error read as a {@link PulumiRunFailure}. */
|
|
838
|
-
export function pulumiRunFailure(err: unknown): PulumiRunFailure {
|
|
839
|
-
const e = err as (Omit<NodeJS.ErrnoException, "code"> & { code?: unknown; stdout?: unknown; stderr?: unknown }) | undefined;
|
|
840
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
841
|
-
return {
|
|
842
|
-
...(typeof e?.stdout === "string" ? { stdout: e.stdout } : {}),
|
|
843
|
-
...(typeof e?.stderr === "string" ? { stderr: e.stderr } : {}),
|
|
844
|
-
message,
|
|
845
|
-
missingBinary: e?.code === "ENOENT" || /ENOENT|command not found/.test(message),
|
|
846
|
-
...(typeof e?.code === "number" ? { exitCode: e.code } : {}),
|
|
847
|
-
};
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
const failureOf = pulumiRunFailure;
|
|
851
|
-
|
|
852
|
-
function parseJson(text: string | undefined): unknown {
|
|
853
|
-
if (!text) return undefined;
|
|
854
|
-
try {
|
|
855
|
-
return JSON.parse(text) as unknown;
|
|
856
|
-
} catch {
|
|
857
|
-
return undefined;
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
/** The first error diagnostic a preview printed, if any. */
|
|
862
|
-
function diagnosticError(doc: unknown): string | undefined {
|
|
863
|
-
const diagnostics = (doc as { diagnostics?: unknown } | undefined)?.diagnostics;
|
|
864
|
-
if (!Array.isArray(diagnostics)) return undefined;
|
|
865
|
-
const d = diagnostics.find((x) => (x as { severity?: unknown })?.severity === "error") as { message?: unknown } | undefined;
|
|
866
|
-
return typeof d?.message === "string" ? d.message.trim() : undefined;
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
export interface PreviewPulumiMemberOptions {
|
|
870
|
-
member: string;
|
|
871
|
-
/** The member's directory, where Pulumi.yaml is. */
|
|
872
|
-
dir: string;
|
|
873
|
-
/**
|
|
874
|
-
* The stack to preview, passed as `--stack` (#4514): the member's declared
|
|
875
|
-
* stack. Without it, the stack the checked-in export's URNs name, then the
|
|
876
|
-
* one the targets name ({@link memberStack}).
|
|
877
|
-
*/
|
|
878
|
-
stack?: string;
|
|
879
|
-
/** Narrow the preview to these URNs. A narrowed preview does not mark what it leaves out. */
|
|
880
|
-
targets?: readonly string[];
|
|
881
|
-
/** The member's configured engine; see {@link pulumiMemberEngine}. A member on plunge previews with `plunge preview`. */
|
|
882
|
-
engine?: PulumiMemberEngine;
|
|
883
|
-
run?: PulumiRunner;
|
|
884
|
-
/** Runs plunge, for a member on plunge. */
|
|
885
|
-
plunge?: PulumiRunner;
|
|
886
|
-
/** The index store the member's export is read from first (#4546). Default: the project's; `null` reads the checked-in file only. */
|
|
887
|
-
exportStore?: SnapshotStore | null;
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
/** A member's preview: its change-set part, and the preview document it was read from (`{}` when none printed). */
|
|
891
|
-
export interface PulumiMemberPreview {
|
|
892
|
-
part: ChangeSetPart;
|
|
893
|
-
preview: unknown;
|
|
894
|
-
/** The binary that ran. */
|
|
895
|
-
engine: PulumiMemberEngine;
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
/**
|
|
899
|
-
* The member's preview, kept beside its part, so a reader of the stack's
|
|
900
|
-
* planned outputs (`./stack-outputs.ts`, #4455) and the change set read the
|
|
901
|
-
* same run. Never throws for a run that failed: the part is failed.
|
|
902
|
-
*/
|
|
903
|
-
export async function previewPulumiMemberRead(opts: PreviewPulumiMemberOptions): Promise<PulumiMemberPreview> {
|
|
904
|
-
const engine = pulumiMemberEngine(opts.dir, opts.engine).engine;
|
|
905
|
-
const prior = await memberExportOf(opts.dir, { ...(opts.stack ? { stack: opts.stack } : {}), ...(opts.exportStore !== undefined ? { store: opts.exportStore } : {}) });
|
|
906
|
-
const stack = memberStack({ declared: opts.stack, exported: prior, urns: opts.targets });
|
|
907
|
-
const args = pulumiPreviewArgs({ stack, targets: opts.targets });
|
|
908
|
-
const common = { member: opts.member, ...(stack ? { stack } : {}), ...(prior !== undefined ? { prior } : {}), ...(opts.targets?.length ? { targeted: true } : {}) };
|
|
909
|
-
try {
|
|
910
|
-
const { stdout } =
|
|
911
|
-
engine === "plunge"
|
|
912
|
-
? await runAllowedPlunge(opts.plunge ?? defaultPlungeRunner, args, opts.dir)
|
|
913
|
-
: await runAllowedPulumi(opts.run ?? defaultPulumiRunner, args, opts.dir);
|
|
914
|
-
const preview = parseJson(stdout);
|
|
915
|
-
if (preview === undefined) return { part: pulumiPreviewPart({ ...common, preview: {}, error: `${engine} preview --json printed no JSON` }), preview: {}, engine };
|
|
916
|
-
return { part: pulumiPreviewPart({ ...common, preview }), preview, engine };
|
|
917
|
-
} catch (err) {
|
|
918
|
-
const f = failureOf(err);
|
|
919
|
-
const preview = parseJson(f.stdout) ?? {};
|
|
920
|
-
const error = f.missingBinary
|
|
921
|
-
? `the ${engine} binary was not found on PATH; install ${engine} to plan this member`
|
|
922
|
-
: diagnosticError(preview) ?? (f.stderr?.trim() || f.message);
|
|
923
|
-
return { part: pulumiPreviewPart({ ...common, preview, error }), preview, engine };
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
/**
|
|
928
|
-
* The member's change-set part from `pulumi preview --json`. A preview that
|
|
929
|
-
* fails is a failed member, keeping what steps it printed; a missing binary
|
|
930
|
-
* is a failed member that says so. Never throws for a run that failed.
|
|
931
|
-
*/
|
|
932
|
-
export async function previewPulumiMember(opts: PreviewPulumiMemberOptions): Promise<ChangeSetPart> {
|
|
933
|
-
return (await previewPulumiMemberRead(opts)).part;
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
export interface PulumiMemberStackOutputsOptions {
|
|
937
|
-
/** The member's directory, where Pulumi.yaml is. */
|
|
938
|
-
dir: string;
|
|
939
|
-
/**
|
|
940
|
-
* The stack to read, passed as `--stack` (#4514): the member's declared
|
|
941
|
-
* stack. Without it, the stack the checked-in export's URNs name
|
|
942
|
-
* ({@link memberStack}).
|
|
943
|
-
*/
|
|
944
|
-
stack?: string;
|
|
945
|
-
/** The member's configured engine; see {@link pulumiMemberEngine}. */
|
|
946
|
-
engine?: PulumiMemberEngine;
|
|
947
|
-
run?: PulumiRunner;
|
|
948
|
-
plunge?: PulumiRunner;
|
|
949
|
-
/** The index store the member's export is read from first (#4546). Default: the project's; `null` reads the checked-in file only. */
|
|
950
|
-
exportStore?: SnapshotStore | null;
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
/**
|
|
954
|
-
* `pulumi stack output --json --show-secrets=false` in the member's
|
|
955
|
-
* directory (`plunge stack output ...` for a member on plunge), parsed: the
|
|
956
|
-
* stack's applied outputs by name, a secret printed as `[secret]`. Throws
|
|
957
|
-
* when the command fails or prints no JSON object, naming the command.
|
|
958
|
-
*/
|
|
959
|
-
export async function pulumiMemberStackOutputs(opts: PulumiMemberStackOutputsOptions): Promise<Record<string, unknown>> {
|
|
960
|
-
const engine = pulumiMemberEngine(opts.dir, opts.engine).engine;
|
|
961
|
-
const exported = opts.stack ? undefined : await memberExportOf(opts.dir, opts.exportStore !== undefined ? { store: opts.exportStore } : {});
|
|
962
|
-
const args = pulumiStackOutputArgs({ stack: memberStack({ declared: opts.stack, exported }) });
|
|
963
|
-
const command = `${engine} ${args.join(" ")}`;
|
|
964
|
-
let stdout: string;
|
|
965
|
-
try {
|
|
966
|
-
({ stdout } =
|
|
967
|
-
engine === "plunge"
|
|
968
|
-
? await runAllowedPlunge(opts.plunge ?? defaultPlungeRunner, args, opts.dir)
|
|
969
|
-
: await runAllowedPulumi(opts.run ?? defaultPulumiRunner, args, opts.dir));
|
|
970
|
-
} catch (err) {
|
|
971
|
-
const f = failureOf(err);
|
|
972
|
-
const why = f.missingBinary ? `the ${engine} binary was not found on PATH` : (f.stderr?.trim() || f.message).split("\n").slice(-3).join("\n");
|
|
973
|
-
throw new Error(`${command} in ${opts.dir} failed: ${why}`);
|
|
974
|
-
}
|
|
975
|
-
const doc = parseJson(stdout);
|
|
976
|
-
if (doc === null || typeof doc !== "object" || Array.isArray(doc)) throw new Error(`${command} in ${opts.dir} printed no JSON object`);
|
|
977
|
-
return doc as Record<string, unknown>;
|
|
978
|
-
}
|
|
979
|
-
|
|
980
|
-
export interface RefreshPulumiMemberOptions extends DriftAdapterBase {
|
|
981
|
-
dir: string;
|
|
982
|
-
/**
|
|
983
|
-
* The stack to read, passed as `--stack` (#4496): the member's declared
|
|
984
|
-
* `pulumi.member.stack`. Without it, the stack the checked-in export's
|
|
985
|
-
* URNs name, then the one the URNs asked for name. A member with no
|
|
986
|
-
* selected stack can still be refreshed that way.
|
|
987
|
-
*/
|
|
988
|
-
stack?: string;
|
|
989
|
-
/** The URNs to read. Default: the checked-in export's resources, providers and the stack left out. */
|
|
990
|
-
urns?: readonly string[];
|
|
991
|
-
/** The member's configured engine; see {@link pulumiMemberEngine}. */
|
|
992
|
-
engine?: PulumiMemberEngine;
|
|
993
|
-
run?: PulumiRunner;
|
|
994
|
-
/** Runs plunge, for a member on plunge. */
|
|
995
|
-
plunge?: PulumiRunner;
|
|
996
|
-
/** The index store the member's export is read from first (#4546). Default: the project's; `null` reads the checked-in file only. */
|
|
997
|
-
exportStore?: SnapshotStore | null;
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
|
-
function unobservedFor(f: RunFailure): { reason: UnobservedReason; detail: string } {
|
|
1001
|
-
if (f.missingBinary) return { reason: "read-failed", detail: "the pulumi binary was not found on PATH" };
|
|
1002
|
-
const text = `${f.stderr ?? ""}\n${f.message}`;
|
|
1003
|
-
if (/credential|PULUMI_ACCESS_TOKEN|pulumi login|NoCredentialProviders|could not find default credentials/i.test(text)) {
|
|
1004
|
-
return { reason: "no-credentials", detail: (f.stderr?.trim() || f.message).slice(0, 2000) };
|
|
1005
|
-
}
|
|
1006
|
-
return { reason: "read-failed", detail: (diagnosticError(parseJson(f.stdout)) ?? (f.stderr?.trim() || f.message)).slice(0, 2000) };
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
/**
|
|
1010
|
-
* The member's drift records, one `--target`ed `pulumi refresh
|
|
1011
|
-
* --preview-only --json` per URN, run one after another. A run that fails
|
|
1012
|
-
* makes its URN's record not-observed and the others still read. With no
|
|
1013
|
-
* URNs given and no export to take them from (the store's or the checked-in one), one untargeted refresh, which
|
|
1014
|
-
* throws when it fails, since no record names a resource to hang it on.
|
|
1015
|
-
*/
|
|
1016
|
-
export async function refreshPulumiMember(opts: RefreshPulumiMemberOptions): Promise<DriftRecord[]> {
|
|
1017
|
-
const run = opts.run ?? defaultPulumiRunner;
|
|
1018
|
-
const exported = await memberExportOf(opts.dir, { ...(opts.stack ? { stack: opts.stack } : {}), ...(opts.exportStore !== undefined ? { store: opts.exportStore } : {}) });
|
|
1019
|
-
const urns =
|
|
1020
|
-
opts.urns ??
|
|
1021
|
-
(exported === undefined ? undefined : pulumiExportResources(exported).filter((r) => !isPulumiNodeless(r.type)).map((r) => r.urn));
|
|
1022
|
-
// `--stack` (#4496): the declared stack, else the export's, else the URNs'.
|
|
1023
|
-
// Without one the CLI reads the selected stack, and a checked-in member
|
|
1024
|
-
// has none selected.
|
|
1025
|
-
const stack = memberStack({ declared: opts.stack, exported, urns });
|
|
1026
|
-
const base: DriftAdapterBase & { stack?: string } = {
|
|
1027
|
-
member: opts.member,
|
|
1028
|
-
observedAt: opts.observedAt,
|
|
1029
|
-
...(opts.graph !== undefined ? { graph: opts.graph } : {}),
|
|
1030
|
-
...(opts.fellBackFrom !== undefined ? { fellBackFrom: opts.fellBackFrom } : {}),
|
|
1031
|
-
...(opts.version !== undefined ? { version: opts.version } : {}),
|
|
1032
|
-
...(stack ? { stack } : {}),
|
|
1033
|
-
};
|
|
1034
|
-
|
|
1035
|
-
if (pulumiMemberEngine(opts.dir, opts.engine).engine === "plunge") {
|
|
1036
|
-
// plunge drift reads one resource at a time, so it needs the URNs.
|
|
1037
|
-
if (urns === undefined) throw new Error(`member ${opts.member} runs on plunge, whose drift reads one resource at a time, and has no ${PULUMI_EXPORT_FILE} to take the URNs from`);
|
|
1038
|
-
const plunge = opts.plunge ?? defaultPlungeRunner;
|
|
1039
|
-
const reads: PlungeDriftRead[] = [];
|
|
1040
|
-
for (const urn of urns) {
|
|
1041
|
-
try {
|
|
1042
|
-
const { stdout } = await runAllowedPlunge(plunge, plungeDriftArgs({ urn, stack, member: opts.member }), opts.dir);
|
|
1043
|
-
reads.push({ urn, stream: stdout });
|
|
1044
|
-
} catch (err) {
|
|
1045
|
-
const f = failureOf(err);
|
|
1046
|
-
reads.push(f.stdout && !f.missingBinary ? { urn, stream: f.stdout } : { urn, failed: f.missingBinary ? { reason: "read-failed", detail: "the plunge binary was not found on PATH" } : unobservedFor(f) });
|
|
1047
|
-
}
|
|
1048
|
-
}
|
|
1049
|
-
return plungeDriftStreamRecords({ ...base, reads });
|
|
1050
|
-
}
|
|
1051
|
-
|
|
1052
|
-
if (urns === undefined) {
|
|
1053
|
-
try {
|
|
1054
|
-
const { stdout } = await runAllowedPulumi(run, pulumiRefreshArgs({ stack }), opts.dir);
|
|
1055
|
-
return pulumiRefreshDocumentRecords({ ...base, refresh: parseJson(stdout) ?? {} });
|
|
1056
|
-
} catch (err) {
|
|
1057
|
-
// Nothing names the resources, so the failure has no record to sit on.
|
|
1058
|
-
const why = unobservedFor(failureOf(err));
|
|
1059
|
-
throw new Error(`pulumi refresh --preview-only for member ${opts.member} failed (${why.reason}): ${why.detail}`);
|
|
1060
|
-
}
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1063
|
-
const reads: PulumiRefreshRead[] = [];
|
|
1064
|
-
for (const urn of urns) {
|
|
1065
|
-
try {
|
|
1066
|
-
const { stdout } = await runAllowedPulumi(run, pulumiRefreshArgs({ urn, stack }), opts.dir);
|
|
1067
|
-
reads.push({ urn, refresh: parseJson(stdout) });
|
|
1068
|
-
} catch (err) {
|
|
1069
|
-
const f = failureOf(err);
|
|
1070
|
-
// A refresh that failed may still have printed the step for its target.
|
|
1071
|
-
const printed = parseJson(f.stdout);
|
|
1072
|
-
reads.push(printed !== undefined && !f.missingBinary ? { urn, refresh: printed } : { urn, failed: unobservedFor(f) });
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
return pulumiRefreshDriftRecords({ ...base, reads });
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
export interface PlungeMemberGraphOptions {
|
|
1079
|
-
/** The member's directory, where Pulumi.yaml is. */
|
|
1080
|
-
dir: string;
|
|
1081
|
-
/**
|
|
1082
|
-
* The stack to read, passed as `--stack`: the member's declared stack.
|
|
1083
|
-
* Without it, the stack the checked-in export's URNs name
|
|
1084
|
-
* ({@link memberStack}), as for every other read.
|
|
1085
|
-
*/
|
|
1086
|
-
stack?: string;
|
|
1087
|
-
/** Pass `--versions`: each node lists its record's versions, one version listing per record (#4520 Q6). Off by default. */
|
|
1088
|
-
versions?: boolean;
|
|
1089
|
-
plunge?: PulumiRunner;
|
|
1090
|
-
/** The index store the member's export is read from first (#4546). Default: the project's; `null` reads the checked-in file only. */
|
|
1091
|
-
exportStore?: SnapshotStore | null;
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
/** What one `plunge graph` run gave: the parsed document, or why there is none. */
|
|
1095
|
-
export type PlungeMemberGraphRead =
|
|
1096
|
-
| { ok: true; doc: unknown; command: string; stack?: string }
|
|
1097
|
-
| { ok: false; command: string; stack?: string; reason: UnobservedReason; detail: string };
|
|
1098
|
-
|
|
1099
|
-
/**
|
|
1100
|
-
* `plunge graph --json [--stack <stack>] [--versions]` in the member's
|
|
1101
|
-
* directory (#4529): the stack's engine graph from its records, in
|
|
1102
|
-
* chant#4520's document. plunge makes no provider call for it and prints no
|
|
1103
|
-
* output value. Never throws for a run that failed: the read says why. A
|
|
1104
|
-
* plunge older than the command (INTENTIUS/plunge#40) fails it with cobra's
|
|
1105
|
-
* unknown-command error, and the read says that plunge has no `graph`.
|
|
1106
|
-
*
|
|
1107
|
-
* Only a member on plunge runs it. The caller decides that with
|
|
1108
|
-
* {@link pulumiMemberEngine}; nothing here runs stock `pulumi`.
|
|
1109
|
-
*/
|
|
1110
|
-
export async function plungeMemberGraph(opts: PlungeMemberGraphOptions): Promise<PlungeMemberGraphRead> {
|
|
1111
|
-
const exported = opts.stack ? undefined : await memberExportOf(opts.dir, opts.exportStore !== undefined ? { store: opts.exportStore } : {});
|
|
1112
|
-
const stack = memberStack({ declared: opts.stack, exported });
|
|
1113
|
-
const args = plungeGraphArgs({ stack, ...(opts.versions ? { versions: true } : {}) });
|
|
1114
|
-
const command = `plunge ${args.join(" ")}`;
|
|
1115
|
-
const at = { command, ...(stack ? { stack } : {}) };
|
|
1116
|
-
try {
|
|
1117
|
-
const { stdout } = await runAllowedPlunge(opts.plunge ?? defaultPlungeRunner, args, opts.dir);
|
|
1118
|
-
const doc = parseJson(stdout);
|
|
1119
|
-
if (doc === undefined) return { ok: false, ...at, reason: "read-failed", detail: `${command} printed no JSON` };
|
|
1120
|
-
return { ok: true, doc, ...at };
|
|
1121
|
-
} catch (err) {
|
|
1122
|
-
const f = failureOf(err);
|
|
1123
|
-
if (f.missingBinary) return { ok: false, ...at, reason: "read-failed", detail: "the plunge binary was not found on PATH" };
|
|
1124
|
-
if (/unknown command "graph"/.test(`${f.stderr ?? ""}\n${f.message}`)) {
|
|
1125
|
-
return { ok: false, ...at, reason: "read-failed", detail: "this plunge has no `plunge graph` (INTENTIUS/plunge#40); a plunge that has it gives the member's engine facts" };
|
|
1126
|
-
}
|
|
1127
|
-
return { ok: false, ...at, ...unobservedFor(f) };
|
|
1128
|
-
}
|
|
1129
|
-
}
|