@intentius/chant-lexicon-pulumi 0.124.98 → 0.124.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adopt.d.ts +0 -1
- package/dist/capability-plugin.d.ts +0 -1
- package/dist/change-set.d.ts +0 -1
- package/dist/changed-units.d.ts +0 -1
- package/dist/check-step.d.ts +0 -1
- package/dist/ci-setup.d.ts +0 -1
- package/dist/codegen/docs-cli.d.ts +0 -1
- package/dist/codegen/docs.d.ts +0 -1
- package/dist/codegen/package.d.ts +0 -1
- package/dist/composites/pulumi-adopt-op.d.ts +0 -1
- package/dist/composites/pulumi-watch-op.d.ts +0 -1
- package/dist/config.d.ts +0 -1
- package/dist/describe-resources.d.ts +0 -1
- package/dist/drift-read.d.ts +0 -1
- package/dist/drift-record.d.ts +0 -1
- package/dist/engine-events.d.ts +0 -1
- package/dist/engine-graph.d.ts +0 -1
- package/dist/exit-codes.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/init-templates.d.ts +0 -1
- package/dist/integrity.json +2 -2
- package/dist/lint/audit-catalog.d.ts +0 -1
- package/dist/lint/post-synth/index.d.ts +0 -1
- package/dist/lint/post-synth/member-read-helpers.d.ts +0 -1
- package/dist/lint/post-synth/pul001.d.ts +0 -1
- package/dist/lint/post-synth/pul002.d.ts +0 -1
- package/dist/lint/post-synth/pul003.d.ts +0 -1
- package/dist/lint/post-synth/pul004.d.ts +0 -1
- package/dist/lint/post-synth/pul005.d.ts +0 -1
- package/dist/lint/post-synth/pul006.d.ts +0 -1
- package/dist/lint/post-synth/pul007.d.ts +0 -1
- package/dist/lint/post-synth/pul008.d.ts +0 -1
- package/dist/lint/post-synth/pul009.d.ts +0 -1
- package/dist/lint/post-synth/pul010.d.ts +0 -1
- package/dist/lint/post-synth/pul011.d.ts +0 -1
- package/dist/lint/post-synth/pul012.d.ts +0 -1
- package/dist/lint/post-synth/pul013.d.ts +0 -1
- package/dist/lint/post-synth/pul014.d.ts +0 -1
- package/dist/lint/post-synth/pul015.d.ts +0 -1
- package/dist/lint/rules/index.d.ts +0 -1
- package/dist/lint/rules/member-dir-absolute.d.ts +0 -1
- package/dist/lock-rows.d.ts +0 -1
- package/dist/lsp/completions.d.ts +0 -1
- package/dist/lsp/documents.d.ts +0 -1
- package/dist/lsp/hover.d.ts +0 -1
- package/dist/lsp/keys.d.ts +0 -1
- package/dist/lsp/object-path.d.ts +0 -1
- package/dist/lsp/yaml-cursor.d.ts +0 -1
- package/dist/manifest.json +1 -1
- package/dist/member-engine.d.ts +0 -1
- package/dist/member-outputs.d.ts +0 -1
- package/dist/op/activities/index.d.ts +0 -1
- package/dist/op/activities/pulumi-adopt.d.ts +0 -1
- package/dist/op/activities/pulumi.d.ts +0 -1
- package/dist/op/activity-contracts.d.ts +0 -1
- package/dist/op/builders.d.ts +0 -1
- package/dist/package-cli.d.ts +0 -1
- package/dist/plan-shape.d.ts +0 -1
- package/dist/planned-output-changes.d.ts +0 -1
- package/dist/plugin.d.ts +0 -1
- package/dist/plunge-timings.d.ts +0 -1
- package/dist/preview-tips.d.ts +0 -1
- package/dist/pulumi-up.d.ts +0 -1
- package/dist/release-copy.d.ts +0 -1
- package/dist/review-stack.d.ts +0 -1
- package/dist/run.d.ts +0 -1
- package/dist/serializer.d.ts +0 -1
- package/dist/stack-export-snapshot.d.ts +0 -1
- package/dist/stack-ops.d.ts +0 -1
- package/dist/stack-outputs.d.ts +0 -1
- package/dist/stack-references.d.ts +0 -1
- package/dist/trace-facts.d.ts +0 -1
- package/dist/values.d.ts +0 -1
- package/dist/workspace-member.d.ts +0 -1
- package/package.json +3 -4
- package/dist/adopt.d.ts.map +0 -1
- package/dist/capability-plugin.d.ts.map +0 -1
- package/dist/change-set.d.ts.map +0 -1
- package/dist/changed-units.d.ts.map +0 -1
- package/dist/check-step.d.ts.map +0 -1
- package/dist/ci-setup.d.ts.map +0 -1
- package/dist/codegen/docs-cli.d.ts.map +0 -1
- package/dist/codegen/docs.d.ts.map +0 -1
- package/dist/codegen/package.d.ts.map +0 -1
- package/dist/composites/pulumi-adopt-op.d.ts.map +0 -1
- package/dist/composites/pulumi-watch-op.d.ts.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/describe-resources.d.ts.map +0 -1
- package/dist/drift-read.d.ts.map +0 -1
- package/dist/drift-record.d.ts.map +0 -1
- package/dist/engine-events.d.ts.map +0 -1
- package/dist/engine-graph.d.ts.map +0 -1
- package/dist/exit-codes.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/init-templates.d.ts.map +0 -1
- package/dist/lint/audit-catalog.d.ts.map +0 -1
- package/dist/lint/post-synth/index.d.ts.map +0 -1
- package/dist/lint/post-synth/member-read-helpers.d.ts.map +0 -1
- package/dist/lint/post-synth/pul001.d.ts.map +0 -1
- package/dist/lint/post-synth/pul002.d.ts.map +0 -1
- package/dist/lint/post-synth/pul003.d.ts.map +0 -1
- package/dist/lint/post-synth/pul004.d.ts.map +0 -1
- package/dist/lint/post-synth/pul005.d.ts.map +0 -1
- package/dist/lint/post-synth/pul006.d.ts.map +0 -1
- package/dist/lint/post-synth/pul007.d.ts.map +0 -1
- package/dist/lint/post-synth/pul008.d.ts.map +0 -1
- package/dist/lint/post-synth/pul009.d.ts.map +0 -1
- package/dist/lint/post-synth/pul010.d.ts.map +0 -1
- package/dist/lint/post-synth/pul011.d.ts.map +0 -1
- package/dist/lint/post-synth/pul012.d.ts.map +0 -1
- package/dist/lint/post-synth/pul013.d.ts.map +0 -1
- package/dist/lint/post-synth/pul014.d.ts.map +0 -1
- package/dist/lint/post-synth/pul015.d.ts.map +0 -1
- package/dist/lint/rules/index.d.ts.map +0 -1
- package/dist/lint/rules/member-dir-absolute.d.ts.map +0 -1
- package/dist/lock-rows.d.ts.map +0 -1
- package/dist/lsp/completions.d.ts.map +0 -1
- package/dist/lsp/documents.d.ts.map +0 -1
- package/dist/lsp/hover.d.ts.map +0 -1
- package/dist/lsp/keys.d.ts.map +0 -1
- package/dist/lsp/object-path.d.ts.map +0 -1
- package/dist/lsp/yaml-cursor.d.ts.map +0 -1
- package/dist/member-engine.d.ts.map +0 -1
- package/dist/member-outputs.d.ts.map +0 -1
- package/dist/op/activities/index.d.ts.map +0 -1
- package/dist/op/activities/pulumi-adopt.d.ts.map +0 -1
- package/dist/op/activities/pulumi.d.ts.map +0 -1
- package/dist/op/activity-contracts.d.ts.map +0 -1
- package/dist/op/builders.d.ts.map +0 -1
- package/dist/package-cli.d.ts.map +0 -1
- package/dist/plan-shape.d.ts.map +0 -1
- package/dist/planned-output-changes.d.ts.map +0 -1
- package/dist/plugin.d.ts.map +0 -1
- package/dist/plunge-timings.d.ts.map +0 -1
- package/dist/preview-tips.d.ts.map +0 -1
- package/dist/pulumi-up.d.ts.map +0 -1
- package/dist/release-copy.d.ts.map +0 -1
- package/dist/review-stack.d.ts.map +0 -1
- package/dist/run.d.ts.map +0 -1
- package/dist/serializer.d.ts.map +0 -1
- package/dist/stack-export-snapshot.d.ts.map +0 -1
- package/dist/stack-ops.d.ts.map +0 -1
- package/dist/stack-outputs.d.ts.map +0 -1
- package/dist/stack-references.d.ts.map +0 -1
- package/dist/trace-facts.d.ts.map +0 -1
- package/dist/values.d.ts.map +0 -1
- package/dist/workspace-member.d.ts.map +0 -1
- package/src/adopt.ts +0 -202
- package/src/capability-plugin.ts +0 -34
- package/src/change-set.test.ts +0 -245
- package/src/change-set.ts +0 -508
- package/src/changed-units.test.ts +0 -87
- package/src/changed-units.ts +0 -96
- package/src/check-step.test.ts +0 -191
- package/src/check-step.ts +0 -316
- package/src/ci-setup.test.ts +0 -234
- package/src/ci-setup.ts +0 -224
- package/src/codegen/docs-cli.ts +0 -4
- package/src/codegen/docs.ts +0 -58
- package/src/codegen/package.ts +0 -63
- package/src/composites/pulumi-adopt-op.test.ts +0 -258
- package/src/composites/pulumi-adopt-op.ts +0 -193
- package/src/composites/pulumi-watch-op.test.ts +0 -42
- package/src/composites/pulumi-watch-op.ts +0 -85
- package/src/config.ts +0 -43
- package/src/describe-resources.test.ts +0 -112
- package/src/describe-resources.ts +0 -118
- package/src/drift-read.test.ts +0 -178
- package/src/drift-read.ts +0 -94
- package/src/drift-record.test.ts +0 -197
- package/src/drift-record.ts +0 -326
- package/src/engine-events.test.ts +0 -160
- package/src/engine-events.ts +0 -395
- package/src/engine-graph.test.ts +0 -141
- package/src/engine-graph.ts +0 -149
- package/src/exit-codes.test.ts +0 -21
- package/src/exit-codes.ts +0 -71
- package/src/index.ts +0 -139
- package/src/init-templates.ts +0 -85
- package/src/lint/audit-catalog.test.ts +0 -33
- package/src/lint/audit-catalog.ts +0 -174
- package/src/lint/post-synth/index.ts +0 -35
- package/src/lint/post-synth/member-read-helpers.ts +0 -122
- package/src/lint/post-synth/post-synth.test.ts +0 -245
- package/src/lint/post-synth/pul001.ts +0 -38
- package/src/lint/post-synth/pul002.ts +0 -38
- package/src/lint/post-synth/pul003.ts +0 -43
- package/src/lint/post-synth/pul004.ts +0 -32
- package/src/lint/post-synth/pul005.ts +0 -31
- package/src/lint/post-synth/pul006.ts +0 -31
- package/src/lint/post-synth/pul007.ts +0 -35
- package/src/lint/post-synth/pul008.ts +0 -35
- package/src/lint/post-synth/pul009.ts +0 -32
- package/src/lint/post-synth/pul010.ts +0 -42
- package/src/lint/post-synth/pul011.ts +0 -38
- package/src/lint/post-synth/pul012.ts +0 -35
- package/src/lint/post-synth/pul013.ts +0 -35
- package/src/lint/post-synth/pul014.ts +0 -32
- package/src/lint/post-synth/pul015.ts +0 -39
- package/src/lint/rules/index.ts +0 -7
- package/src/lint/rules/member-dir-absolute.test.ts +0 -37
- package/src/lint/rules/member-dir-absolute.ts +0 -83
- package/src/lock-rows.test.ts +0 -60
- package/src/lock-rows.ts +0 -56
- package/src/lsp/completions.test.ts +0 -69
- package/src/lsp/completions.ts +0 -119
- package/src/lsp/documents.ts +0 -48
- package/src/lsp/hover.test.ts +0 -56
- package/src/lsp/hover.ts +0 -83
- package/src/lsp/keys.ts +0 -169
- package/src/lsp/object-path.ts +0 -71
- package/src/lsp/yaml-cursor.ts +0 -85
- package/src/member-engine.test.ts +0 -112
- package/src/member-engine.ts +0 -97
- package/src/member-outputs.test.ts +0 -339
- package/src/member-outputs.ts +0 -157
- package/src/op/activities/index.ts +0 -36
- package/src/op/activities/pulumi-adopt.ts +0 -345
- package/src/op/activities/pulumi.ts +0 -136
- package/src/op/activity-contracts.ts +0 -129
- package/src/op/builders.ts +0 -67
- package/src/package-cli.ts +0 -14
- package/src/plan-shape.test.ts +0 -91
- package/src/plan-shape.ts +0 -105
- package/src/planned-output-changes.test.ts +0 -85
- package/src/planned-output-changes.ts +0 -141
- package/src/plugin.test.ts +0 -96
- package/src/plugin.ts +0 -272
- package/src/plunge-timings.test.ts +0 -241
- package/src/plunge-timings.ts +0 -115
- package/src/plunge-up-failed.test.ts +0 -54
- package/src/pr-note.test.ts +0 -87
- package/src/preview-generated.test.ts +0 -124
- package/src/preview-tips.test.ts +0 -134
- package/src/preview-tips.ts +0 -128
- package/src/pulumi-up.test.ts +0 -581
- package/src/pulumi-up.ts +0 -1102
- package/src/pulumi-urn-node.test.ts +0 -94
- package/src/release-copy.test.ts +0 -162
- package/src/release-copy.ts +0 -223
- package/src/review-stack.test.ts +0 -254
- package/src/review-stack.ts +0 -266
- package/src/run-plan-flags.test.ts +0 -53
- package/src/run.test.ts +0 -540
- package/src/run.ts +0 -1129
- package/src/serializer.test.ts +0 -9
- package/src/serializer.ts +0 -15
- package/src/skills/chant-pulumi-plunge.md +0 -51
- package/src/skills/chant-pulumi-stack-export.md +0 -54
- package/src/skills/chant-pulumi.md +0 -83
- package/src/stack-export-snapshot.test.ts +0 -192
- package/src/stack-export-snapshot.ts +0 -312
- package/src/stack-ops.fake-binary.test.ts +0 -323
- package/src/stack-ops.test.ts +0 -511
- package/src/stack-ops.ts +0 -1082
- package/src/stack-outputs.ts +0 -66
- package/src/stack-references.test.ts +0 -96
- package/src/stack-references.ts +0 -110
- package/src/testdata/plunge-drift/README.md +0 -10
- package/src/testdata/plunge-drift/assets-drifted.ndjson +0 -3
- package/src/testdata/plunge-drift/component-unsupported.ndjson +0 -3
- package/src/testdata/plunge-drift/role-in-sync.ndjson +0 -3
- package/src/testdata/plunge-drift/settled-empty.ndjson +0 -2
- package/src/testdata/plunge-graph/Pulumi.yaml +0 -4
- package/src/testdata/plunge-graph/README.md +0 -12
- package/src/testdata/plunge-graph/engine-graph.json +0 -158
- package/src/testdata/plunge-graph/stack-export.json +0 -49
- package/src/testdata/plunge-member/Pulumi.yaml +0 -4
- package/src/testdata/plunge-member/README.md +0 -3
- package/src/testdata/plunge-member/stack-export.json +0 -480
- package/src/testdata/plunge-outputs/Pulumi.yaml +0 -9
- package/src/testdata/plunge-outputs/README.md +0 -7
- package/src/testdata/plunge-outputs/stack-export.json +0 -2003
- package/src/testdata/plunge-outputs/stack-output.json +0 -19
- package/src/testdata/pulumi-member/Pulumi.yaml +0 -2
- package/src/testdata/pulumi-member/README.md +0 -50
- package/src/testdata/pulumi-member/recording/Pulumi.dev.yaml +0 -19
- package/src/testdata/pulumi-member/recording/Pulumi.yaml +0 -7
- package/src/testdata/pulumi-member/recording/index.js +0 -47
- package/src/testdata/pulumi-member/recording/package-lock.json +0 -2707
- package/src/testdata/pulumi-member/recording/package.json +0 -9
- package/src/testdata/pulumi-member/stack-export.json +0 -746
- package/src/testdata/pulumi-outputs/Pulumi.yaml +0 -7
- package/src/testdata/pulumi-outputs/README.md +0 -9
- package/src/testdata/pulumi-outputs/preview-replaced.json +0 -2894
- package/src/testdata/pulumi-outputs/preview-settled.json +0 -2894
- package/src/testdata/pulumi-outputs/stack-export.json +0 -1919
- package/src/testdata/pulumi-outputs/stack-output.json +0 -19
- package/src/testdata/pulumi-preview/Pulumi.yaml +0 -7
- package/src/testdata/pulumi-preview/README.md +0 -9
- package/src/testdata/pulumi-preview/preview-create.json +0 -992
- package/src/testdata/pulumi-preview/preview.json +0 -2894
- package/src/testdata/pulumi-preview/stack-export.json +0 -1919
- package/src/testdata/pulumi-refresh/Pulumi.yaml +0 -7
- package/src/testdata/pulumi-refresh/README.md +0 -14
- package/src/testdata/pulumi-refresh/all.json +0 -3742
- package/src/testdata/pulumi-refresh/bucket-edited.json +0 -468
- package/src/testdata/pulumi-refresh/policy-deleted.json +0 -95
- package/src/testdata/pulumi-refresh/queue-edited.json +0 -250
- package/src/testdata/pulumi-refresh/role-same.json +0 -242
- package/src/testdata/pulumi-refresh/secret-edited.json +0 -247
- package/src/testdata/pulumi-refresh/stack-export.json +0 -1907
- package/src/testdata/pulumi-stream/README.md +0 -16
- package/src/testdata/pulumi-stream/preview-stream.ndjson +0 -42
- package/src/testdata/pulumi-stream/up-failed-plunge.ndjson +0 -5
- package/src/testdata/pulumi-unexported/Pulumi.yaml +0 -2
- package/src/testdata/pulumi-urn-node/Pulumi.yaml +0 -7
- package/src/testdata/pulumi-urn-node/README.md +0 -9
- package/src/testdata/pulumi-urn-node/preview.json +0 -2894
- package/src/testdata/pulumi-urn-node/stack-export.json +0 -1919
- package/src/trace-facts.test.ts +0 -38
- package/src/trace-facts.ts +0 -83
- package/src/values.ts +0 -147
- package/src/workspace-kinds.test.ts +0 -47
- package/src/workspace-member.test.ts +0 -127
- package/src/workspace-member.ts +0 -304
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `describeResources` for a Pulumi member (#4529): one `plunge graph --json
|
|
3
|
-
* --stack <stack>` for a member on plunge, read from chant#4527's plunge
|
|
4
|
-
* fixture document, and nothing at all for a stock member. The runner is a
|
|
5
|
-
* fake; no plunge binary runs here.
|
|
6
|
-
*/
|
|
7
|
-
import { readFileSync } from "node:fs";
|
|
8
|
-
import { join } from "node:path";
|
|
9
|
-
import { describe, expect, test } from "vitest";
|
|
10
|
-
import { buildLiveGraphIr } from "@intentius/chant/graph-ir";
|
|
11
|
-
import { isObservationResult, normalizeObservation } from "@intentius/chant/observation";
|
|
12
|
-
import { describePulumiResources, PLUNGE_GRAPH_SOURCE } from "./describe-resources";
|
|
13
|
-
import type { PulumiRunner } from "./run";
|
|
14
|
-
|
|
15
|
-
const testdata = join(import.meta.dirname, "testdata");
|
|
16
|
-
const dir = join(testdata, "plunge-graph");
|
|
17
|
-
const fixturePath = join(import.meta.dirname, "..", "..", "..", "packages", "core", "src", "graph-schema", "fixtures", "plunge.engine-graph.json");
|
|
18
|
-
const fixtureText = readFileSync(fixturePath, "utf-8");
|
|
19
|
-
const fixture = JSON.parse(fixtureText) as { nodes: { id: string; facts?: unknown }[] };
|
|
20
|
-
|
|
21
|
-
function fake(answer: (args: string[]) => string | Error): { run: PulumiRunner; calls: { args: string[]; cwd: string }[] } {
|
|
22
|
-
const calls: { args: string[]; cwd: string }[] = [];
|
|
23
|
-
const run: PulumiRunner = async (args, opts) => {
|
|
24
|
-
calls.push({ args, cwd: opts.cwd });
|
|
25
|
-
const out = answer(args);
|
|
26
|
-
if (out instanceof Error) throw out;
|
|
27
|
-
return { stdout: out };
|
|
28
|
-
};
|
|
29
|
-
return { run, calls };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const entities = new Map([
|
|
33
|
-
["app/aws:s3/bucketV2:BucketV2::assets", { entityType: "aws:s3/bucketV2:BucketV2", props: {} }],
|
|
34
|
-
["app/gcp:storage/bucket:Bucket::media", { entityType: "gcp:storage/bucket:Bucket", props: {} }],
|
|
35
|
-
["app/aws:s3/bucketPolicy:BucketPolicy::assets-policy", { entityType: "aws:s3/bucketPolicy:BucketPolicy", props: {} }],
|
|
36
|
-
]);
|
|
37
|
-
const factsOf = (urn: string) => fixture.nodes.find((n) => n.id === urn)!.facts;
|
|
38
|
-
|
|
39
|
-
describe("describeResources for a member on plunge (#4529)", () => {
|
|
40
|
-
test("runs plunge graph --json --stack <stack> once and maps each URN with pulumiNodeKey", async () => {
|
|
41
|
-
const { run, calls } = fake(() => fixtureText);
|
|
42
|
-
const result = await describePulumiResources({ entities }, { member: { dir, label: "app" }, plunge: run });
|
|
43
|
-
expect(calls).toEqual([{ args: ["graph", "--json", "--stack", "dev"], cwd: dir }]);
|
|
44
|
-
const obs = normalizeObservation(result);
|
|
45
|
-
// The provider has no node; every other node of the document is a resource.
|
|
46
|
-
expect(Object.keys(obs.resources).sort()).toEqual([...entities.keys()].sort());
|
|
47
|
-
expect(obs.unobserved).toEqual({});
|
|
48
|
-
expect(obs.sources["app/aws:s3/bucketV2:BucketV2::assets"]).toBe(PLUNGE_GRAPH_SOURCE);
|
|
49
|
-
expect(obs.queried["app/aws:s3/bucketV2:BucketV2::assets"]).toBe("urn:pulumi:dev::app::aws:s3/bucketV2:BucketV2::assets");
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
test("each resource carries plunge's physicalId and facts, and no verdict", async () => {
|
|
53
|
-
const { run } = fake(() => fixtureText);
|
|
54
|
-
const { resources } = normalizeObservation(await describePulumiResources({ entities }, { member: { dir, label: "app" }, plunge: run }));
|
|
55
|
-
const assets = resources["app/aws:s3/bucketV2:BucketV2::assets"];
|
|
56
|
-
expect(assets).toEqual({
|
|
57
|
-
type: "aws:s3/bucketV2:BucketV2",
|
|
58
|
-
physicalId: "assets-4f1c2e9",
|
|
59
|
-
status: "bound",
|
|
60
|
-
ownership: "unknown",
|
|
61
|
-
facts: factsOf("urn:pulumi:dev::app::aws:s3/bucketV2:BucketV2::assets"),
|
|
62
|
-
});
|
|
63
|
-
expect(assets.facts?.markers).toEqual({ owner: "app/dev", address: "aws:s3/bucketV2:BucketV2::assets", encoding: "plain", source: "record" });
|
|
64
|
-
expect(resources["app/gcp:storage/bucket:Bucket::media"].facts?.markers?.encoding).toBe("digest");
|
|
65
|
-
expect(resources["app/aws:s3/bucketPolicy:BucketPolicy::assets-policy"]).toMatchObject({ status: "pending", ownership: "unknown" });
|
|
66
|
-
for (const r of Object.values(resources)) {
|
|
67
|
-
expect(r.ownership).toBe("unknown");
|
|
68
|
-
expect(r.marker).toBeUndefined();
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
test("buildLiveGraphIr puts the facts on the live node", async () => {
|
|
73
|
-
const { run } = fake(() => fixtureText);
|
|
74
|
-
const { resources } = normalizeObservation(await describePulumiResources({ entities }, { member: { dir, label: "app" }, plunge: run }));
|
|
75
|
-
const ir = buildLiveGraphIr([{ lexicon: "pulumi", resources }]);
|
|
76
|
-
const node = ir.nodes.find((n) => n.id === "app/aws:s3/bucketV2:BucketV2::assets")!;
|
|
77
|
-
expect(node.facts).toEqual(factsOf("urn:pulumi:dev::app::aws:s3/bucketV2:BucketV2::assets"));
|
|
78
|
-
expect(node.ownership).toBeUndefined();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
test("with owned asked, a note says ownership stays unknown", async () => {
|
|
82
|
-
const { run } = fake(() => fixtureText);
|
|
83
|
-
const result = await describePulumiResources({ entities, owned: true }, { member: { dir, label: "app" }, plunge: run });
|
|
84
|
-
expect(normalizeObservation(result).notes.join("\n")).toMatch(/ownership stays unknown.*source: record/);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
test("a failed run leaves every entity not-observed, never absent", async () => {
|
|
88
|
-
const old = fake(() => Object.assign(new Error("Command failed"), { stderr: 'error: unknown command "graph" for "plunge"' }));
|
|
89
|
-
const obs = normalizeObservation(await describePulumiResources({ entities }, { member: { dir, label: "app" }, plunge: old.run }));
|
|
90
|
-
expect(obs.resources).toEqual({});
|
|
91
|
-
expect(Object.keys(obs.unobserved).sort()).toEqual([...entities.keys()].sort());
|
|
92
|
-
expect(Object.values(obs.unobserved).every((u) => u.reason === "read-failed" && /plunge#40/.test(u.detail ?? ""))).toBe(true);
|
|
93
|
-
|
|
94
|
-
const other = fake(() => JSON.stringify({ version: 1, meta: { engineGraph: { format: 1, engine: { name: "choudoufu" } } }, nodes: [], edges: [] }));
|
|
95
|
-
const wrong = normalizeObservation(await describePulumiResources({ entities }, { member: { dir, label: "app" }, plunge: other.run }));
|
|
96
|
-
expect(Object.values(wrong.unobserved).every((u) => u.reason === "read-failed" && /not plunge/.test(u.detail ?? ""))).toBe(true);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
describe("describeResources for a stock member (#4529)", () => {
|
|
101
|
-
test("runs nothing and leaves every entity not-observed", async () => {
|
|
102
|
-
const plunge = fake(() => fixtureText);
|
|
103
|
-
for (const member of [{ dir: join(testdata, "pulumi-preview"), label: "app" }, { dir, label: "app", engine: "pulumi" as const }]) {
|
|
104
|
-
const result = await describePulumiResources({ entities }, { member, plunge: plunge.run });
|
|
105
|
-
expect(isObservationResult(result)).toBe(true);
|
|
106
|
-
const obs = normalizeObservation(result);
|
|
107
|
-
expect(obs.resources).toEqual({});
|
|
108
|
-
expect(Object.values(obs.unobserved).every((u) => u.reason === "no-binding" && /stock pulumi/.test(u.detail ?? ""))).toBe(true);
|
|
109
|
-
}
|
|
110
|
-
expect(plunge.calls).toEqual([]);
|
|
111
|
-
});
|
|
112
|
-
});
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `describeResources` for a Pulumi member (#4529, designed on #4520 section
|
|
3
|
-
* 4): engine facts for a member on plunge.
|
|
4
|
-
*
|
|
5
|
-
* A member on plunge is read with one `plunge graph --json --stack <stack>`
|
|
6
|
-
* (`./run.ts`, `plungeMemberGraph`), the stack chosen as every other read
|
|
7
|
-
* chooses it (`memberStack`: the declared one, else the one the checked-in
|
|
8
|
-
* export's URNs name). plunge prints the stack's graph from its records in
|
|
9
|
-
* chant#4520's document: no provider call, no output value. Each node becomes
|
|
10
|
-
* a resource keyed like the member graph's node (`<label>/<urn tail>`, by
|
|
11
|
-
* `pulumiNodeKey`), with plunge's `physicalId` and its facts on
|
|
12
|
-
* `ResourceMetadata.facts`, which `buildLiveGraphIr` copies onto the node.
|
|
13
|
-
* Provider resources and the root stack have no node and are left out.
|
|
14
|
-
*
|
|
15
|
-
* What it does not do:
|
|
16
|
-
*
|
|
17
|
-
* - Decide anything. `ownership` is `unknown` on every resource and no
|
|
18
|
-
* `marker` is set, so the change set never reads a delete from it and a
|
|
19
|
-
* teardown never selects it. plunge's markers carry `source: "record"`
|
|
20
|
-
* (#4520 Q5): what the record says was written, not a read of the object.
|
|
21
|
-
* - Run anything for a stock member. `pulumiMemberEngine` decides, and a
|
|
22
|
-
* member on stock `pulumi` has every entity not-observed with
|
|
23
|
-
* `no-binding`, with no argv run.
|
|
24
|
-
* - Ask for record versions. `--versions` costs one version listing per
|
|
25
|
-
* record (#4520 Q6), so this read leaves it off.
|
|
26
|
-
*
|
|
27
|
-
* A run that fails leaves every declared entity not-observed with the
|
|
28
|
-
* reason, never absent. That includes a plunge older than `plunge graph`
|
|
29
|
-
* (INTENTIUS/plunge#40).
|
|
30
|
-
*/
|
|
31
|
-
import { basename, dirname, isAbsolute, resolve } from "node:path";
|
|
32
|
-
import type { ResourceMetadata } from "@intentius/chant/lexicon";
|
|
33
|
-
import { observation, unobservedAll, type DescribeResourcesResult } from "@intentius/chant/observation";
|
|
34
|
-
import { isPulumiNodeless, pulumiNodeKey } from "@intentius/chant/pulumi-urn";
|
|
35
|
-
import type { PulumiConfig } from "./config";
|
|
36
|
-
import { readPlungeEngineGraph } from "./engine-graph";
|
|
37
|
-
import { pulumiMemberEngine } from "./member-engine";
|
|
38
|
-
import { plungeMemberGraph, type PulumiRunner } from "./run";
|
|
39
|
-
import type { PulumiMemberConfig } from "./workspace-member";
|
|
40
|
-
|
|
41
|
-
/** The `describeResources` options this read uses. */
|
|
42
|
-
export interface DescribePulumiOptions {
|
|
43
|
-
entities: Map<string, { entityType: string; props: Record<string, unknown> }>;
|
|
44
|
-
owned?: boolean;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/** Injectable for tests: the member (else read from the project's config) and the plunge runner. */
|
|
48
|
-
export interface DescribePulumiDeps {
|
|
49
|
-
/** The member, as the reader project's `pulumi.member` names it. Default: loaded from the config above `cwd`. */
|
|
50
|
-
member?: PulumiMemberConfig;
|
|
51
|
-
/** Where the config search starts. Default: the process cwd. */
|
|
52
|
-
cwd?: string;
|
|
53
|
-
plunge?: PulumiRunner;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/** The `sources` value on each entity this read answered. */
|
|
57
|
-
export const PLUNGE_GRAPH_SOURCE = "plunge-graph";
|
|
58
|
-
|
|
59
|
-
async function configuredMember(cwd: string): Promise<PulumiMemberConfig | undefined> {
|
|
60
|
-
const { loadChantConfigUpward } = await import("@intentius/chant/config");
|
|
61
|
-
const { config, configPath } = await loadChantConfigUpward(cwd);
|
|
62
|
-
const member = (config as { pulumi?: PulumiConfig }).pulumi?.member;
|
|
63
|
-
if (!member) return undefined;
|
|
64
|
-
const root = configPath ? dirname(configPath) : cwd;
|
|
65
|
-
return isAbsolute(member.dir) ? member : { ...member, dir: resolve(root, member.dir) };
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/** `LexiconPlugin.describeResources` for the pulumi lexicon. */
|
|
69
|
-
export async function describePulumiResources(options: DescribePulumiOptions, deps: DescribePulumiDeps = {}): Promise<DescribeResourcesResult> {
|
|
70
|
-
const names = [...options.entities.keys()];
|
|
71
|
-
const member = deps.member ?? (await configuredMember(resolve(deps.cwd ?? process.cwd())));
|
|
72
|
-
if (!member) {
|
|
73
|
-
return observation({}, unobservedAll(names, "no-binding", "pulumi.member names no member; chant workspace graph writes it into a pulumi member's reader project", options.entities));
|
|
74
|
-
}
|
|
75
|
-
const label = member.label ?? basename(member.dir);
|
|
76
|
-
const engine = pulumiMemberEngine(member.dir, member.engine);
|
|
77
|
-
if (engine.engine !== "plunge") {
|
|
78
|
-
// Stock pulumi has no record read; nothing runs (#4529).
|
|
79
|
-
return observation(
|
|
80
|
-
{},
|
|
81
|
-
unobservedAll(names, "no-binding", `member ${label} runs on stock pulumi (${engine.because}); only a member on plunge is described, by plunge graph`, options.entities),
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const read = await plungeMemberGraph({ dir: member.dir, ...(member.stack ? { stack: member.stack } : {}), ...(deps.plunge ? { plunge: deps.plunge } : {}) });
|
|
86
|
-
if (!read.ok) return observation({}, unobservedAll(names, read.reason, `${read.command} in ${member.dir}: ${read.detail}`, options.entities));
|
|
87
|
-
const parsed = readPlungeEngineGraph(read.doc);
|
|
88
|
-
if ("error" in parsed) {
|
|
89
|
-
return observation({}, unobservedAll(names, "read-failed", `${read.command} in ${member.dir} printed a document chant can't read: ${parsed.error}`, options.entities));
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const resources: Record<string, ResourceMetadata> = {};
|
|
93
|
-
const queried: Record<string, string> = {};
|
|
94
|
-
const sources: Record<string, string> = {};
|
|
95
|
-
for (const n of parsed.graph.nodes) {
|
|
96
|
-
if (isPulumiNodeless(n.kind)) continue;
|
|
97
|
-
const tail = pulumiNodeKey(n.urn);
|
|
98
|
-
if (tail === null) continue;
|
|
99
|
-
const key = `${label}/${tail}`;
|
|
100
|
-
resources[key] = {
|
|
101
|
-
type: n.kind,
|
|
102
|
-
...(n.physicalId ? { physicalId: n.physicalId } : {}),
|
|
103
|
-
// The record's word, not a provider's: bound or pending (#4520 Q5).
|
|
104
|
-
status: n.facts?.ownership ?? "recorded",
|
|
105
|
-
// Never a verdict: see the module comment.
|
|
106
|
-
ownership: "unknown",
|
|
107
|
-
...(n.facts ? { facts: n.facts } : {}),
|
|
108
|
-
};
|
|
109
|
-
queried[key] = n.urn;
|
|
110
|
-
sources[key] = PLUNGE_GRAPH_SOURCE;
|
|
111
|
-
}
|
|
112
|
-
const notes: string[] = [];
|
|
113
|
-
if (options.owned) {
|
|
114
|
-
notes.push(`member ${label}: plunge graph reads records, not live markers, so ownership stays unknown; facts.markers says what the record wrote (source: record)`);
|
|
115
|
-
}
|
|
116
|
-
if (parsed.graph.gaps > 0) notes.push(`member ${label}: ${read.command} could not describe ${parsed.graph.gaps} record(s); see its meta.engineGraph.gaps`);
|
|
117
|
-
return observation(resources, {}, queried, notes, undefined, sources);
|
|
118
|
-
}
|
package/src/drift-read.test.ts
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The pulumi lexicon's `readDrift` (#4455), what `chant workspace drift
|
|
3
|
-
* --member <pulumi member>` reaches through `chant lifecycle drift` in the
|
|
4
|
-
* member's reader project: it dispatches to #4453's runner and adapters,
|
|
5
|
-
* `pulumi refresh --preview-only --target` per resource on a stock member
|
|
6
|
-
* and `plunge drift --resource --stream` on a member on plunge, and wraps
|
|
7
|
-
* the records in one stream. The runners are fakes over the fixtures recorded
|
|
8
|
-
* for #4475 (pulumi 3.272.0 and plunge on floci, see testdata's READMEs);
|
|
9
|
-
* `plunge-member`'s export is a cut of the recorded plunge stack's. No binary
|
|
10
|
-
* runs here.
|
|
11
|
-
*/
|
|
12
|
-
import { cpSync, mkdirSync, mkdtempSync, readFileSync } from "node:fs";
|
|
13
|
-
import { tmpdir } from "node:os";
|
|
14
|
-
import { join } from "node:path";
|
|
15
|
-
import { describe, expect, test } from "vitest";
|
|
16
|
-
import { createSnapshotStore } from "@intentius/chant/lifecycle/snapshot-store";
|
|
17
|
-
import { foldDriftLines, type ReadDriftOptions } from "@intentius/chant/drift-record";
|
|
18
|
-
import { readPulumiDrift } from "./drift-read";
|
|
19
|
-
import { pulumiPlugin } from "./plugin";
|
|
20
|
-
import type { PulumiRunner } from "./run";
|
|
21
|
-
import { writePulumiExportSnapshot } from "./stack-export-snapshot";
|
|
22
|
-
|
|
23
|
-
const testdata = join(import.meta.dirname, "testdata");
|
|
24
|
-
const text = (...path: string[]) => readFileSync(join(testdata, ...path), "utf-8");
|
|
25
|
-
const AT = "2026-10-25T12:00:00Z";
|
|
26
|
-
const bucket = "urn:pulumi:floci::corpus-aws-ts::aws:s3/bucket:Bucket::site-bucket";
|
|
27
|
-
const assets = "urn:pulumi:floci::corpus-aws-ts::corpus:index:Site$aws:s3/bucket:Bucket::docs-assets";
|
|
28
|
-
const role = "urn:pulumi:floci::corpus-aws-ts::aws:iam/role:Role::app-role";
|
|
29
|
-
|
|
30
|
-
function fake(answer: (args: string[]) => string): { run: PulumiRunner; calls: string[][] } {
|
|
31
|
-
const calls: string[][] = [];
|
|
32
|
-
return {
|
|
33
|
-
calls,
|
|
34
|
-
run: async (args) => {
|
|
35
|
-
calls.push(args);
|
|
36
|
-
return { stdout: answer(args) };
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const never = fake(() => {
|
|
42
|
-
throw new Error("this binary must not run");
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
function options(dir: string, extra: Partial<ReadDriftOptions> = {}): ReadDriftOptions {
|
|
46
|
-
return { member: "site", projectRoot: dir, config: { pulumi: { member: { dir, label: "site" } } }, observedAt: AT, ...extra };
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
describe("readPulumiDrift", () => {
|
|
50
|
-
test("the plugin has a drift read", () => {
|
|
51
|
-
expect(typeof pulumiPlugin.readDrift).toBe("function");
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test("--resource on a stock member: one refresh --preview-only --target, as one stream", async () => {
|
|
55
|
-
const pulumi = fake(() => text("pulumi-refresh", "bucket-edited.json"));
|
|
56
|
-
const dir = join(testdata, "pulumi-preview");
|
|
57
|
-
const answer = await readPulumiDrift(options(dir, { resource: bucket }), { run: pulumi.run, plunge: never.run });
|
|
58
|
-
if (!("lines" in answer)) throw new Error(JSON.stringify(answer));
|
|
59
|
-
expect(pulumi.calls).toEqual([["refresh", "--preview-only", "--json", "--stack", "floci", "--target", bucket]]);
|
|
60
|
-
expect(answer.lines.map((l) => l.type)).toEqual(["drift-start", "drift-record", "drift-settle"]);
|
|
61
|
-
expect(answer.lines[0]).toMatchObject({ member: "site", engine: "pulumi", read: "refresh", resource: bucket, expected: [bucket] });
|
|
62
|
-
const { document } = foldDriftLines(answer.lines);
|
|
63
|
-
expect(document.records.map((r) => [r.address, r.status])).toEqual([[bucket, "drifted"]]);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test("a member on plunge reads each resource in its export with plunge drift --resource --stream, never pulumi", async () => {
|
|
67
|
-
const docs = "urn:pulumi:floci::corpus-aws-ts::corpus:index:Site::docs";
|
|
68
|
-
const answers: Record<string, string> = { [assets]: "assets-drifted.ndjson", [role]: "role-in-sync.ndjson", [docs]: "component-unsupported.ndjson" };
|
|
69
|
-
const plunge = fake((args) => text("plunge-drift", answers[args[2]]));
|
|
70
|
-
const dir = join(testdata, "plunge-member");
|
|
71
|
-
const answer = await readPulumiDrift(options(dir), { run: never.run, plunge: plunge.run });
|
|
72
|
-
if (!("lines" in answer)) throw new Error(JSON.stringify(answer));
|
|
73
|
-
expect(plunge.calls).toEqual([role, docs, assets].map((u) => ["drift", "--resource", u, "--stream", "--stack", "floci", "--member", "site"]));
|
|
74
|
-
expect(answer.lines[0]).toMatchObject({ engine: "plunge", read: "refresh" });
|
|
75
|
-
const { document } = foldDriftLines(answer.lines);
|
|
76
|
-
// plunge answers a component, which no provider reads, with not-observed (recorded).
|
|
77
|
-
expect(document.records.map((r) => [r.address, r.status]).sort()).toEqual([
|
|
78
|
-
[role, "in-sync"],
|
|
79
|
-
[docs, "not-observed"],
|
|
80
|
-
[assets, "drifted"],
|
|
81
|
-
].sort());
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
test("--resource on a member on plunge reads that URN alone", async () => {
|
|
85
|
-
const plunge = fake(() => text("plunge-drift", "assets-drifted.ndjson"));
|
|
86
|
-
const answer = await readPulumiDrift(options(join(testdata, "plunge-member"), { resource: assets }), { run: never.run, plunge: plunge.run });
|
|
87
|
-
expect("lines" in answer).toBe(true);
|
|
88
|
-
expect(plunge.calls).toEqual([["drift", "--resource", assets, "--stream", "--stack", "floci", "--member", "site"]]);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
test("--stack is the member's declared stack, over the one its export names (#4496)", async () => {
|
|
92
|
-
const pulumi = fake(() => text("pulumi-refresh", "bucket-edited.json"));
|
|
93
|
-
const dir = join(testdata, "pulumi-preview");
|
|
94
|
-
const config = { pulumi: { member: { dir, label: "site", stack: "staging" } } };
|
|
95
|
-
const answer = await readPulumiDrift({ ...options(dir, { resource: bucket }), config }, { run: pulumi.run, plunge: never.run });
|
|
96
|
-
expect("lines" in answer).toBe(true);
|
|
97
|
-
expect(pulumi.calls).toEqual([["refresh", "--preview-only", "--json", "--stack", "staging", "--target", bucket]]);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
test("a read other than refresh is refused, and so is a project with no pulumi member", async () => {
|
|
101
|
-
const dir = join(testdata, "pulumi-preview");
|
|
102
|
-
expect(await readPulumiDrift(options(dir, { read: "state" }), { run: never.run })).toEqual({
|
|
103
|
-
refused: { code: "read-unsupported", message: "a Pulumi member answers refresh, not state" },
|
|
104
|
-
});
|
|
105
|
-
const none = await readPulumiDrift({ member: "site", projectRoot: dir, config: {}, observedAt: AT });
|
|
106
|
-
expect("refused" in none && none.refused.code).toBe("no-drift-read");
|
|
107
|
-
expect(never.calls).toEqual([]);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
describe("readPulumiDrift with --stack", () => {
|
|
112
|
-
const exportText = text("pulumi-preview", "stack-export.json");
|
|
113
|
-
|
|
114
|
-
/** A member directory with Pulumi.yaml and no checked-in export, and a store holding the stacks named. */
|
|
115
|
-
async function memberWithStore(stacks: string[]) {
|
|
116
|
-
const dir = mkdtempSync(join(tmpdir(), "pulumi-drift-stack-"));
|
|
117
|
-
cpSync(join(testdata, "pulumi-preview", "Pulumi.yaml"), join(dir, "Pulumi.yaml"));
|
|
118
|
-
mkdirSync(join(dir, "node_modules"));
|
|
119
|
-
const store = createSnapshotStore({ store: "local", dir: mkdtempSync(join(tmpdir(), "pulumi-drift-store-")) });
|
|
120
|
-
for (const stack of stacks) {
|
|
121
|
-
const wrote = await writePulumiExportSnapshot({
|
|
122
|
-
dir,
|
|
123
|
-
stack,
|
|
124
|
-
environment: "prod",
|
|
125
|
-
engine: "pulumi",
|
|
126
|
-
run: async () => ({ stdout: exportText }),
|
|
127
|
-
store,
|
|
128
|
-
});
|
|
129
|
-
expect(wrote.written, JSON.stringify(wrote)).toBe(true);
|
|
130
|
-
}
|
|
131
|
-
return { dir, store };
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
test("reads the named stack's stored export and passes that stack to every refresh", async () => {
|
|
135
|
-
const { dir, store } = await memberWithStore(["staging", "prod-eu"]);
|
|
136
|
-
const pulumi = fake(() => text("pulumi-refresh", "bucket-edited.json"));
|
|
137
|
-
const answer = await readPulumiDrift(options(dir, { stack: "prod-eu" }), { run: pulumi.run, plunge: never.run, exportStore: store });
|
|
138
|
-
if (!("lines" in answer)) throw new Error(JSON.stringify(answer));
|
|
139
|
-
expect(pulumi.calls.length).toBeGreaterThan(0);
|
|
140
|
-
for (const call of pulumi.calls) expect(call.slice(call.indexOf("--stack"), call.indexOf("--stack") + 2)).toEqual(["--stack", "prod-eu"]);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
test("beats the member's declared stack", async () => {
|
|
144
|
-
const { dir, store } = await memberWithStore(["staging", "prod-eu"]);
|
|
145
|
-
const pulumi = fake(() => text("pulumi-refresh", "bucket-edited.json"));
|
|
146
|
-
const config = { pulumi: { member: { dir, label: "site", stack: "staging" } } };
|
|
147
|
-
const answer = await readPulumiDrift({ ...options(dir, { stack: "prod-eu", resource: bucket }), config }, { run: pulumi.run, plunge: never.run, exportStore: store });
|
|
148
|
-
expect("lines" in answer).toBe(true);
|
|
149
|
-
expect(pulumi.calls).toEqual([["refresh", "--preview-only", "--json", "--stack", "prod-eu", "--target", bucket]]);
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
test("a store with no export for that stack is an error naming the stack, and nothing runs", async () => {
|
|
153
|
-
const { dir, store } = await memberWithStore(["staging"]);
|
|
154
|
-
const spy = fake(() => text("pulumi-refresh", "bucket-edited.json"));
|
|
155
|
-
const answer = await readPulumiDrift(options(dir, { stack: "prod-eu" }), { run: spy.run, plunge: never.run, exportStore: store });
|
|
156
|
-
expect(answer).toMatchObject({ refused: { code: "no-drift-read" } });
|
|
157
|
-
expect("refused" in answer && answer.refused.message).toMatch(/holds no export for stack prod-eu of site/);
|
|
158
|
-
expect(spy.calls).toEqual([]);
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
test("an empty store is refused too, though a checked-in export sits beside the member", async () => {
|
|
162
|
-
const dir = join(testdata, "pulumi-preview");
|
|
163
|
-
const store = createSnapshotStore({ store: "local", dir: mkdtempSync(join(tmpdir(), "pulumi-drift-store-")) });
|
|
164
|
-
const spy = fake(() => text("pulumi-refresh", "bucket-edited.json"));
|
|
165
|
-
const answer = await readPulumiDrift(options(dir, { stack: "floci" }), { run: spy.run, plunge: never.run, exportStore: store });
|
|
166
|
-
expect(answer).toMatchObject({ refused: { code: "no-drift-read" } });
|
|
167
|
-
expect(spy.calls).toEqual([]);
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
test("without --stack the read is as before: the checked-in export when the store has none", async () => {
|
|
171
|
-
const dir = join(testdata, "pulumi-preview");
|
|
172
|
-
const store = createSnapshotStore({ store: "local", dir: mkdtempSync(join(tmpdir(), "pulumi-drift-store-")) });
|
|
173
|
-
const pulumi = fake(() => text("pulumi-refresh", "bucket-edited.json"));
|
|
174
|
-
const answer = await readPulumiDrift(options(dir, { resource: bucket }), { run: pulumi.run, plunge: never.run, exportStore: store });
|
|
175
|
-
expect("lines" in answer).toBe(true);
|
|
176
|
-
expect(pulumi.calls).toEqual([["refresh", "--preview-only", "--json", "--stack", "floci", "--target", bucket]]);
|
|
177
|
-
});
|
|
178
|
-
});
|
package/src/drift-read.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The pulumi lexicon's drift read: `LexiconPlugin.readDrift`, which `chant
|
|
3
|
-
* lifecycle drift` calls, and which `chant workspace drift --member <m>`
|
|
4
|
-
* runs in a `pulumi` member's reader project (behold#995's command, wired
|
|
5
|
-
* for Pulumi by #4455). It hands the member to the runner and adapters
|
|
6
|
-
* from #4453 (`refreshPulumiMember`), so the records say exactly what those
|
|
7
|
-
* adapters say.
|
|
8
|
-
*
|
|
9
|
-
* | engine | `--resource` | reads |
|
|
10
|
-
* |---|---|---|
|
|
11
|
-
* | pulumi | unset | `pulumi refresh --preview-only --json --target <urn>`, once per resource in the checked-in export; with no export, one untargeted refresh |
|
|
12
|
-
* | pulumi | `<urn>` | the same, for that URN alone |
|
|
13
|
-
* | plunge | unset | `plunge drift --resource <urn> --stream`, once per resource in the export |
|
|
14
|
-
* | plunge | `<urn>` | the same, for that URN alone |
|
|
15
|
-
*
|
|
16
|
-
* Each read passes `--stack` (#4496): the stack asked for (`chant workspace
|
|
17
|
-
* drift --stack`), else the member's declared `pulumi.member.stack`, else the
|
|
18
|
-
* stack the export's URNs name. A stack asked for is read from that stack's
|
|
19
|
-
* export in the index store alone; with none there the read is refused
|
|
20
|
-
* (`no-drift-read`), where without `--stack` the member reads the store's
|
|
21
|
-
* export, then the checked-in file.
|
|
22
|
-
*
|
|
23
|
-
* The one read is `refresh`. The member's engine is `pulumiMemberEngine`'s:
|
|
24
|
-
* the member config's `engine`, then a plunge backend URL in `Pulumi.yaml`.
|
|
25
|
-
* Neither command writes the stack. Each member's records go out as one
|
|
26
|
-
* stream: a `drift-start` whose `expected` is every URN read, the records,
|
|
27
|
-
* and a `drift-settle`. `chant workspace drift` places each record on the
|
|
28
|
-
* member's graph.
|
|
29
|
-
*/
|
|
30
|
-
import type { DriftLine, DriftRecord, ReadDriftOptions, ReadDriftResult } from "@intentius/chant/drift-record";
|
|
31
|
-
import { driftRecordLine, driftSettle, driftStart } from "@intentius/chant/drift-record";
|
|
32
|
-
import type { PulumiConfig } from "./config";
|
|
33
|
-
import { pulumiMemberEngine, refreshPulumiMember, type PulumiRunner } from "./run";
|
|
34
|
-
import { readStoredPulumiExport } from "./stack-export-snapshot";
|
|
35
|
-
import type { SnapshotStore } from "@intentius/chant/lifecycle/snapshot-store";
|
|
36
|
-
|
|
37
|
-
/** The runners, injectable so the tests run no binary. */
|
|
38
|
-
export interface PulumiDriftRunners {
|
|
39
|
-
run?: PulumiRunner;
|
|
40
|
-
plunge?: PulumiRunner;
|
|
41
|
-
/** The index store the exports are read from. Default: the project's. */
|
|
42
|
-
exportStore?: SnapshotStore | null;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** `LexiconPlugin.readDrift` for the pulumi lexicon. */
|
|
46
|
-
export async function readPulumiDrift(options: ReadDriftOptions, runners: PulumiDriftRunners = {}): Promise<ReadDriftResult> {
|
|
47
|
-
const member = (options.config as { pulumi?: PulumiConfig }).pulumi?.member;
|
|
48
|
-
if (!member) return { refused: { code: "no-drift-read", message: "pulumi.member names no member; chant workspace graph writes it into a pulumi member's reader project" } };
|
|
49
|
-
if (options.read !== undefined && options.read !== "refresh") {
|
|
50
|
-
return { refused: { code: "read-unsupported", message: `a Pulumi member answers refresh, not ${options.read}` } };
|
|
51
|
-
}
|
|
52
|
-
const { engine } = pulumiMemberEngine(member.dir, member.engine);
|
|
53
|
-
const stack = options.stack ?? member.stack;
|
|
54
|
-
if (options.stack !== undefined) {
|
|
55
|
-
const stored = await readStoredPulumiExport({ dir: member.dir, stack: options.stack, ...(runners.exportStore !== undefined ? { store: runners.exportStore } : {}) });
|
|
56
|
-
if (!stored) {
|
|
57
|
-
return {
|
|
58
|
-
refused: {
|
|
59
|
-
code: "no-drift-read",
|
|
60
|
-
message: `the index store holds no export for stack ${options.stack} of ${options.member}; the pulumi-up capability writes one after each apply through chant, so apply that stack once, or read without --stack`,
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
let records: DriftRecord[];
|
|
66
|
-
try {
|
|
67
|
-
records = await refreshPulumiMember({
|
|
68
|
-
member: options.member,
|
|
69
|
-
dir: member.dir,
|
|
70
|
-
observedAt: options.observedAt,
|
|
71
|
-
...(member.engine ? { engine: member.engine } : {}),
|
|
72
|
-
...(stack ? { stack } : {}),
|
|
73
|
-
...(runners.exportStore !== undefined ? { exportStore: runners.exportStore } : {}),
|
|
74
|
-
...(options.resource !== undefined ? { urns: [options.resource] } : {}),
|
|
75
|
-
...(runners.run ? { run: runners.run } : {}),
|
|
76
|
-
...(runners.plunge ? { plunge: runners.plunge } : {}),
|
|
77
|
-
});
|
|
78
|
-
} catch (err) {
|
|
79
|
-
// No URN to hang the failure on (an untargeted refresh that failed, or a plunge member with no export): the command fails with the reason.
|
|
80
|
-
throw new Error(`pulumi.member ${options.member}: ${err instanceof Error ? err.message : String(err)}`);
|
|
81
|
-
}
|
|
82
|
-
const start = driftStart({
|
|
83
|
-
member: options.member,
|
|
84
|
-
engine,
|
|
85
|
-
read: "refresh",
|
|
86
|
-
...(options.resource !== undefined ? { resource: options.resource } : {}),
|
|
87
|
-
at: options.observedAt,
|
|
88
|
-
expected: records.map((r) => r.address),
|
|
89
|
-
evidence: { tool: engine },
|
|
90
|
-
});
|
|
91
|
-
const settled = driftSettle(start, records, options.observedAt);
|
|
92
|
-
const lines: DriftLine[] = [start, ...settled.records.map(driftRecordLine), settled.line];
|
|
93
|
-
return { lines };
|
|
94
|
-
}
|