@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/pulumi-up.test.ts
DELETED
|
@@ -1,581 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The `pulumi-up` capability (#4541): plan and apply a Pulumi or plunge
|
|
3
|
-
* stack as a component step, under the 2026-10-27 rulings (A: a stock apply
|
|
4
|
-
* compares its event stream with the approved shape; B: same and read steps
|
|
5
|
-
* leave the digest on the resource grain; C: the preview streams, and
|
|
6
|
-
* CrossGuard's events feed the gate; D: no approved plan means preview and
|
|
7
|
-
* up in one go).
|
|
8
|
-
*
|
|
9
|
-
* The runners are fakes answering with `testdata/pulumi-stream` (the
|
|
10
|
-
* recorded corpus preview in stream form; see its README) and the recorded
|
|
11
|
-
* `stack output`. No pulumi or plunge binary runs here, and nothing reaches
|
|
12
|
-
* a backend.
|
|
13
|
-
*/
|
|
14
|
-
import { execFileSync } from "node:child_process";
|
|
15
|
-
import { copyFileSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
|
|
16
|
-
import { tmpdir } from "node:os";
|
|
17
|
-
import { join, relative } from "node:path";
|
|
18
|
-
import { describe, expect, test } from "vitest";
|
|
19
|
-
import { isPlanMovedError, type DeployContext } from "@intentius/chant/components/capability";
|
|
20
|
-
import { PlanShapeMovedError } from "@intentius/chant/components/covered-round";
|
|
21
|
-
import { pulumiPreviewDigest, pulumiResourceDigests } from "./change-set";
|
|
22
|
-
import { pulumiStreamPreview, PULUMI_STREAMING_PREVIEW_ENV } from "./engine-events";
|
|
23
|
-
import {
|
|
24
|
-
createPulumiUpCapability,
|
|
25
|
-
pulumiReleaseInputs,
|
|
26
|
-
pulumiReviewStep,
|
|
27
|
-
pulumiScratchConfig,
|
|
28
|
-
PR_ENV_TEMPLATE_VARIABLE,
|
|
29
|
-
pulumiUpMember,
|
|
30
|
-
PulumiAppliedShapeError,
|
|
31
|
-
PulumiPlanMovedError,
|
|
32
|
-
PulumiPolicyDeniedError,
|
|
33
|
-
PulumiResourceGrainRefusedError,
|
|
34
|
-
type PulumiUpArtifact,
|
|
35
|
-
type PulumiUpStepInput,
|
|
36
|
-
} from "./pulumi-up";
|
|
37
|
-
import type { PulumiRunner } from "./run";
|
|
38
|
-
|
|
39
|
-
const testdata = join(import.meta.dirname, "testdata");
|
|
40
|
-
const dir = join(testdata, "pulumi-preview");
|
|
41
|
-
const stream = readFileSync(join(testdata, "pulumi-stream", "preview-stream.ndjson"), "utf-8");
|
|
42
|
-
const upStream = stream.replaceAll(',"planning":true', "");
|
|
43
|
-
const stackOutput = readFileSync(join(testdata, "pulumi-outputs", "stack-output.json"), "utf-8");
|
|
44
|
-
const urn = (type: string, name: string) => `urn:pulumi:floci::corpus-aws-ts::${type}::${name}`;
|
|
45
|
-
const ctx: DeployContext = { env: "prod", component: "site" };
|
|
46
|
-
const member = "corpus-aws-ts/floci";
|
|
47
|
-
|
|
48
|
-
interface Call {
|
|
49
|
-
args: string[];
|
|
50
|
-
cwd: string;
|
|
51
|
-
env?: Record<string, string>;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** A runner that answers by command; `up` may be overridden per test. */
|
|
55
|
-
function engine(answers: { preview?: () => string | Error; up?: () => string | Error } = {}): { run: PulumiRunner; calls: Call[] } {
|
|
56
|
-
const calls: Call[] = [];
|
|
57
|
-
const run: PulumiRunner = async (args, opts) => {
|
|
58
|
-
calls.push({ args, cwd: opts.cwd, ...(opts.env ? { env: opts.env } : {}) });
|
|
59
|
-
// plunge writes the saved plan where --save-plan says; the fake does too, so run finds it.
|
|
60
|
-
const save = args.indexOf("--save-plan");
|
|
61
|
-
if (save >= 0) writeFileSync(args[save + 1], "{}\n");
|
|
62
|
-
const out = args[0] === "preview" ? (answers.preview ?? (() => stream))() : args[0] === "up" ? (answers.up ?? (() => upStream))() : stackOutput;
|
|
63
|
-
if (out instanceof Error) throw out;
|
|
64
|
-
return { stdout: out };
|
|
65
|
-
};
|
|
66
|
-
return { run, calls };
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const exit = (code: number, stdout = "", message = `exit ${code}`): Error => Object.assign(new Error(message), { code, stdout });
|
|
70
|
-
const tmp = (): string => mkdtempSync(join(tmpdir(), "pulumi-up-test-"));
|
|
71
|
-
const step = (extra: Partial<PulumiUpStepInput> = {}): PulumiUpStepInput => ({ dir, stack: "floci", ...extra });
|
|
72
|
-
|
|
73
|
-
describe("the step", () => {
|
|
74
|
-
test("its member is <Pulumi.yaml name>/<stack>, or the member given", () => {
|
|
75
|
-
expect(pulumiUpMember(step())).toBe(member);
|
|
76
|
-
expect(pulumiUpMember(step({ member: "site" }))).toBe("site/floci");
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
test("a step with no dir or stack is refused", async () => {
|
|
80
|
-
const cap = createPulumiUpCapability({ run: engine().run, env: {}, snapshots: null });
|
|
81
|
-
await expect(cap.plan!(ctx, { dir: "", stack: "floci" })).rejects.toThrow(/needs "dir"/);
|
|
82
|
-
await expect(cap.plan!(ctx, { dir, stack: "" })).rejects.toThrow(/needs "stack"/);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
test("a stock member on the resource grain is refused by name (#4552)", async () => {
|
|
86
|
-
const cap = createPulumiUpCapability({ run: engine().run, env: {}, snapshots: null });
|
|
87
|
-
await expect(cap.plan!(ctx, step({ engine: "pulumi", lockGrain: "resource" }))).rejects.toBeInstanceOf(PulumiResourceGrainRefusedError);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
describe("plan on plunge", () => {
|
|
92
|
-
test("streams the preview, saves the plan in a scratch dir and answers digest, part, shape and outputs", async () => {
|
|
93
|
-
const plunge = engine();
|
|
94
|
-
const scratch = tmp();
|
|
95
|
-
const cap = createPulumiUpCapability({ plunge: plunge.run, env: {}, tmp: scratch, snapshots: null });
|
|
96
|
-
const planned = await cap.plan!(ctx, step({ engine: "plunge" }));
|
|
97
|
-
const artifact = planned.artifact as PulumiUpArtifact;
|
|
98
|
-
expect(plunge.calls).toHaveLength(1);
|
|
99
|
-
const call = plunge.calls[0];
|
|
100
|
-
expect(call.cwd).toBe(dir);
|
|
101
|
-
expect(call.env).toEqual({ [PULUMI_STREAMING_PREVIEW_ENV]: "true" });
|
|
102
|
-
expect(call.args).toEqual(["preview", "--json", "--show-sames", "--stack", "floci", "--save-plan", artifact.planFile]);
|
|
103
|
-
expect(artifact.planFile!.startsWith(scratch)).toBe(true);
|
|
104
|
-
expect(artifact).toMatchObject({ kind: "pulumi-up", member, stack: "floci", engine: "plunge", engineSource: "member-config" });
|
|
105
|
-
expect(planned.member).toBe(member);
|
|
106
|
-
// Ruling B: plunge defaults to the resource grain, so same and read steps leave the digest.
|
|
107
|
-
expect(planned.planDigest).toBe(pulumiPreviewDigest(pulumiStreamPreview(stream), { changedOnly: true }));
|
|
108
|
-
expect(planned.changeSet?.member.planDigest).toBe(planned.planDigest);
|
|
109
|
-
expect(planned.shape?.entries.map((e) => e.action).sort()).toEqual(["delete", "delete", "replace", "replace", "update", "update"]);
|
|
110
|
-
expect(planned.outputs).toBeDefined();
|
|
111
|
-
expect(artifact.policy.warnings).toHaveLength(1);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
test("answers a digest for each resource the preview changes, on either grain (plywood#55)", async () => {
|
|
115
|
-
const cap = createPulumiUpCapability({ plunge: engine().run, env: {}, tmp: tmp(), snapshots: null });
|
|
116
|
-
const resource = await cap.plan!(ctx, step({ engine: "plunge" }));
|
|
117
|
-
const stack = await cap.plan!(ctx, step({ engine: "plunge", lockGrain: "target" }));
|
|
118
|
-
expect(resource.resourceDigests).toEqual(pulumiResourceDigests(pulumiStreamPreview(stream)));
|
|
119
|
-
expect(stack.resourceDigests).toEqual(resource.resourceDigests);
|
|
120
|
-
const changed = (pulumiStreamPreview(stream) as { steps: { op: string }[] }).steps.filter((x) => x.op !== "same" && x.op !== "read");
|
|
121
|
-
expect(Object.keys(resource.resourceDigests!).length).toBeGreaterThan(0);
|
|
122
|
-
expect(Object.keys(resource.resourceDigests!).length).toBeLessThanOrEqual(changed.length);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
test("the target grain keeps every step in the digest", async () => {
|
|
126
|
-
const cap = createPulumiUpCapability({ plunge: engine().run, env: {}, tmp: tmp(), snapshots: null });
|
|
127
|
-
const planned = await cap.plan!(ctx, step({ engine: "plunge", lockGrain: "target" }));
|
|
128
|
-
expect(planned.planDigest).toBe(pulumiPreviewDigest(pulumiStreamPreview(stream)));
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
test("config goes into a scratch copy of the stack's file, passed as --config-file, never --config", async () => {
|
|
132
|
-
const plunge = engine();
|
|
133
|
-
const cap = createPulumiUpCapability({ plunge: plunge.run, env: {}, tmp: tmp(), snapshots: null });
|
|
134
|
-
const planned = await cap.plan!(ctx, step({ engine: "plunge", config: { vpcId: "vpc-1", "aws:region": "us-east-1", later: undefined } }));
|
|
135
|
-
const artifact = planned.artifact as PulumiUpArtifact;
|
|
136
|
-
const args = plunge.calls[0].args;
|
|
137
|
-
expect(args).toContain("--config-file");
|
|
138
|
-
expect(args).not.toContain("--config");
|
|
139
|
-
expect(args[args.indexOf("--config-file") + 1]).toBe(artifact.configFile);
|
|
140
|
-
expect(JSON.parse(readFileSync(artifact.configFile!, "utf-8"))).toEqual({ config: { "corpus-aws-ts:vpcId": "vpc-1", "aws:region": "us-east-1" } });
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
test("targets and policy packs pass to the preview in the fixed order", async () => {
|
|
144
|
-
const plunge = engine();
|
|
145
|
-
const cap = createPulumiUpCapability({ plunge: plunge.run, env: {}, tmp: tmp(), snapshots: null });
|
|
146
|
-
const target = urn("aws:sqs/queue:Queue", "events");
|
|
147
|
-
const planned = await cap.plan!({ ...ctx, targets: [target] }, step({ engine: "plunge", policyPacks: [{ dir: "/packs/org", config: "/packs/org.json" }] }));
|
|
148
|
-
const args = plunge.calls[0].args;
|
|
149
|
-
expect(args.slice(7)).toEqual(["--target", target, "--policy-pack", "/packs/org", "--policy-pack-config", "/packs/org.json"]);
|
|
150
|
-
expect(planned.targets).toEqual([target]);
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
test("a mandatory CrossGuard violation denies the plan, whatever the exit", async () => {
|
|
154
|
-
const violation = JSON.stringify({ policyEvent: { message: "no public buckets", policyName: "s3-private", policyPackName: "org", policyPackVersion: "1", enforcementLevel: "mandatory" } });
|
|
155
|
-
const failing = createPulumiUpCapability({ plunge: engine({ preview: () => exit(1, `${stream}${violation}\n`) }).run, env: {}, tmp: tmp(), snapshots: null });
|
|
156
|
-
const err = await failing.plan!(ctx, step({ engine: "plunge" })).catch((e: unknown) => e);
|
|
157
|
-
expect(err).toBeInstanceOf(PulumiPolicyDeniedError);
|
|
158
|
-
expect((err as PulumiPolicyDeniedError).findings.denials.map((d) => d.rule)).toEqual(["crossguard.org.s3-private"]);
|
|
159
|
-
expect((err as PulumiPolicyDeniedError).exitCode).toBe(7);
|
|
160
|
-
const passing = createPulumiUpCapability({ plunge: engine({ preview: () => `${stream}${violation}\n` }).run, env: {}, tmp: tmp(), snapshots: null });
|
|
161
|
-
await expect(passing.plan!(ctx, step({ engine: "plunge" }))).rejects.toBeInstanceOf(PulumiPolicyDeniedError);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
test("Pulumi's policy exit denies too (#4553: policy is 7)", async () => {
|
|
165
|
-
const cap = createPulumiUpCapability({ plunge: engine({ preview: () => exit(5, stream) }).run, env: {}, tmp: tmp(), snapshots: null });
|
|
166
|
-
await expect(cap.plan!(ctx, step({ engine: "plunge" }))).rejects.toBeInstanceOf(PulumiPolicyDeniedError);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
test("a failed preview throws with the engine's error, and a missing binary says so", async () => {
|
|
170
|
-
const diag = JSON.stringify({ diagnosticEvent: { message: "error: stack floci not found", severity: "error" } });
|
|
171
|
-
const failed = createPulumiUpCapability({ plunge: engine({ preview: () => exit(6, `${diag}\n`) }).run, env: {}, tmp: tmp(), snapshots: null });
|
|
172
|
-
await expect(failed.plan!(ctx, step({ engine: "plunge" }))).rejects.toThrow(/plunge preview failed: error: stack floci not found/);
|
|
173
|
-
const missing = createPulumiUpCapability({ plunge: engine({ preview: () => Object.assign(new Error("spawn plunge ENOENT"), { code: "ENOENT" }) }).run, env: {}, tmp: tmp(), snapshots: null });
|
|
174
|
-
await expect(missing.plan!(ctx, step({ engine: "plunge" }))).rejects.toThrow(/plunge binary was not found/);
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
test("a stack whose config reads an output not known yet is a hole naming it", async () => {
|
|
178
|
-
const plunge = engine();
|
|
179
|
-
const cap = createPulumiUpCapability({ plunge: plunge.run, env: {}, tmp: tmp(), snapshots: null });
|
|
180
|
-
const planned = await cap.plan!({ ...ctx, unresolvedInputs: ["network.vpcId"] }, step({ engine: "plunge", config: { vpcId: undefined } }));
|
|
181
|
-
expect(plunge.calls).toEqual([]);
|
|
182
|
-
expect(planned.artifact).toBeUndefined();
|
|
183
|
-
expect(planned.changeSet?.member.holes[0].reason).toMatch(/network\.vpcId/);
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
describe("run on plunge", () => {
|
|
188
|
-
test("applies the saved plan with plunge up --plan <file> --yes --json --stack, then reads the outputs", async () => {
|
|
189
|
-
const plunge = engine();
|
|
190
|
-
const cap = createPulumiUpCapability({ plunge: plunge.run, env: {}, tmp: tmp(), snapshots: null });
|
|
191
|
-
const planned = await cap.plan!(ctx, step({ engine: "plunge" }));
|
|
192
|
-
const artifact = planned.artifact as PulumiUpArtifact;
|
|
193
|
-
const out = await cap.run({ ...ctx, plans: { [member]: artifact } }, step({ engine: "plunge" }));
|
|
194
|
-
expect(plunge.calls.map((c) => c.args)).toEqual([
|
|
195
|
-
["preview", "--json", "--show-sames", "--stack", "floci", "--save-plan", artifact.planFile],
|
|
196
|
-
["up", "--plan", artifact.planFile, "--yes", "--json", "--stack", "floci"],
|
|
197
|
-
["stack", "output", "--json", "--show-secrets=false", "--stack", "floci"],
|
|
198
|
-
]);
|
|
199
|
-
expect(out).toMatchObject({ member, stack: "floci", engine: "plunge", planDigest: planned.planDigest, fromWavePlan: true });
|
|
200
|
-
expect(out.outputs.dbPasswordValue).toBe("[secret]");
|
|
201
|
-
expect(out.summary?.resourceChanges).toEqual({ delete: 2, replace: 2, same: 11, update: 2 });
|
|
202
|
-
// The scratch dir with the plan file is gone once the apply is done.
|
|
203
|
-
expect(existsSync(artifact.scratch)).toBe(false);
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
test("plunge's exit 40 is a moved plan: core's mark, the table's 4", async () => {
|
|
207
|
-
const plunge = engine({ up: () => exit(40, "", "error: the saved plan is stale") });
|
|
208
|
-
const cap = createPulumiUpCapability({ plunge: plunge.run, env: {}, tmp: tmp(), snapshots: null });
|
|
209
|
-
const artifact = (await cap.plan!(ctx, step({ engine: "plunge" }))).artifact;
|
|
210
|
-
const err = await cap.run({ ...ctx, plans: { [member]: artifact } }, step({ engine: "plunge" })).catch((e: unknown) => e);
|
|
211
|
-
expect(err).toBeInstanceOf(PulumiPlanMovedError);
|
|
212
|
-
expect(isPlanMovedError(err)).toBe(true);
|
|
213
|
-
expect((err as Error).message).toMatch(/refusing to apply/);
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
test("any other exit fails, naming what landed", async () => {
|
|
217
|
-
const partial = upStream.split("\n").slice(0, 10).join("\n");
|
|
218
|
-
const plunge = engine({ up: () => exit(4, partial, "error: RecordConflictError") });
|
|
219
|
-
const cap = createPulumiUpCapability({ plunge: plunge.run, env: {}, tmp: tmp(), snapshots: null });
|
|
220
|
-
const artifact = (await cap.plan!(ctx, step({ engine: "plunge" }))).artifact;
|
|
221
|
-
const err = await cap.run({ ...ctx, plans: { [member]: artifact } }, step({ engine: "plunge" })).catch((e: unknown) => e);
|
|
222
|
-
expect(isPlanMovedError(err)).toBe(false);
|
|
223
|
-
expect((err as Error).message).toMatch(/plunge up failed \(exit 4\)/);
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
test("ruling D: with no approved plan it previews and applies in one go", async () => {
|
|
227
|
-
const plunge = engine();
|
|
228
|
-
const cap = createPulumiUpCapability({ plunge: plunge.run, env: {}, tmp: tmp(), snapshots: null });
|
|
229
|
-
const out = await cap.run(ctx, step({ engine: "plunge" }));
|
|
230
|
-
expect(plunge.calls.map((c) => c.args[0])).toEqual(["preview", "up", "stack"]);
|
|
231
|
-
expect(out.fromWavePlan).toBe(false);
|
|
232
|
-
});
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
describe("run on stock Pulumi (ruling A)", () => {
|
|
236
|
-
const stock = (extra: Partial<PulumiUpStepInput> = {}) => step({ engine: "pulumi", ...extra });
|
|
237
|
-
|
|
238
|
-
test("previews again, applies with pulumi up --yes --json --stack, and compares the stream with the approved shape", async () => {
|
|
239
|
-
const pulumi = engine();
|
|
240
|
-
const cap = createPulumiUpCapability({ run: pulumi.run, env: {}, tmp: tmp(), snapshots: null });
|
|
241
|
-
const planned = await cap.plan!(ctx, stock());
|
|
242
|
-
expect(planned.planDigest).toBe(pulumiPreviewDigest(pulumiStreamPreview(stream)));
|
|
243
|
-
const out = await cap.run({ ...ctx, plans: { [member]: planned.artifact } }, stock());
|
|
244
|
-
expect(pulumi.calls.map((c) => c.args)).toEqual([
|
|
245
|
-
["preview", "--json", "--show-sames", "--stack", "floci"],
|
|
246
|
-
["preview", "--json", "--show-sames", "--stack", "floci"],
|
|
247
|
-
["up", "--yes", "--json", "--stack", "floci"],
|
|
248
|
-
["stack", "output", "--json", "--show-secrets=false", "--stack", "floci"],
|
|
249
|
-
]);
|
|
250
|
-
expect(pulumi.calls[2].env).toBeUndefined();
|
|
251
|
-
expect(out).toMatchObject({ engine: "pulumi", fromWavePlan: true });
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
test("a fresh preview beyond the approved shape refuses before up: moved", async () => {
|
|
255
|
-
const extra = JSON.stringify({ resourcePreEvent: { metadata: { op: "create", urn: urn("aws:s3/bucket:Bucket", "extra"), type: "aws:s3/bucket:Bucket", new: { type: "aws:s3/bucket:Bucket", inputs: { bucket: "extra" } }, logical: true }, planning: true } });
|
|
256
|
-
let previews = 0;
|
|
257
|
-
const pulumi = engine({ preview: () => (++previews === 1 ? stream : `${stream}${extra}\n`) });
|
|
258
|
-
const cap = createPulumiUpCapability({ run: pulumi.run, env: {}, tmp: tmp(), snapshots: null });
|
|
259
|
-
const artifact = (await cap.plan!(ctx, stock())).artifact;
|
|
260
|
-
const err = await cap.run({ ...ctx, plans: { [member]: artifact } }, stock()).catch((e: unknown) => e);
|
|
261
|
-
expect(err).toBeInstanceOf(PlanShapeMovedError);
|
|
262
|
-
expect(isPlanMovedError(err)).toBe(true);
|
|
263
|
-
expect(pulumi.calls.some((c) => c.args[0] === "up")).toBe(false);
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
test("an up whose stream ran a step the approval did not hold fails the step, not moved", async () => {
|
|
267
|
-
const extra = JSON.stringify({ resourcePreEvent: { metadata: { op: "create", urn: urn("aws:s3/bucket:Bucket", "drifted"), type: "aws:s3/bucket:Bucket", new: { type: "aws:s3/bucket:Bucket", inputs: { bucket: "drifted" } }, logical: true } } });
|
|
268
|
-
const pulumi = engine({ up: () => `${upStream}${extra}\n` });
|
|
269
|
-
const cap = createPulumiUpCapability({ run: pulumi.run, env: {}, tmp: tmp(), snapshots: null });
|
|
270
|
-
const artifact = (await cap.plan!(ctx, stock())).artifact;
|
|
271
|
-
const err = await cap.run({ ...ctx, plans: { [member]: artifact } }, stock()).catch((e: unknown) => e);
|
|
272
|
-
expect(err).toBeInstanceOf(PulumiAppliedShapeError);
|
|
273
|
-
expect(isPlanMovedError(err)).toBe(false);
|
|
274
|
-
expect((err as PulumiAppliedShapeError).differences[0]).toMatch(/drifted/);
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
test("ruling D on stock: one preview, then up", async () => {
|
|
278
|
-
const pulumi = engine();
|
|
279
|
-
const cap = createPulumiUpCapability({ run: pulumi.run, env: {}, tmp: tmp(), snapshots: null });
|
|
280
|
-
await cap.run(ctx, stock());
|
|
281
|
-
expect(pulumi.calls.map((c) => c.args[0])).toEqual(["preview", "up", "stack"]);
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
test("outputs reads the blind stack output", async () => {
|
|
285
|
-
const pulumi = engine();
|
|
286
|
-
const cap = createPulumiUpCapability({ run: pulumi.run, env: {}, snapshots: null });
|
|
287
|
-
expect((await cap.outputs!(ctx, stock())).vpcId).toBe("vpc-05097b38");
|
|
288
|
-
expect(pulumi.calls.map((c) => c.args)).toEqual([["stack", "output", "--json", "--show-secrets=false", "--stack", "floci"]]);
|
|
289
|
-
});
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
describe("the scratch config", () => {
|
|
293
|
-
test("a key with no colon is the project's own, and a null value is not written", () => {
|
|
294
|
-
expect(JSON.parse(pulumiScratchConfig(dir, "floci", { a: "1", "aws:region": "x", b: null }))).toEqual({ config: { "corpus-aws-ts:a": "1", "aws:region": "x" } });
|
|
295
|
-
});
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
describe("releaseInputs (#4542)", () => {
|
|
299
|
-
test("answers the stack's directory, relative to the member", () => {
|
|
300
|
-
expect(pulumiReleaseInputs({ dir: "pulumi-preview", stack: "floci" }, { memberDir: testdata })).toEqual({ field: "dir", dir: "pulumi-preview", paths: ["pulumi-preview"] });
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
test("a directory with no Pulumi.yaml deploys nothing local", () => {
|
|
304
|
-
expect(pulumiReleaseInputs({ dir: "pulumi-stream", stack: "floci" }, { memberDir: testdata })).toBeNull();
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
test("an absolute plunge file backend is bound", () => {
|
|
308
|
-
// testdata/plunge-member names plunge+file:///var/lib/plunge/site.
|
|
309
|
-
expect(pulumiReleaseInputs({ dir: "plunge-member", stack: "floci" }, { memberDir: testdata })).toMatchObject({ field: "dir", dir: "plunge-member" });
|
|
310
|
-
});
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
describe("the step's backend (plywood#22)", () => {
|
|
314
|
-
const store = "plunge+s3://plywood-tutorial-plunge?region=us-east-1&endpoint=http://floci:4566&s3ForcePathStyle=true";
|
|
315
|
-
|
|
316
|
-
test("plunge's preview, up and output read each get it as PULUMI_BACKEND_URL, over the job's", async () => {
|
|
317
|
-
const plunge = engine();
|
|
318
|
-
const cap = createPulumiUpCapability({ plunge: plunge.run, env: { PULUMI_BACKEND_URL: "file:///tmp/plywood-tutorial-backend" }, tmp: tmp(), snapshots: null });
|
|
319
|
-
const planned = await cap.plan!(ctx, step({ engine: "plunge", backend: store }));
|
|
320
|
-
await cap.run({ ...ctx, plans: { [member]: planned.artifact as PulumiUpArtifact } }, step({ engine: "plunge", backend: store }));
|
|
321
|
-
expect(plunge.calls.map((c) => c.args[0])).toEqual(["preview", "up", "stack"]);
|
|
322
|
-
for (const c of plunge.calls) expect(c.env?.PULUMI_BACKEND_URL).toBe(store);
|
|
323
|
-
// The preview keeps its streaming flag beside the backend.
|
|
324
|
-
expect(plunge.calls[0].env).toEqual({ [PULUMI_STREAMING_PREVIEW_ENV]: "true", PULUMI_BACKEND_URL: store });
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
test("stock Pulumi's preview, up and output read get it too, and outputs() reads through it", async () => {
|
|
328
|
-
const pulumi = engine();
|
|
329
|
-
const s3 = "s3://plywood-tutorial-state?region=us-east-1&endpoint=http://floci:4566&use_path_style=true";
|
|
330
|
-
const cap = createPulumiUpCapability({ run: pulumi.run, env: {}, tmp: tmp(), snapshots: null });
|
|
331
|
-
const planned = await cap.plan!(ctx, step({ engine: "pulumi", backend: s3 }));
|
|
332
|
-
await cap.run({ ...ctx, plans: { [member]: planned.artifact as PulumiUpArtifact } }, step({ engine: "pulumi", backend: s3 }));
|
|
333
|
-
await cap.outputs!(ctx, step({ engine: "pulumi", backend: s3 }));
|
|
334
|
-
expect(pulumi.calls.length).toBeGreaterThanOrEqual(4);
|
|
335
|
-
for (const c of pulumi.calls) expect(c.env?.PULUMI_BACKEND_URL).toBe(s3);
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
test("a plunge+ backend picks plunge where the job's PULUMI_BACKEND_URL would have picked stock Pulumi", async () => {
|
|
339
|
-
const plunge = engine();
|
|
340
|
-
const pulumi = engine();
|
|
341
|
-
const cap = createPulumiUpCapability({ run: pulumi.run, plunge: plunge.run, env: { PULUMI_BACKEND_URL: "file:///tmp/b" }, tmp: tmp(), snapshots: null });
|
|
342
|
-
const planned = await cap.plan!(ctx, step({ backend: store }));
|
|
343
|
-
expect((planned.artifact as PulumiUpArtifact).engine).toBe("plunge");
|
|
344
|
-
expect(pulumi.calls).toHaveLength(0);
|
|
345
|
-
expect(cap.defaultLockGrain!(step({ backend: store }))).toBe("resource");
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
test("the ledger lock (ruling for ci-products 2026-10-28): a stack's target row is its stack row, from Pulumi.yaml's name", () => {
|
|
349
|
-
const cap = createPulumiUpCapability({ env: {}, tmp: tmp(), snapshots: null });
|
|
350
|
-
expect(cap.targetLockRow!(step())).toEqual({ key: "stack corpus-aws-ts/floci", target: member, address: "corpus-aws-ts/floci" });
|
|
351
|
-
// A plunge stack on the resource grain still leases URN rows; the stack row it may also take meets this one.
|
|
352
|
-
expect(cap.targetLockRow!(step({ stack: "prod-us" }))).toMatchObject({ key: "stack corpus-aws-ts/prod-us" });
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
test("without it nothing changes: no PULUMI_BACKEND_URL is added", async () => {
|
|
356
|
-
const plunge = engine();
|
|
357
|
-
const cap = createPulumiUpCapability({ plunge: plunge.run, env: {}, tmp: tmp(), snapshots: null });
|
|
358
|
-
await cap.plan!(ctx, step({ engine: "plunge" }));
|
|
359
|
-
expect(plunge.calls[0].env).toEqual({ [PULUMI_STREAMING_PREVIEW_ENV]: "true" });
|
|
360
|
-
});
|
|
361
|
-
|
|
362
|
-
test("an empty backend is refused before anything runs", async () => {
|
|
363
|
-
const plunge = engine();
|
|
364
|
-
const cap = createPulumiUpCapability({ plunge: plunge.run, env: {}, tmp: tmp(), snapshots: null });
|
|
365
|
-
await expect(cap.plan!(ctx, step({ engine: "plunge", backend: " " }))).rejects.toThrow(/"backend" is the stack's backend URL/);
|
|
366
|
-
expect(plunge.calls).toHaveLength(0);
|
|
367
|
-
});
|
|
368
|
-
});
|
|
369
|
-
|
|
370
|
-
describe("a step pinned to its engine release (#4592)", () => {
|
|
371
|
-
test("engineVersion runs the versioned binary, through the same argv checks", async () => {
|
|
372
|
-
const pinned = engine();
|
|
373
|
-
const path = engine();
|
|
374
|
-
const bins: string[] = [];
|
|
375
|
-
const cap = createPulumiUpCapability({
|
|
376
|
-
plunge: path.run,
|
|
377
|
-
runAt: (bin) => {
|
|
378
|
-
bins.push(bin);
|
|
379
|
-
return pinned.run;
|
|
380
|
-
},
|
|
381
|
-
env: {},
|
|
382
|
-
tmp: tmp(),
|
|
383
|
-
snapshots: null,
|
|
384
|
-
});
|
|
385
|
-
await cap.plan!(ctx, step({ engine: "plunge", engineVersion: "0.1.0" }));
|
|
386
|
-
// The release copy (#4542) and the preview each resolve the runner; both get the pinned path.
|
|
387
|
-
expect(new Set(bins)).toEqual(new Set(["/opt/chant/plunge-0.1.0/plunge"]));
|
|
388
|
-
expect(pinned.calls).toHaveLength(1);
|
|
389
|
-
expect(pinned.calls[0].args[0]).toBe("preview");
|
|
390
|
-
expect(path.calls).toHaveLength(0);
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
test("without engineVersion the runner on PATH runs", async () => {
|
|
394
|
-
const path = engine();
|
|
395
|
-
const cap = createPulumiUpCapability({ plunge: path.run, runAt: () => { throw new Error("no pinned binary"); }, env: {}, tmp: tmp(), snapshots: null });
|
|
396
|
-
await cap.plan!(ctx, step({ engine: "plunge" }));
|
|
397
|
-
expect(path.calls).toHaveLength(1);
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
test("a version a shell would read as more is refused before anything runs", async () => {
|
|
401
|
-
const path = engine();
|
|
402
|
-
const cap = createPulumiUpCapability({ plunge: path.run, env: {}, tmp: tmp(), snapshots: null });
|
|
403
|
-
await expect(cap.plan!(ctx, step({ engine: "plunge", engineVersion: "0.1.0 && id" }))).rejects.toThrow(/pulumi-up/);
|
|
404
|
-
expect(path.calls).toHaveLength(0);
|
|
405
|
-
});
|
|
406
|
-
});
|
|
407
|
-
|
|
408
|
-
// ── #4609: review stacks in a pull request's environment ────────────────────
|
|
409
|
-
|
|
410
|
-
describe("review stacks in a pull request's environment (#4609)", () => {
|
|
411
|
-
const prCtx: DeployContext = { env: "pr-12", component: "site" };
|
|
412
|
-
const reviewMember = "corpus-aws-ts/pr-12";
|
|
413
|
-
const location = (engineName: string, stack: string) => `${engineName}:${relative(process.cwd(), dir) || "."}#${stack}`;
|
|
414
|
-
|
|
415
|
-
test("outside pr-<n> the step keeps its own stack", () => {
|
|
416
|
-
expect(pulumiReviewStep(step(), "prod")).toEqual({ step: step() });
|
|
417
|
-
expect(pulumiReviewStep(step(), "pr-12", "corpus-aws-ts/staging")).toEqual({ step: step({ stack: "pr-12" }), review: { stack: "pr-12", copyConfigFrom: "staging" } });
|
|
418
|
-
expect(pulumiReviewStep(step({ reviewSuffix: "web" }), "pr-12")).toMatchObject({ review: { stack: "pr-12-web", copyConfigFrom: "floci" } });
|
|
419
|
-
});
|
|
420
|
-
|
|
421
|
-
test("plan initializes pr-<n> from the template's stack, then previews pr-<n> and gives its location", async () => {
|
|
422
|
-
const plunge = engine();
|
|
423
|
-
const cap = createPulumiUpCapability({ plunge: plunge.run, env: { [PR_ENV_TEMPLATE_VARIABLE]: "corpus-aws-ts/staging" }, tmp: tmp(), snapshots: null });
|
|
424
|
-
const planned = await cap.plan!(prCtx, step({ engine: "plunge" }));
|
|
425
|
-
const artifact = planned.artifact as PulumiUpArtifact;
|
|
426
|
-
expect(plunge.calls.map((c) => c.args)).toEqual([
|
|
427
|
-
["stack", "init", "pr-12", "--no-select", "--copy-config-from", "staging"],
|
|
428
|
-
["preview", "--json", "--show-sames", "--stack", "pr-12", "--save-plan", artifact.planFile],
|
|
429
|
-
]);
|
|
430
|
-
expect(plunge.calls[0]!.cwd).toBe(dir);
|
|
431
|
-
expect(planned.member).toBe(reviewMember);
|
|
432
|
-
expect(artifact.stack).toBe("pr-12");
|
|
433
|
-
expect(planned.location).toBe(location("plunge", "pr-12"));
|
|
434
|
-
});
|
|
435
|
-
|
|
436
|
-
test("with no template naming this project's stack, the config comes from the step's own stack", async () => {
|
|
437
|
-
const pulumi = engine();
|
|
438
|
-
const cap = createPulumiUpCapability({ run: pulumi.run, env: { [PR_ENV_TEMPLATE_VARIABLE]: "staging" }, tmp: tmp(), snapshots: null });
|
|
439
|
-
await cap.plan!(prCtx, step({ engine: "pulumi" }));
|
|
440
|
-
expect(pulumi.calls[0]!.args).toEqual(["stack", "init", "pr-12", "--no-select", "--copy-config-from", "floci"]);
|
|
441
|
-
});
|
|
442
|
-
|
|
443
|
-
test("a review stack that exists already is previewed and updated", async () => {
|
|
444
|
-
const calls: string[][] = [];
|
|
445
|
-
const base = engine();
|
|
446
|
-
const run: PulumiRunner = async (args, opts) => {
|
|
447
|
-
if (args[0] === "stack" && args[1] === "init") {
|
|
448
|
-
calls.push(args);
|
|
449
|
-
throw Object.assign(new Error("exit 255"), { code: 255, stderr: "error: stack 'pr-12' already exists" });
|
|
450
|
-
}
|
|
451
|
-
return base.run(args, opts);
|
|
452
|
-
};
|
|
453
|
-
const cap = createPulumiUpCapability({ plunge: run, env: {}, tmp: tmp(), snapshots: null });
|
|
454
|
-
const planned = await cap.plan!(prCtx, step({ engine: "plunge" }));
|
|
455
|
-
expect(calls).toHaveLength(1);
|
|
456
|
-
expect(planned.member).toBe(reviewMember);
|
|
457
|
-
});
|
|
458
|
-
|
|
459
|
-
test("run applies the plan to pr-<n>, never to the template's stack", async () => {
|
|
460
|
-
const plunge = engine();
|
|
461
|
-
const cap = createPulumiUpCapability({ plunge: plunge.run, env: {}, tmp: tmp(), snapshots: null });
|
|
462
|
-
const planned = await cap.plan!(prCtx, step({ engine: "plunge" }));
|
|
463
|
-
const artifact = planned.artifact as PulumiUpArtifact;
|
|
464
|
-
const out = await cap.run({ ...prCtx, plans: { [reviewMember]: artifact } }, step({ engine: "plunge" }));
|
|
465
|
-
expect(plunge.calls.map((c) => c.args).slice(2)).toEqual([
|
|
466
|
-
["up", "--plan", artifact.planFile, "--yes", "--json", "--stack", "pr-12"],
|
|
467
|
-
["stack", "output", "--json", "--show-secrets=false", "--stack", "pr-12"],
|
|
468
|
-
]);
|
|
469
|
-
expect(out).toMatchObject({ member: reviewMember, stack: "pr-12", fromWavePlan: true });
|
|
470
|
-
// Only the stack init names the template's stack, as --copy-config-from; no preview, up or output does.
|
|
471
|
-
expect(plunge.calls.slice(1).some((c) => c.args.includes("floci"))).toBe(false);
|
|
472
|
-
});
|
|
473
|
-
|
|
474
|
-
test("a step whose config waits on an upstream still names its review stack's location", async () => {
|
|
475
|
-
const cap = createPulumiUpCapability({ plunge: engine().run, env: {}, tmp: tmp(), snapshots: null });
|
|
476
|
-
const planned = await cap.plan!({ ...prCtx, unresolvedInputs: ["db.url"] }, step({ engine: "plunge" }));
|
|
477
|
-
expect(planned.member).toBe(reviewMember);
|
|
478
|
-
expect(planned.location).toBe(location("plunge", "pr-12"));
|
|
479
|
-
});
|
|
480
|
-
});
|
|
481
|
-
|
|
482
|
-
describe("CrossGuard packs read at base (#4613)", () => {
|
|
483
|
-
const git = (cwd: string, ...args: string[]): string => execFileSync("git", args, { cwd, encoding: "utf-8" }).trim();
|
|
484
|
-
|
|
485
|
-
/** A repo holding the corpus stack and a pack `guard` beside it: mandatory at base, advisory on the head. */
|
|
486
|
-
function repo(): { stack: string; base: string } {
|
|
487
|
-
const top = realpathSync(tmp());
|
|
488
|
-
git(top, "init", "-q", "-b", "main");
|
|
489
|
-
git(top, "config", "user.email", "t@example.com");
|
|
490
|
-
git(top, "config", "user.name", "t");
|
|
491
|
-
const stack = join(top, "stack");
|
|
492
|
-
mkdirSync(join(stack, "guard"), { recursive: true });
|
|
493
|
-
for (const f of ["Pulumi.yaml", "stack-export.json"]) copyFileSync(join(dir, f), join(stack, f));
|
|
494
|
-
// An installed checkout, so the step runs no install before the preview (plywood#22).
|
|
495
|
-
mkdirSync(join(stack, "node_modules"));
|
|
496
|
-
writeFileSync(join(stack, "guard", "index.ts"), "// no-public-bucket: mandatory\n");
|
|
497
|
-
git(top, "add", ".");
|
|
498
|
-
git(top, "commit", "-q", "-m", "base");
|
|
499
|
-
const base = git(top, "rev-parse", "HEAD");
|
|
500
|
-
writeFileSync(join(stack, "guard", "index.ts"), "// no-public-bucket: advisory\n");
|
|
501
|
-
git(top, "commit", "-q", "-am", "head");
|
|
502
|
-
return { stack, base };
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
test("with a policy base, the preview and up run the base's copy of a pack the head changed", async () => {
|
|
506
|
-
const { stack, base } = repo();
|
|
507
|
-
const pulumi = engine();
|
|
508
|
-
const cap = createPulumiUpCapability({ run: pulumi.run, env: {}, tmp: tmp(), snapshots: null });
|
|
509
|
-
const planned = await cap.plan!({ ...ctx, policyBase: base }, step({ dir: stack, engine: "pulumi", policyPacks: [{ dir: "guard" }] }));
|
|
510
|
-
const args = pulumi.calls[0]!.args;
|
|
511
|
-
const pack = args[args.indexOf("--policy-pack") + 1]!;
|
|
512
|
-
expect(pack).not.toBe(join(stack, "guard"));
|
|
513
|
-
expect(readFileSync(join(pack, "index.ts"), "utf-8")).toContain("mandatory");
|
|
514
|
-
const artifact = planned.artifact as PulumiUpArtifact;
|
|
515
|
-
expect(artifact.policyPacks?.base).toBe(base);
|
|
516
|
-
expect(artifact.policyPacks?.notes).toEqual([expect.stringMatching(/guard differs on this change/)]);
|
|
517
|
-
|
|
518
|
-
await cap.run({ ...ctx, plans: { [planned.member]: artifact } }, step({ dir: stack, engine: "pulumi", policyPacks: [{ dir: "guard" }] }));
|
|
519
|
-
const up = pulumi.calls.find((c) => c.args[0] === "up")!.args;
|
|
520
|
-
expect(up[up.indexOf("--policy-pack") + 1]).toBe(pack);
|
|
521
|
-
});
|
|
522
|
-
|
|
523
|
-
test("without a policy base, the step's packs pass as they stand", async () => {
|
|
524
|
-
const { stack } = repo();
|
|
525
|
-
const pulumi = engine();
|
|
526
|
-
const cap = createPulumiUpCapability({ run: pulumi.run, env: {}, tmp: tmp(), snapshots: null });
|
|
527
|
-
const planned = await cap.plan!(ctx, step({ dir: stack, engine: "pulumi", policyPacks: [{ dir: "guard" }] }));
|
|
528
|
-
const args = pulumi.calls[0]!.args;
|
|
529
|
-
expect(args[args.indexOf("--policy-pack") + 1]).toBe("guard");
|
|
530
|
-
expect((planned.artifact as PulumiUpArtifact).policyPacks).toBeUndefined();
|
|
531
|
-
});
|
|
532
|
-
|
|
533
|
-
test("a base that names no commit stops the plan before the engine runs", async () => {
|
|
534
|
-
const { stack } = repo();
|
|
535
|
-
const pulumi = engine();
|
|
536
|
-
const cap = createPulumiUpCapability({ run: pulumi.run, env: {}, tmp: tmp(), snapshots: null });
|
|
537
|
-
await expect(cap.plan!({ ...ctx, policyBase: "f".repeat(40) }, step({ dir: stack, engine: "pulumi", policyPacks: [{ dir: "guard" }] }))).rejects.toThrow(/names no commit/);
|
|
538
|
-
expect(pulumi.calls).toHaveLength(0);
|
|
539
|
-
});
|
|
540
|
-
});
|
|
541
|
-
|
|
542
|
-
describe("an in-place checkout (plywood#22)", () => {
|
|
543
|
-
/** A checkout of the corpus program: Pulumi.yaml, package.json and, unless left out, a lockfile; no node_modules. */
|
|
544
|
-
function checkout(lockfile = true): string {
|
|
545
|
-
const stack = tmp();
|
|
546
|
-
for (const f of ["Pulumi.yaml", "stack-export.json"]) copyFileSync(join(dir, f), join(stack, f));
|
|
547
|
-
writeFileSync(join(stack, "package.json"), "{}\n");
|
|
548
|
-
if (lockfile) writeFileSync(join(stack, "package-lock.json"), "{}\n");
|
|
549
|
-
return stack;
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
test("a Node checkout with a lockfile and no node_modules gets one install, with the step's backend, before the first preview", async () => {
|
|
553
|
-
const stack = checkout();
|
|
554
|
-
const pulumi = engine();
|
|
555
|
-
const cap = createPulumiUpCapability({ run: pulumi.run, env: {}, tmp: tmp(), snapshots: null });
|
|
556
|
-
const planned = await cap.plan!(ctx, step({ dir: stack, engine: "pulumi", backend: "s3://shop-state" }));
|
|
557
|
-
expect(pulumi.calls[0]).toMatchObject({ args: ["install"], cwd: stack, env: { PULUMI_BACKEND_URL: "s3://shop-state" } });
|
|
558
|
-
expect(pulumi.calls[1]!.args[0]).toBe("preview");
|
|
559
|
-
|
|
560
|
-
await cap.run({ ...ctx, plans: { [planned.member]: planned.artifact as PulumiUpArtifact } }, step({ dir: stack, engine: "pulumi", backend: "s3://shop-state" }));
|
|
561
|
-
expect(pulumi.calls.filter((c) => c.args[0] === "install")).toHaveLength(1);
|
|
562
|
-
expect(pulumi.calls.some((c) => c.args[0] === "up")).toBe(true);
|
|
563
|
-
});
|
|
564
|
-
|
|
565
|
-
test("a Node checkout with no lockfile is refused by name before the engine runs", async () => {
|
|
566
|
-
const stack = checkout(false);
|
|
567
|
-
const pulumi = engine();
|
|
568
|
-
const cap = createPulumiUpCapability({ run: pulumi.run, env: {}, tmp: tmp(), snapshots: null });
|
|
569
|
-
await expect(cap.plan!(ctx, step({ dir: stack, engine: "pulumi" }))).rejects.toThrow(/no lockfile .* beside its package.json/);
|
|
570
|
-
expect(pulumi.calls).toHaveLength(0);
|
|
571
|
-
});
|
|
572
|
-
|
|
573
|
-
test("an installed checkout runs no install", async () => {
|
|
574
|
-
const stack = checkout();
|
|
575
|
-
mkdirSync(join(stack, "node_modules"));
|
|
576
|
-
const pulumi = engine();
|
|
577
|
-
const cap = createPulumiUpCapability({ run: pulumi.run, env: {}, tmp: tmp(), snapshots: null });
|
|
578
|
-
await cap.plan!(ctx, step({ dir: stack, engine: "pulumi" }));
|
|
579
|
-
expect(pulumi.calls.map((c) => c.args[0])).not.toContain("install");
|
|
580
|
-
});
|
|
581
|
-
});
|