@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/stack-ops.test.ts
DELETED
|
@@ -1,511 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gated stack operations (#4578): export, cancel and move each run only
|
|
3
|
-
* after their gated request (#4551) is approved, and each write goes
|
|
4
|
-
* through its fixed argv. The gated-request API is an in-memory fake that
|
|
5
|
-
* digests with chant's own `gatedRequestDigest`, and the runners are fakes
|
|
6
|
-
* answering with recorded documents (`testdata/pulumi-preview`), so no
|
|
7
|
-
* binary runs and no ledger or backend is written.
|
|
8
|
-
*/
|
|
9
|
-
import { existsSync, mkdirSync, mkdtempSync, readFileSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
10
|
-
import { tmpdir } from "node:os";
|
|
11
|
-
import { join } from "node:path";
|
|
12
|
-
import { describe, expect, test } from "vitest";
|
|
13
|
-
import { gatedRequestDigest, type GatedRequest } from "@intentius/chant/lifecycle/gated-request-digest";
|
|
14
|
-
import type { PulumiRunner } from "./run";
|
|
15
|
-
import {
|
|
16
|
-
diyStackLockIds,
|
|
17
|
-
gatedStackCancel,
|
|
18
|
-
gatedStackExport,
|
|
19
|
-
gatedStackAction,
|
|
20
|
-
gatedStackMove,
|
|
21
|
-
moveLeftovers,
|
|
22
|
-
pulumiMoveDestStack,
|
|
23
|
-
pulumiStackLockToCancel,
|
|
24
|
-
PulumiStackActionRefused,
|
|
25
|
-
stackOpApproveCommand,
|
|
26
|
-
stackActionScope,
|
|
27
|
-
pulumiStackLockIds,
|
|
28
|
-
PULUMI_STACK_OPS_OP,
|
|
29
|
-
type GatedRequestApi,
|
|
30
|
-
type PulumiStackOpCommon,
|
|
31
|
-
} from "./stack-ops";
|
|
32
|
-
|
|
33
|
-
const exportText = readFileSync(join(import.meta.dirname, "testdata", "pulumi-preview", "stack-export.json"), "utf-8");
|
|
34
|
-
|
|
35
|
-
/** An in-memory ledger: requests wait until `approve` is called by someone other than the requester. */
|
|
36
|
-
function ledger() {
|
|
37
|
-
const pending: { digest: string; request: GatedRequest; applied?: boolean }[] = [];
|
|
38
|
-
const approvals = new Map<string, string>();
|
|
39
|
-
const spent = new Set<string>();
|
|
40
|
-
const finished: { digest: string; result: string; detail?: Record<string, unknown> }[] = [];
|
|
41
|
-
const api: GatedRequestApi = {
|
|
42
|
-
async readGatedRequests(op) {
|
|
43
|
-
return pending.map((p) => ({ op, gate: p.request.subject, digest: p.digest, request: p.request, pending: {} as never, approvals: [], ...(spent.has(p.digest) ? { applied: {} as never } : {}) }));
|
|
44
|
-
},
|
|
45
|
-
async requestGate(input) {
|
|
46
|
-
const digest = gatedRequestDigest(input.op, input.request);
|
|
47
|
-
if (spent.has(digest)) return { status: "spent", digest, request: input.request };
|
|
48
|
-
if (!pending.some((p) => p.digest === digest)) pending.push({ digest, request: input.request });
|
|
49
|
-
const by = approvals.get(digest);
|
|
50
|
-
const command = `chant approve ${input.op} ${input.request.subject} --plan ${digest}`;
|
|
51
|
-
if (!by) return { status: "waiting", digest, request: input.request, command };
|
|
52
|
-
if (by === input.request.by) return { status: "refused", digest, request: input.request, by, reason: "the requester's own approval does not count", command };
|
|
53
|
-
return { status: "approved", digest, request: input.request, approval: { version: 1, op: input.op, gate: input.request.subject, resolvedBy: by, timestamp: "2026-10-27T12:00:00Z" } as never };
|
|
54
|
-
},
|
|
55
|
-
async spendGatedRequest(input) {
|
|
56
|
-
spent.add(input.digest);
|
|
57
|
-
return { version: 1, kind: "applied", op: input.op, gate: input.gate, planDigest: input.digest, approvedAt: input.approval.timestamp, approvedBy: input.approval.resolvedBy, timestamp: "2026-10-27T12:01:00Z" };
|
|
58
|
-
},
|
|
59
|
-
async finishGatedRequest(input) {
|
|
60
|
-
finished.push({ digest: input.digest, result: input.result, ...(input.detail ? { detail: input.detail } : {}) });
|
|
61
|
-
return { record: {} as never, pushed: true };
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
return { api, pending, approve: (digest: string, by: string) => approvals.set(digest, by), finished, spent };
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function runner(answer: (args: string[]) => string | Error = () => "{}"): { run: PulumiRunner; calls: string[][] } {
|
|
68
|
-
const calls: string[][] = [];
|
|
69
|
-
const run: PulumiRunner = async (args) => {
|
|
70
|
-
calls.push(args);
|
|
71
|
-
const out = answer(args);
|
|
72
|
-
if (out instanceof Error) throw out;
|
|
73
|
-
return { stdout: out };
|
|
74
|
-
};
|
|
75
|
-
return { run, calls };
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const outside = (): string => mkdtempSync(join(tmpdir(), "stack-ops-out-"));
|
|
79
|
-
/** A stack directory outside any git working tree, with a Pulumi.yaml and an optional backend. */
|
|
80
|
-
function stackDir(backend?: string): string {
|
|
81
|
-
const dir = mkdtempSync(join(tmpdir(), "stack-ops-stack-"));
|
|
82
|
-
writeFileSync(join(dir, "Pulumi.yaml"), `name: shop\nruntime: nodejs\n${backend ? `backend:\n url: ${backend}\n` : ""}`);
|
|
83
|
-
return dir;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
describe("export", () => {
|
|
87
|
-
test("waits for a second identity, then writes the export mode 600 on the requester's machine only", async () => {
|
|
88
|
-
const l = ledger();
|
|
89
|
-
const pulumi = runner(() => exportText);
|
|
90
|
-
const out = join(outside(), "dev.json");
|
|
91
|
-
const common: PulumiStackOpCommon = { by: "alice", rules: { mode: "ledger" }, gated: l.api, env: {}, run: pulumi.run };
|
|
92
|
-
const first = await gatedStackExport({ ...common, dir: stackDir(), stack: "dev", engine: "pulumi", out });
|
|
93
|
-
expect(first.status).toBe("waiting");
|
|
94
|
-
// #4808: the first call names the version (no numbered history, so the export's digest) and writes nothing.
|
|
95
|
-
expect(first.request).toMatchObject({ kind: "stack-export", subject: "dev", fields: { version_id: expect.stringMatching(/^sha256:/) } });
|
|
96
|
-
expect(existsSync(out)).toBe(false);
|
|
97
|
-
|
|
98
|
-
l.approve(first.digest, "alice");
|
|
99
|
-
expect((await gatedStackExport({ ...common, dir: stackDir(), stack: "dev", engine: "pulumi", out })).status).toBe("refused");
|
|
100
|
-
|
|
101
|
-
l.approve(first.digest, "bob");
|
|
102
|
-
const done = await gatedStackExport({ ...common, dir: stackDir(), stack: "dev", engine: "pulumi", out });
|
|
103
|
-
expect(done.status).toBe("done");
|
|
104
|
-
expect(done.digest).toBe(first.digest);
|
|
105
|
-
expect(pulumi.calls.filter((c) => c[1] === "export").at(-1)).toEqual(["stack", "export", "--stack", "dev"]);
|
|
106
|
-
expect(readFileSync(out, "utf-8")).toBe(exportText);
|
|
107
|
-
expect(statSync(out).mode & 0o777).toBe(0o600);
|
|
108
|
-
expect(done).toMatchObject({ result: { resources: expect.any(Number), bytes: exportText.length } });
|
|
109
|
-
expect(l.finished[0]).toMatchObject({ result: "applied", detail: { content_digest: expect.stringMatching(/^sha256:/) } });
|
|
110
|
-
expect(JSON.stringify(l.finished)).not.toContain("ciphertext");
|
|
111
|
-
|
|
112
|
-
// The same request again (its `at` kept) answers spent and runs nothing.
|
|
113
|
-
expect((await gatedStackExport({ ...common, now: first.request.at, dir: stackDir(), stack: "dev", engine: "pulumi", out: join(outside(), "again.json") })).status).toBe("spent");
|
|
114
|
-
// A later export is a new request: it waits for its own approval, and the spent one runs nothing again.
|
|
115
|
-
const again = await gatedStackExport({ ...common, now: "2000-01-01T00:00:00.000Z", dir: stackDir(), stack: "dev", engine: "pulumi", out: join(outside(), "again.json") });
|
|
116
|
-
expect(again.status).toBe("waiting");
|
|
117
|
-
expect(again.digest).not.toBe(first.digest);
|
|
118
|
-
expect(existsSync(join(outside(), "again.json"))).toBe(false);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
test("refused in CI, inside a git working tree, and over an existing file, before anything is asked", async () => {
|
|
122
|
-
const l = ledger();
|
|
123
|
-
const base = { by: "alice", rules: { mode: "ledger" as const }, gated: l.api, dir: stackDir(), stack: "dev", engine: "pulumi" as const };
|
|
124
|
-
await expect(gatedStackExport({ ...base, env: { CI: "true" }, out: join(outside(), "x.json") })).rejects.toThrow(/CI is set/);
|
|
125
|
-
const repo = outside();
|
|
126
|
-
mkdirSync(join(repo, ".git"));
|
|
127
|
-
await expect(gatedStackExport({ ...base, env: {}, out: join(repo, "x.json") })).rejects.toThrow(/inside the git working tree/);
|
|
128
|
-
const taken = join(outside(), "taken.json");
|
|
129
|
-
writeFileSync(taken, "{}");
|
|
130
|
-
await expect(gatedStackExport({ ...base, env: {}, out: taken })).rejects.toThrow(/never writes over a file/);
|
|
131
|
-
expect(l.pending).toEqual([]);
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
describe("cancel", () => {
|
|
136
|
-
test("releases the lock only while it is the approved one, on a file:// backend", async () => {
|
|
137
|
-
const root = outside();
|
|
138
|
-
const locks = join(root, ".pulumi", "locks", "organization", "shop", "dev");
|
|
139
|
-
mkdirSync(locks, { recursive: true });
|
|
140
|
-
writeFileSync(join(locks, "lock-1.json"), "{}");
|
|
141
|
-
expect(diyStackLockIds(root, "shop", "dev")).toEqual(["lock-1"]);
|
|
142
|
-
|
|
143
|
-
const dir = stackDir(`file://${root}`);
|
|
144
|
-
const l = ledger();
|
|
145
|
-
// Like pulumi on a file backend, cancel takes the lock file away (moved aside, so the test deletes nothing).
|
|
146
|
-
const pulumi = runner((args) => {
|
|
147
|
-
if (args[0] === "cancel") renameSync(join(locks, "lock-1.json"), join(root, "released-lock-1.json"));
|
|
148
|
-
return "{}";
|
|
149
|
-
});
|
|
150
|
-
const common = { by: "alice", rules: { mode: "ledger" as const }, gated: l.api, env: {}, run: pulumi.run, dir, stack: "dev", engine: "pulumi" as const, liveRuns: async () => [] };
|
|
151
|
-
|
|
152
|
-
// #4808: a lock id that is not the one held is refused before anything is asked.
|
|
153
|
-
await expect(gatedStackCancel({ ...common, lockId: "lock-0" })).rejects.toThrow(/not the one it holds now \(lock-1\)/);
|
|
154
|
-
expect(l.pending).toEqual([]);
|
|
155
|
-
|
|
156
|
-
const asked = await gatedStackCancel({ ...common, lockId: "lock-1" });
|
|
157
|
-
expect(asked.status).toBe("waiting");
|
|
158
|
-
l.approve(asked.digest, "bob");
|
|
159
|
-
const done = await gatedStackCancel({ ...common, lockId: "lock-1" });
|
|
160
|
-
expect(done).toMatchObject({ status: "done", result: { lockChecked: true, liveRuns: 0 } });
|
|
161
|
-
expect(pulumi.calls).toEqual([["cancel", "--yes", "--stack", "dev"]]);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
test("a stack on plunge is refused: plunge keeps no stack lock", async () => {
|
|
165
|
-
const l = ledger();
|
|
166
|
-
await expect(gatedStackCancel({ by: "alice", rules: { mode: "ledger" }, gated: l.api, env: {}, dir: stackDir(), stack: "dev", engine: "plunge", lockId: "x" })).rejects.toThrow(/keeps no stack lock/);
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
const src = (name: string) => `urn:pulumi:net::shop::aws:s3/bucketV2:BucketV2::${name}`;
|
|
171
|
-
const dst = (name: string) => `urn:pulumi:app::shop::aws:s3/bucketV2:BucketV2::${name}`;
|
|
172
|
-
const step = (op: string, urn: string) => ({ op, urn, type: "aws:s3/bucketV2:BucketV2", provider: "", ...(op === "create" ? { newState: { type: "aws:s3/bucketV2:BucketV2", inputs: {} } } : { oldState: { type: "aws:s3/bucketV2:BucketV2", inputs: {} } }) });
|
|
173
|
-
const previewDoc = (steps: unknown[]) => JSON.stringify({ steps, changeSummary: {} });
|
|
174
|
-
|
|
175
|
-
describe("move", () => {
|
|
176
|
-
test("moveLeftovers is empty only when the previews change nothing but the moved resources", async () => {
|
|
177
|
-
const { pulumiPreviewPart } = await import("./change-set");
|
|
178
|
-
const source = pulumiPreviewPart({ member: "net", preview: JSON.parse(previewDoc([step("delete", src("logs"))])) });
|
|
179
|
-
const dest = pulumiPreviewPart({ member: "app", preview: JSON.parse(previewDoc([step("create", dst("logs"))])) });
|
|
180
|
-
expect(moveLeftovers([src("logs")], source, dest)).toEqual([]);
|
|
181
|
-
const other = pulumiPreviewPart({ member: "app", preview: JSON.parse(previewDoc([step("create", dst("logs")), step("create", dst("extra"))])) });
|
|
182
|
-
expect(moveLeftovers([src("logs")], source, other)).toEqual([`app: create ${dst("extra")}`]);
|
|
183
|
-
const unmoved = pulumiPreviewPart({ member: "app", preview: JSON.parse(previewDoc([])) });
|
|
184
|
-
expect(moveLeftovers([src("logs")], source, unmoved)[0]).toMatch(/does not create/);
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
test("stock: previews both, waits, moves with pulumi state move, and previews both again", async () => {
|
|
188
|
-
const l = ledger();
|
|
189
|
-
let moved = false;
|
|
190
|
-
const pulumi = runner((args) => {
|
|
191
|
-
if (args[0] === "state") {
|
|
192
|
-
moved = true;
|
|
193
|
-
return "";
|
|
194
|
-
}
|
|
195
|
-
const stack = args[args.indexOf("--stack") + 1];
|
|
196
|
-
if (moved) return previewDoc([]);
|
|
197
|
-
return stack === "net" ? previewDoc([step("delete", src("logs"))]) : previewDoc([step("create", dst("logs"))]);
|
|
198
|
-
});
|
|
199
|
-
const opts = {
|
|
200
|
-
by: "alice",
|
|
201
|
-
rules: { mode: "ledger" as const },
|
|
202
|
-
gated: l.api,
|
|
203
|
-
env: {},
|
|
204
|
-
run: pulumi.run,
|
|
205
|
-
engine: "pulumi" as const,
|
|
206
|
-
source: { member: "net", dir: stackDir(), stack: "net" },
|
|
207
|
-
dest: { member: "app", dir: stackDir(), stack: "app" },
|
|
208
|
-
urns: [src("logs")],
|
|
209
|
-
};
|
|
210
|
-
const asked = await gatedStackMove(opts);
|
|
211
|
-
expect(asked.status).toBe("waiting");
|
|
212
|
-
expect(asked.request).toMatchObject({ kind: "stack-move", subject: "move:net:app", fields: { urns: src("logs") } });
|
|
213
|
-
l.approve(asked.digest, "bob");
|
|
214
|
-
const done = await gatedStackMove(opts);
|
|
215
|
-
expect(done.status).toBe("done");
|
|
216
|
-
expect(pulumi.calls.filter((c) => c[0] === "state")).toEqual([["state", "move", "--source", "net", "--dest", "app", "--yes", src("logs")]]);
|
|
217
|
-
expect(l.finished[0]).toMatchObject({ result: "applied", detail: { afterNoChange: true } });
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
test("a preview that changes more than the move refuses before anything is asked", async () => {
|
|
221
|
-
const l = ledger();
|
|
222
|
-
const pulumi = runner((args) => (args[args.indexOf("--stack") + 1] === "net" ? previewDoc([step("delete", src("logs")), step("delete", src("other"))]) : previewDoc([step("create", dst("logs"))])));
|
|
223
|
-
const opts = { by: "alice", rules: { mode: "ledger" as const }, gated: l.api, env: {}, run: pulumi.run, engine: "pulumi" as const, source: { member: "net", dir: stackDir(), stack: "net" }, dest: { member: "app", dir: stackDir(), stack: "app" }, urns: [src("logs")] };
|
|
224
|
-
await expect(gatedStackMove(opts)).rejects.toThrow(/change more than the moved resources.*delete .*other/);
|
|
225
|
-
expect(l.pending).toEqual([]);
|
|
226
|
-
expect(pulumi.calls.some((c) => c[0] === "state")).toBe(false);
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
test("plunge: the plan must be planned, then plunge stack move --json --yes runs", async () => {
|
|
230
|
-
const l = ledger();
|
|
231
|
-
let moved = false;
|
|
232
|
-
const plunge = runner((args) => {
|
|
233
|
-
if (args[0] === "stack" && args[1] === "move") {
|
|
234
|
-
if (args.includes("--yes")) {
|
|
235
|
-
moved = true;
|
|
236
|
-
return JSON.stringify({ status: "moved", result: { source: "net", destination: "app", written: true, resources: [] } });
|
|
237
|
-
}
|
|
238
|
-
return JSON.stringify({ status: "planned", result: { source: "net", destination: "app", written: false, resources: [] } });
|
|
239
|
-
}
|
|
240
|
-
const stack = args[args.indexOf("--stack") + 1];
|
|
241
|
-
if (moved) return previewDoc([]);
|
|
242
|
-
return stack === "net" ? previewDoc([step("delete", src("logs"))]) : previewDoc([step("create", dst("logs"))]);
|
|
243
|
-
});
|
|
244
|
-
const opts = { by: "alice", rules: { mode: "ledger" as const }, gated: l.api, env: {}, plunge: plunge.run, engine: "plunge" as const, source: { member: "net", dir: stackDir(), stack: "net" }, dest: { member: "app", dir: stackDir(), stack: "app" }, urns: [src("logs")] };
|
|
245
|
-
l.approve((await gatedStackMove(opts)).digest, "bob");
|
|
246
|
-
const done = await gatedStackMove(opts);
|
|
247
|
-
expect(done.status).toBe("done");
|
|
248
|
-
// Each call plans with plunge's own plan; the move runs once, after the approval.
|
|
249
|
-
expect(plunge.calls.filter((c) => c[1] === "move")).toEqual([
|
|
250
|
-
["stack", "move", "--stack", "net", "--dest", "app", src("logs"), "--json"],
|
|
251
|
-
["stack", "move", "--stack", "net", "--dest", "app", src("logs"), "--json"],
|
|
252
|
-
["stack", "move", "--stack", "net", "--dest", "app", src("logs"), "--json", "--yes"],
|
|
253
|
-
]);
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
test("a refused plunge plan refuses the move", async () => {
|
|
257
|
-
const l = ledger();
|
|
258
|
-
const plunge = runner((args) => {
|
|
259
|
-
if (args[1] === "move") return Object.assign(new Error("exit 255"), { code: 255, stdout: JSON.stringify({ status: "refused", refusals: [{ urn: src("logs"), reason: "the destination already owns a resource of that URN" }] }) });
|
|
260
|
-
return args[args.indexOf("--stack") + 1] === "net" ? previewDoc([step("delete", src("logs"))]) : previewDoc([step("create", dst("logs"))]);
|
|
261
|
-
});
|
|
262
|
-
const opts = { by: "alice", rules: { mode: "ledger" as const }, gated: l.api, env: {}, plunge: plunge.run, engine: "plunge" as const, source: { member: "net", dir: stackDir(), stack: "net" }, dest: { member: "app", dir: stackDir(), stack: "app" }, urns: [src("logs")] };
|
|
263
|
-
await expect(gatedStackMove(opts)).rejects.toThrow(/plan is refused: .*already owns/);
|
|
264
|
-
expect(l.pending).toEqual([]);
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
test("the requests sit under one op", () => {
|
|
268
|
-
expect(PULUMI_STACK_OPS_OP).toBe("pulumi-stack-ops");
|
|
269
|
-
});
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
describe("the stack lock reader (chant#4615)", () => {
|
|
273
|
-
test("lists a file:// backend's current lock ids for the stack, both layouts", async () => {
|
|
274
|
-
const root = outside();
|
|
275
|
-
mkdirSync(join(root, ".pulumi", "locks", "organization", "shop", "dev"), { recursive: true });
|
|
276
|
-
writeFileSync(join(root, ".pulumi", "locks", "organization", "shop", "dev", "lock-2.json"), "{}");
|
|
277
|
-
mkdirSync(join(root, ".pulumi", "locks", "dev"), { recursive: true });
|
|
278
|
-
writeFileSync(join(root, ".pulumi", "locks", "dev", "lock-1.json"), "{}");
|
|
279
|
-
const dir = stackDir(`file://${root}`);
|
|
280
|
-
expect(await pulumiStackLockIds({ dir, stack: "dev", env: {} })).toEqual({ checked: true, backend: `file://${root}`, ids: ["lock-1", "lock-2"] });
|
|
281
|
-
expect(await pulumiStackLockIds({ dir, stack: "prod", env: {} })).toEqual({ checked: true, backend: `file://${root}`, ids: [] });
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
test("takes PULUMI_BACKEND_URL over Pulumi.yaml, and says it did not read a backend it cannot list", async () => {
|
|
285
|
-
const root = outside();
|
|
286
|
-
mkdirSync(join(root, ".pulumi", "locks", "organization", "shop", "dev"), { recursive: true });
|
|
287
|
-
writeFileSync(join(root, ".pulumi", "locks", "organization", "shop", "dev", "lock-9.json"), "{}");
|
|
288
|
-
const dir = stackDir("s3://bucket");
|
|
289
|
-
expect(await pulumiStackLockIds({ dir, stack: "dev", env: {} })).toEqual({ checked: false, backend: "s3://bucket", ids: [] });
|
|
290
|
-
expect((await pulumiStackLockIds({ dir, stack: "dev", env: { PULUMI_BACKEND_URL: `file://${root}` } })).ids).toEqual(["lock-9"]);
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
test("a plunge stack holds no stack lock", async () => {
|
|
294
|
-
const dir = stackDir(`file://${outside()}`);
|
|
295
|
-
expect(await pulumiStackLockIds({ dir, stack: "dev", engine: "plunge", env: {} })).toEqual({ checked: true, ids: [] });
|
|
296
|
-
});
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
describe("action (chant#4654)", () => {
|
|
300
|
-
const rotate = "urn:pulumi:prod-us::shop::command:local:Command::rotate";
|
|
301
|
-
const bucket = "urn:pulumi:prod-us::shop::aws:s3/bucket:Bucket::b";
|
|
302
|
-
const stackUrn = "urn:pulumi:prod-us::shop::pulumi:pulumi:Stack::shop-prod-us";
|
|
303
|
-
const replaceSteps = (urn: string) => [
|
|
304
|
-
{ op: "create-replacement", urn, newState: { type: "command:local:Command", inputs: { create: "./rotate.sh" } } },
|
|
305
|
-
{ op: "replace", urn, newState: { type: "command:local:Command", inputs: { create: "./rotate.sh" } } },
|
|
306
|
-
{ op: "delete-replaced", urn, oldState: { type: "command:local:Command", inputs: { create: "./rotate.sh" } } },
|
|
307
|
-
];
|
|
308
|
-
const doc = (steps: unknown[]) => JSON.stringify({ steps: [{ op: "same", urn: stackUrn }, ...steps] });
|
|
309
|
-
const previewArgs = ["preview", "--json", "--target", rotate, "--replace", rotate, "--stack", "prod-us"];
|
|
310
|
-
const upArgs = ["up", "--yes", "--target", rotate, "--replace", rotate, "--stack", "prod-us"];
|
|
311
|
-
|
|
312
|
-
test("the first call previews the replacement and answers waiting, with no update", async () => {
|
|
313
|
-
const l = ledger();
|
|
314
|
-
const pulumi = runner(() => doc(replaceSteps(rotate)));
|
|
315
|
-
const first = await gatedStackAction({ by: "alice", rules: { mode: "ledger" }, gated: l.api, env: {}, run: pulumi.run, dir: stackDir(), stack: "prod-us", engine: "pulumi", urn: rotate, name: "rotate" });
|
|
316
|
-
expect(first.status).toBe("waiting");
|
|
317
|
-
expect(first.digest).toMatch(/^sha256:/);
|
|
318
|
-
expect(pulumi.calls).toEqual([previewArgs]);
|
|
319
|
-
expect(pulumi.calls.some((c) => c[0] === "up")).toBe(false);
|
|
320
|
-
expect(first.request).toMatchObject({
|
|
321
|
-
kind: "stack-action",
|
|
322
|
-
subject: "action:prod-us:rotate",
|
|
323
|
-
fields: { stack: "prod-us", urn: rotate, engine: "pulumi", name: "rotate", preview: expect.stringMatching(/sha256:/) },
|
|
324
|
-
});
|
|
325
|
-
expect(l.spent.size).toBe(0);
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
test("a preview that replaces a second resource is refused action-scope, naming it, and asks for nothing", async () => {
|
|
329
|
-
const l = ledger();
|
|
330
|
-
const pulumi = runner(() => doc([...replaceSteps(rotate), ...replaceSteps(bucket)]));
|
|
331
|
-
const call = gatedStackAction({ by: "alice", rules: { mode: "ledger" }, gated: l.api, env: {}, run: pulumi.run, dir: stackDir(), stack: "prod-us", engine: "pulumi", urn: rotate });
|
|
332
|
-
await expect(call).rejects.toThrow(PulumiStackActionRefused);
|
|
333
|
-
await expect(call).rejects.toMatchObject({ code: "action-scope", urns: [bucket] });
|
|
334
|
-
await expect(call).rejects.toThrow(new RegExp(`^action-scope: .*${bucket.replace(/[$.]/g, "\\$&")}`));
|
|
335
|
-
expect(l.pending).toEqual([]);
|
|
336
|
-
expect(pulumi.calls.every((c) => c[0] === "preview")).toBe(true);
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
test("a preview that does not replace the URN, or updates it in place, is refused action-scope", () => {
|
|
340
|
-
expect(stackActionScope(rotate, JSON.parse(doc([])))).toEqual({ others: [], problem: `the preview does not replace ${rotate}` });
|
|
341
|
-
expect(stackActionScope(rotate, JSON.parse(doc([{ op: "update", urn: rotate }])))).toMatchObject({ problem: `the preview shows update of ${rotate}, not its replacement` });
|
|
342
|
-
expect(stackActionScope(rotate, JSON.parse(doc(replaceSteps(rotate))))).toEqual({ others: [] });
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
test("a URN of another type is refused action-type before any engine call", async () => {
|
|
346
|
-
const l = ledger();
|
|
347
|
-
const pulumi = runner(() => doc([]));
|
|
348
|
-
const common = { by: "alice", rules: { mode: "ledger" as const }, gated: l.api, env: {}, run: pulumi.run, dir: stackDir(), stack: "prod-us", engine: "pulumi" as const };
|
|
349
|
-
await expect(gatedStackAction({ ...common, urn: bucket })).rejects.toMatchObject({ code: "action-type" });
|
|
350
|
-
await expect(gatedStackAction({ ...common, urn: bucket })).rejects.toThrow(/aws:s3\/bucket:Bucket/);
|
|
351
|
-
await expect(gatedStackAction({ ...common, urn: "rotate" })).rejects.toMatchObject({ code: "action-urn" });
|
|
352
|
-
await expect(gatedStackAction({ ...common, urn: "urn:pulumi:dev::shop::command:local:Command::rotate" })).rejects.toMatchObject({ code: "action-urn" });
|
|
353
|
-
expect(pulumi.calls).toEqual([]);
|
|
354
|
-
expect(l.pending).toEqual([]);
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
test("after a second identity approves, the update runs once, applied and finished are written, and a repeat is spent", async () => {
|
|
358
|
-
const l = ledger();
|
|
359
|
-
const pulumi = runner((args) => (args[0] === "up" ? "Updating (prod-us)\n ++ command:local:Command rotate created replacement\nResources: 1 replaced" : doc(replaceSteps(rotate))));
|
|
360
|
-
const opts = { by: "alice", rules: { mode: "ledger" as const }, gated: l.api, env: {}, run: pulumi.run, dir: stackDir(), stack: "prod-us", engine: "pulumi" as const, urn: rotate, name: "rotate" };
|
|
361
|
-
const first = await gatedStackAction(opts);
|
|
362
|
-
l.approve(first.digest, "alice");
|
|
363
|
-
expect((await gatedStackAction(opts)).status).toBe("refused");
|
|
364
|
-
expect(pulumi.calls.filter((c) => c[0] === "up")).toEqual([]);
|
|
365
|
-
|
|
366
|
-
l.approve(first.digest, "bob");
|
|
367
|
-
const done = await gatedStackAction(opts);
|
|
368
|
-
expect(done.status).toBe("done");
|
|
369
|
-
expect(done.digest).toBe(first.digest);
|
|
370
|
-
if (done.status !== "done") throw new Error("not done");
|
|
371
|
-
expect(done.result).toMatchObject({ urn: rotate, engine: "pulumi", exit: 0, tail: expect.stringContaining("1 replaced") });
|
|
372
|
-
expect(pulumi.calls.filter((c) => c[0] === "up")).toEqual([upArgs]);
|
|
373
|
-
expect(l.spent.has(first.digest)).toBe(true);
|
|
374
|
-
expect(l.finished).toEqual([{ digest: first.digest, result: "applied", detail: expect.objectContaining({ result: "ok", exit: 0, urn: rotate }) }]);
|
|
375
|
-
|
|
376
|
-
const again = await gatedStackAction(opts);
|
|
377
|
-
expect(again.status).toBe("spent");
|
|
378
|
-
expect(again.digest).toBe(first.digest);
|
|
379
|
-
expect(pulumi.calls.filter((c) => c[0] === "up")).toHaveLength(1);
|
|
380
|
-
// Asked anew, the same action is a new request that waits for its own approval.
|
|
381
|
-
const anew = await gatedStackAction({ ...opts, anew: true, now: "2000-01-01T00:00:00.000Z" });
|
|
382
|
-
expect(anew.status).toBe("waiting");
|
|
383
|
-
expect(pulumi.calls.filter((c) => c[0] === "up")).toHaveLength(1);
|
|
384
|
-
});
|
|
385
|
-
|
|
386
|
-
test("a failed update finishes failed with the exit code and the output's tail", async () => {
|
|
387
|
-
const l = ledger();
|
|
388
|
-
const pulumi = runner((args) => (args[0] === "up" ? Object.assign(new Error("exit 255"), { code: 255, stdout: "error: rotate.sh exited 3" }) : doc(replaceSteps(rotate))));
|
|
389
|
-
const opts = { by: "alice", rules: { mode: "ledger" as const }, gated: l.api, env: {}, run: pulumi.run, dir: stackDir(), stack: "prod-us", engine: "pulumi" as const, urn: rotate };
|
|
390
|
-
l.approve((await gatedStackAction(opts)).digest, "bob");
|
|
391
|
-
const failed = await gatedStackAction(opts);
|
|
392
|
-
expect(failed.status).toBe("failed");
|
|
393
|
-
expect(l.finished[0]).toMatchObject({ result: "failed", detail: { result: "failed", exit: 255, tail: "error: rotate.sh exited 3", urn: rotate } });
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
test("a stack on plunge previews and updates under plunge", async () => {
|
|
397
|
-
const l = ledger();
|
|
398
|
-
const plunge = runner((args) => (args[0] === "up" ? "done" : doc(replaceSteps(rotate))));
|
|
399
|
-
const opts = { by: "alice", rules: { mode: "ledger" as const }, gated: l.api, env: {}, plunge: plunge.run, dir: stackDir(), stack: "prod-us", engine: "plunge" as const, urn: rotate };
|
|
400
|
-
const first = await gatedStackAction(opts);
|
|
401
|
-
expect(first.request.fields.engine).toBe("plunge");
|
|
402
|
-
l.approve(first.digest, "bob");
|
|
403
|
-
expect((await gatedStackAction(opts)).status).toBe("done");
|
|
404
|
-
expect(plunge.calls).toEqual([previewArgs, previewArgs, upArgs]);
|
|
405
|
-
});
|
|
406
|
-
});
|
|
407
|
-
|
|
408
|
-
describe("the version reads (#4808)", () => {
|
|
409
|
-
test("runStackOpReadPulumi runs exactly the history and versioned export forms", async () => {
|
|
410
|
-
const { pulumiStackExportVersionArgs, pulumiStackHistoryArgs, runStackOpReadPulumi } = await import("./run");
|
|
411
|
-
const pulumi = runner(() => "[]");
|
|
412
|
-
await runStackOpReadPulumi(pulumi.run, pulumiStackHistoryArgs("dev"), "/tmp");
|
|
413
|
-
await runStackOpReadPulumi(pulumi.run, pulumiStackExportVersionArgs("dev", "12"), "/tmp");
|
|
414
|
-
expect(pulumi.calls).toEqual([
|
|
415
|
-
["stack", "history", "--json", "--page-size", "1", "--stack", "dev"],
|
|
416
|
-
["stack", "export", "--stack", "dev", "--version", "12"],
|
|
417
|
-
]);
|
|
418
|
-
for (const bad of [["stack", "export", "--stack", "dev", "--version", "0"], ["stack", "export", "--stack", "dev", "--show-secrets", "1"], ["stack", "history", "--json", "--show-secrets", "--stack", "dev"], ["stack", "export", "--stack", "dev"]]) {
|
|
419
|
-
await expect(runStackOpReadPulumi(pulumi.run, bad, "/tmp")).rejects.toThrow(/reads a stack's versions only as/);
|
|
420
|
-
}
|
|
421
|
-
expect(pulumi.calls).toHaveLength(2);
|
|
422
|
-
});
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
// #4911: what plywood built beside the lexicon's verbs.
|
|
426
|
-
describe("the product's approve line, lock, destination and requester (#4911)", () => {
|
|
427
|
-
test("a template the product words its approve line in, filled with the op, the gate, the digest and --sign when sealed", () => {
|
|
428
|
-
const line = stackOpApproveCommand({ approveCommand: "plywood approve {gate} --op {op} --plan {digest} {sign}", rules: { mode: "ledger" } })!;
|
|
429
|
-
expect(line("dev", "sha256:ab")).toBe(`plywood approve dev --op ${PULUMI_STACK_OPS_OP} --plan sha256:ab`);
|
|
430
|
-
const sealed = stackOpApproveCommand({ approveCommand: "plywood approve {gate} --op {op} --plan {digest} {sign}", rules: { mode: "sealed" }, op: "mine" })!;
|
|
431
|
-
expect(sealed("dev", "d")).toBe("plywood approve dev --op mine --plan d --sign");
|
|
432
|
-
expect(stackOpApproveCommand({ rules: { mode: "ledger" } })).toBeUndefined();
|
|
433
|
-
});
|
|
434
|
-
|
|
435
|
-
test("a waiting cancel and a waiting move print the product's line", async () => {
|
|
436
|
-
const root = outside();
|
|
437
|
-
const locks = join(root, ".pulumi", "locks", "organization", "shop", "dev");
|
|
438
|
-
mkdirSync(locks, { recursive: true });
|
|
439
|
-
writeFileSync(join(locks, "lock-1.json"), "{}");
|
|
440
|
-
const l = ledger();
|
|
441
|
-
const approveCommand = (gate: string, digest: string) => `plywood approve ${gate} --plan ${digest}`;
|
|
442
|
-
const asked = await gatedStackCancel({ by: "alice", rules: { mode: "ledger" }, gated: l.api, env: {}, dir: stackDir(`file://${root}`), stack: "dev", engine: "pulumi", lockId: "lock-1", liveRuns: async () => [], approveCommand });
|
|
443
|
-
expect(asked).toMatchObject({ status: "waiting", command: `plywood approve dev --plan ${asked.digest}` });
|
|
444
|
-
});
|
|
445
|
-
|
|
446
|
-
test("the lock to cancel: the one given, the one held, or a refusal the product words", async () => {
|
|
447
|
-
const root = outside();
|
|
448
|
-
const locks = join(root, ".pulumi", "locks", "organization", "shop", "dev");
|
|
449
|
-
mkdirSync(locks, { recursive: true });
|
|
450
|
-
const dir = stackDir(`file://${root}`);
|
|
451
|
-
expect(await pulumiStackLockToCancel("given", { dir, stack: "dev", env: {} })).toEqual({ lockId: "given", read: false });
|
|
452
|
-
expect(await pulumiStackLockToCancel(undefined, { dir, stack: "dev", env: {} })).toMatchObject({ refusal: "no-lock", ids: [] });
|
|
453
|
-
writeFileSync(join(locks, "lock-1.json"), "{}");
|
|
454
|
-
expect(await pulumiStackLockToCancel(undefined, { dir, stack: "dev", env: {} })).toEqual({ lockId: "lock-1", read: true });
|
|
455
|
-
writeFileSync(join(locks, "lock-2.json"), "{}");
|
|
456
|
-
expect(await pulumiStackLockToCancel(undefined, { dir, stack: "dev", env: {} })).toMatchObject({ refusal: "many-locks", ids: ["lock-1", "lock-2"] });
|
|
457
|
-
expect(await pulumiStackLockToCancel(undefined, { dir: stackDir("s3://bucket"), stack: "dev", env: {} })).toMatchObject({ refusal: "not-listed", backend: "s3://bucket" });
|
|
458
|
-
});
|
|
459
|
-
|
|
460
|
-
test("--dest: the bare stack in one project, else qualified, the org on Pulumi Cloud only", () => {
|
|
461
|
-
expect(pulumiMoveDestStack({ project: "shop" }, { project: "shop", stack: "app" })).toBe("app");
|
|
462
|
-
expect(pulumiMoveDestStack({ project: "net" }, { project: "shop", stack: "app" }, { org: "acme" })).toBe("acme/shop/app");
|
|
463
|
-
expect(pulumiMoveDestStack({ project: "net" }, { project: "shop", stack: "app", backend: "https://api.pulumi.com" }, { org: "acme" })).toBe("acme/shop/app");
|
|
464
|
-
expect(pulumiMoveDestStack({ project: "net" }, { project: "shop", stack: "app", backend: "file:///state" }, { org: "acme" })).toBe("organization/shop/app");
|
|
465
|
-
expect(pulumiMoveDestStack({ project: "net" }, { project: "shop", stack: "app" })).toBe("organization/shop/app");
|
|
466
|
-
expect(pulumiMoveDestStack({ project: "net" }, { project: "shop", stack: "o/shop/app" })).toBe("o/shop/app");
|
|
467
|
-
});
|
|
468
|
-
|
|
469
|
-
test("a move given both projects names the destination itself", async () => {
|
|
470
|
-
const l = ledger();
|
|
471
|
-
const pulumi = runner((args) => {
|
|
472
|
-
const stack = args[args.indexOf("--stack") + 1];
|
|
473
|
-
return stack === "net" ? previewDoc([step("delete", src("logs"))]) : previewDoc([step("create", dst("logs"))]);
|
|
474
|
-
});
|
|
475
|
-
const asked = await gatedStackMove({
|
|
476
|
-
by: "alice",
|
|
477
|
-
rules: { mode: "ledger" },
|
|
478
|
-
gated: l.api,
|
|
479
|
-
env: {},
|
|
480
|
-
run: pulumi.run,
|
|
481
|
-
engine: "pulumi",
|
|
482
|
-
source: { member: "infra/net", dir: stackDir(`file://${outside()}`), stack: "net", project: "infra" },
|
|
483
|
-
dest: { member: "shop/app", dir: stackDir(`file://${outside()}`), stack: "app", project: "shop" },
|
|
484
|
-
urns: [src("logs")],
|
|
485
|
-
org: "acme",
|
|
486
|
-
approveCommand: "plywood approve {gate} --op {op} --plan {digest} {sign}",
|
|
487
|
-
});
|
|
488
|
-
expect(asked).toMatchObject({ status: "waiting", request: { subject: "move:net:organization/shop/app", fields: { dest: "organization/shop/app" } } });
|
|
489
|
-
if (asked.status === "waiting") expect(asked.command).toBe(`plywood approve move:net:organization/shop/app --op ${PULUMI_STACK_OPS_OP} --plan ${asked.digest}`);
|
|
490
|
-
});
|
|
491
|
-
});
|
|
492
|
-
|
|
493
|
-
// #4920: a laptop cancel names the forge and the repository from the stack checkout's origin remote.
|
|
494
|
-
describe("cancel on a laptop (#4920)", () => {
|
|
495
|
-
test("with no CI variables and no repository given, the origin remote names the repository; only the token is missing", async () => {
|
|
496
|
-
const { execFileSync } = await import("node:child_process");
|
|
497
|
-
const root = outside();
|
|
498
|
-
const locks = join(root, ".pulumi", "locks", "organization", "shop", "dev");
|
|
499
|
-
mkdirSync(locks, { recursive: true });
|
|
500
|
-
writeFileSync(join(locks, "lock-1.json"), "{}");
|
|
501
|
-
const dir = stackDir(`file://${root}`);
|
|
502
|
-
const base = { by: "alice", rules: { mode: "ledger" as const }, env: {}, dir, stack: "dev", engine: "pulumi" as const, lockId: "lock-1", forge: { kind: "github" as const } };
|
|
503
|
-
const before = await gatedStackCancel({ ...base, gated: ledger().api }).then(() => "", (e: Error) => e.message);
|
|
504
|
-
expect(before).toMatch(/GITHUB_REPOSITORY/);
|
|
505
|
-
execFileSync("git", ["-C", dir, "init", "-q"]);
|
|
506
|
-
execFileSync("git", ["-C", dir, "remote", "add", "origin", "git@github.com:acme/infra.git"]);
|
|
507
|
-
const after = await gatedStackCancel({ ...base, gated: ledger().api }).then(() => "", (e: Error) => e.message);
|
|
508
|
-
expect(after).toMatch(/a token/);
|
|
509
|
-
expect(after).not.toMatch(/GITHUB_REPOSITORY/);
|
|
510
|
-
});
|
|
511
|
-
});
|