@intentius/chant-lexicon-pulumi 0.124.98 → 0.124.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adopt.d.ts +0 -1
- package/dist/capability-plugin.d.ts +0 -1
- package/dist/change-set.d.ts +0 -1
- package/dist/changed-units.d.ts +0 -1
- package/dist/check-step.d.ts +0 -1
- package/dist/ci-setup.d.ts +0 -1
- package/dist/codegen/docs-cli.d.ts +0 -1
- package/dist/codegen/docs.d.ts +0 -1
- package/dist/codegen/package.d.ts +0 -1
- package/dist/composites/pulumi-adopt-op.d.ts +0 -1
- package/dist/composites/pulumi-watch-op.d.ts +0 -1
- package/dist/config.d.ts +0 -1
- package/dist/describe-resources.d.ts +0 -1
- package/dist/drift-read.d.ts +0 -1
- package/dist/drift-record.d.ts +0 -1
- package/dist/engine-events.d.ts +0 -1
- package/dist/engine-graph.d.ts +0 -1
- package/dist/exit-codes.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/init-templates.d.ts +0 -1
- package/dist/integrity.json +2 -2
- package/dist/lint/audit-catalog.d.ts +0 -1
- package/dist/lint/post-synth/index.d.ts +0 -1
- package/dist/lint/post-synth/member-read-helpers.d.ts +0 -1
- package/dist/lint/post-synth/pul001.d.ts +0 -1
- package/dist/lint/post-synth/pul002.d.ts +0 -1
- package/dist/lint/post-synth/pul003.d.ts +0 -1
- package/dist/lint/post-synth/pul004.d.ts +0 -1
- package/dist/lint/post-synth/pul005.d.ts +0 -1
- package/dist/lint/post-synth/pul006.d.ts +0 -1
- package/dist/lint/post-synth/pul007.d.ts +0 -1
- package/dist/lint/post-synth/pul008.d.ts +0 -1
- package/dist/lint/post-synth/pul009.d.ts +0 -1
- package/dist/lint/post-synth/pul010.d.ts +0 -1
- package/dist/lint/post-synth/pul011.d.ts +0 -1
- package/dist/lint/post-synth/pul012.d.ts +0 -1
- package/dist/lint/post-synth/pul013.d.ts +0 -1
- package/dist/lint/post-synth/pul014.d.ts +0 -1
- package/dist/lint/post-synth/pul015.d.ts +0 -1
- package/dist/lint/rules/index.d.ts +0 -1
- package/dist/lint/rules/member-dir-absolute.d.ts +0 -1
- package/dist/lock-rows.d.ts +0 -1
- package/dist/lsp/completions.d.ts +0 -1
- package/dist/lsp/documents.d.ts +0 -1
- package/dist/lsp/hover.d.ts +0 -1
- package/dist/lsp/keys.d.ts +0 -1
- package/dist/lsp/object-path.d.ts +0 -1
- package/dist/lsp/yaml-cursor.d.ts +0 -1
- package/dist/manifest.json +1 -1
- package/dist/member-engine.d.ts +0 -1
- package/dist/member-outputs.d.ts +0 -1
- package/dist/op/activities/index.d.ts +0 -1
- package/dist/op/activities/pulumi-adopt.d.ts +0 -1
- package/dist/op/activities/pulumi.d.ts +0 -1
- package/dist/op/activity-contracts.d.ts +0 -1
- package/dist/op/builders.d.ts +0 -1
- package/dist/package-cli.d.ts +0 -1
- package/dist/plan-shape.d.ts +0 -1
- package/dist/planned-output-changes.d.ts +0 -1
- package/dist/plugin.d.ts +0 -1
- package/dist/plunge-timings.d.ts +0 -1
- package/dist/preview-tips.d.ts +0 -1
- package/dist/pulumi-up.d.ts +0 -1
- package/dist/release-copy.d.ts +0 -1
- package/dist/review-stack.d.ts +0 -1
- package/dist/run.d.ts +0 -1
- package/dist/serializer.d.ts +0 -1
- package/dist/stack-export-snapshot.d.ts +0 -1
- package/dist/stack-ops.d.ts +0 -1
- package/dist/stack-outputs.d.ts +0 -1
- package/dist/stack-references.d.ts +0 -1
- package/dist/trace-facts.d.ts +0 -1
- package/dist/values.d.ts +0 -1
- package/dist/workspace-member.d.ts +0 -1
- package/package.json +3 -4
- package/dist/adopt.d.ts.map +0 -1
- package/dist/capability-plugin.d.ts.map +0 -1
- package/dist/change-set.d.ts.map +0 -1
- package/dist/changed-units.d.ts.map +0 -1
- package/dist/check-step.d.ts.map +0 -1
- package/dist/ci-setup.d.ts.map +0 -1
- package/dist/codegen/docs-cli.d.ts.map +0 -1
- package/dist/codegen/docs.d.ts.map +0 -1
- package/dist/codegen/package.d.ts.map +0 -1
- package/dist/composites/pulumi-adopt-op.d.ts.map +0 -1
- package/dist/composites/pulumi-watch-op.d.ts.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/describe-resources.d.ts.map +0 -1
- package/dist/drift-read.d.ts.map +0 -1
- package/dist/drift-record.d.ts.map +0 -1
- package/dist/engine-events.d.ts.map +0 -1
- package/dist/engine-graph.d.ts.map +0 -1
- package/dist/exit-codes.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/init-templates.d.ts.map +0 -1
- package/dist/lint/audit-catalog.d.ts.map +0 -1
- package/dist/lint/post-synth/index.d.ts.map +0 -1
- package/dist/lint/post-synth/member-read-helpers.d.ts.map +0 -1
- package/dist/lint/post-synth/pul001.d.ts.map +0 -1
- package/dist/lint/post-synth/pul002.d.ts.map +0 -1
- package/dist/lint/post-synth/pul003.d.ts.map +0 -1
- package/dist/lint/post-synth/pul004.d.ts.map +0 -1
- package/dist/lint/post-synth/pul005.d.ts.map +0 -1
- package/dist/lint/post-synth/pul006.d.ts.map +0 -1
- package/dist/lint/post-synth/pul007.d.ts.map +0 -1
- package/dist/lint/post-synth/pul008.d.ts.map +0 -1
- package/dist/lint/post-synth/pul009.d.ts.map +0 -1
- package/dist/lint/post-synth/pul010.d.ts.map +0 -1
- package/dist/lint/post-synth/pul011.d.ts.map +0 -1
- package/dist/lint/post-synth/pul012.d.ts.map +0 -1
- package/dist/lint/post-synth/pul013.d.ts.map +0 -1
- package/dist/lint/post-synth/pul014.d.ts.map +0 -1
- package/dist/lint/post-synth/pul015.d.ts.map +0 -1
- package/dist/lint/rules/index.d.ts.map +0 -1
- package/dist/lint/rules/member-dir-absolute.d.ts.map +0 -1
- package/dist/lock-rows.d.ts.map +0 -1
- package/dist/lsp/completions.d.ts.map +0 -1
- package/dist/lsp/documents.d.ts.map +0 -1
- package/dist/lsp/hover.d.ts.map +0 -1
- package/dist/lsp/keys.d.ts.map +0 -1
- package/dist/lsp/object-path.d.ts.map +0 -1
- package/dist/lsp/yaml-cursor.d.ts.map +0 -1
- package/dist/member-engine.d.ts.map +0 -1
- package/dist/member-outputs.d.ts.map +0 -1
- package/dist/op/activities/index.d.ts.map +0 -1
- package/dist/op/activities/pulumi-adopt.d.ts.map +0 -1
- package/dist/op/activities/pulumi.d.ts.map +0 -1
- package/dist/op/activity-contracts.d.ts.map +0 -1
- package/dist/op/builders.d.ts.map +0 -1
- package/dist/package-cli.d.ts.map +0 -1
- package/dist/plan-shape.d.ts.map +0 -1
- package/dist/planned-output-changes.d.ts.map +0 -1
- package/dist/plugin.d.ts.map +0 -1
- package/dist/plunge-timings.d.ts.map +0 -1
- package/dist/preview-tips.d.ts.map +0 -1
- package/dist/pulumi-up.d.ts.map +0 -1
- package/dist/release-copy.d.ts.map +0 -1
- package/dist/review-stack.d.ts.map +0 -1
- package/dist/run.d.ts.map +0 -1
- package/dist/serializer.d.ts.map +0 -1
- package/dist/stack-export-snapshot.d.ts.map +0 -1
- package/dist/stack-ops.d.ts.map +0 -1
- package/dist/stack-outputs.d.ts.map +0 -1
- package/dist/stack-references.d.ts.map +0 -1
- package/dist/trace-facts.d.ts.map +0 -1
- package/dist/values.d.ts.map +0 -1
- package/dist/workspace-member.d.ts.map +0 -1
- package/src/adopt.ts +0 -202
- package/src/capability-plugin.ts +0 -34
- package/src/change-set.test.ts +0 -245
- package/src/change-set.ts +0 -508
- package/src/changed-units.test.ts +0 -87
- package/src/changed-units.ts +0 -96
- package/src/check-step.test.ts +0 -191
- package/src/check-step.ts +0 -316
- package/src/ci-setup.test.ts +0 -234
- package/src/ci-setup.ts +0 -224
- package/src/codegen/docs-cli.ts +0 -4
- package/src/codegen/docs.ts +0 -58
- package/src/codegen/package.ts +0 -63
- package/src/composites/pulumi-adopt-op.test.ts +0 -258
- package/src/composites/pulumi-adopt-op.ts +0 -193
- package/src/composites/pulumi-watch-op.test.ts +0 -42
- package/src/composites/pulumi-watch-op.ts +0 -85
- package/src/config.ts +0 -43
- package/src/describe-resources.test.ts +0 -112
- package/src/describe-resources.ts +0 -118
- package/src/drift-read.test.ts +0 -178
- package/src/drift-read.ts +0 -94
- package/src/drift-record.test.ts +0 -197
- package/src/drift-record.ts +0 -326
- package/src/engine-events.test.ts +0 -160
- package/src/engine-events.ts +0 -395
- package/src/engine-graph.test.ts +0 -141
- package/src/engine-graph.ts +0 -149
- package/src/exit-codes.test.ts +0 -21
- package/src/exit-codes.ts +0 -71
- package/src/index.ts +0 -139
- package/src/init-templates.ts +0 -85
- package/src/lint/audit-catalog.test.ts +0 -33
- package/src/lint/audit-catalog.ts +0 -174
- package/src/lint/post-synth/index.ts +0 -35
- package/src/lint/post-synth/member-read-helpers.ts +0 -122
- package/src/lint/post-synth/post-synth.test.ts +0 -245
- package/src/lint/post-synth/pul001.ts +0 -38
- package/src/lint/post-synth/pul002.ts +0 -38
- package/src/lint/post-synth/pul003.ts +0 -43
- package/src/lint/post-synth/pul004.ts +0 -32
- package/src/lint/post-synth/pul005.ts +0 -31
- package/src/lint/post-synth/pul006.ts +0 -31
- package/src/lint/post-synth/pul007.ts +0 -35
- package/src/lint/post-synth/pul008.ts +0 -35
- package/src/lint/post-synth/pul009.ts +0 -32
- package/src/lint/post-synth/pul010.ts +0 -42
- package/src/lint/post-synth/pul011.ts +0 -38
- package/src/lint/post-synth/pul012.ts +0 -35
- package/src/lint/post-synth/pul013.ts +0 -35
- package/src/lint/post-synth/pul014.ts +0 -32
- package/src/lint/post-synth/pul015.ts +0 -39
- package/src/lint/rules/index.ts +0 -7
- package/src/lint/rules/member-dir-absolute.test.ts +0 -37
- package/src/lint/rules/member-dir-absolute.ts +0 -83
- package/src/lock-rows.test.ts +0 -60
- package/src/lock-rows.ts +0 -56
- package/src/lsp/completions.test.ts +0 -69
- package/src/lsp/completions.ts +0 -119
- package/src/lsp/documents.ts +0 -48
- package/src/lsp/hover.test.ts +0 -56
- package/src/lsp/hover.ts +0 -83
- package/src/lsp/keys.ts +0 -169
- package/src/lsp/object-path.ts +0 -71
- package/src/lsp/yaml-cursor.ts +0 -85
- package/src/member-engine.test.ts +0 -112
- package/src/member-engine.ts +0 -97
- package/src/member-outputs.test.ts +0 -339
- package/src/member-outputs.ts +0 -157
- package/src/op/activities/index.ts +0 -36
- package/src/op/activities/pulumi-adopt.ts +0 -345
- package/src/op/activities/pulumi.ts +0 -136
- package/src/op/activity-contracts.ts +0 -129
- package/src/op/builders.ts +0 -67
- package/src/package-cli.ts +0 -14
- package/src/plan-shape.test.ts +0 -91
- package/src/plan-shape.ts +0 -105
- package/src/planned-output-changes.test.ts +0 -85
- package/src/planned-output-changes.ts +0 -141
- package/src/plugin.test.ts +0 -96
- package/src/plugin.ts +0 -272
- package/src/plunge-timings.test.ts +0 -241
- package/src/plunge-timings.ts +0 -115
- package/src/plunge-up-failed.test.ts +0 -54
- package/src/pr-note.test.ts +0 -87
- package/src/preview-generated.test.ts +0 -124
- package/src/preview-tips.test.ts +0 -134
- package/src/preview-tips.ts +0 -128
- package/src/pulumi-up.test.ts +0 -581
- package/src/pulumi-up.ts +0 -1102
- package/src/pulumi-urn-node.test.ts +0 -94
- package/src/release-copy.test.ts +0 -162
- package/src/release-copy.ts +0 -223
- package/src/review-stack.test.ts +0 -254
- package/src/review-stack.ts +0 -266
- package/src/run-plan-flags.test.ts +0 -53
- package/src/run.test.ts +0 -540
- package/src/run.ts +0 -1129
- package/src/serializer.test.ts +0 -9
- package/src/serializer.ts +0 -15
- package/src/skills/chant-pulumi-plunge.md +0 -51
- package/src/skills/chant-pulumi-stack-export.md +0 -54
- package/src/skills/chant-pulumi.md +0 -83
- package/src/stack-export-snapshot.test.ts +0 -192
- package/src/stack-export-snapshot.ts +0 -312
- package/src/stack-ops.fake-binary.test.ts +0 -323
- package/src/stack-ops.test.ts +0 -511
- package/src/stack-ops.ts +0 -1082
- package/src/stack-outputs.ts +0 -66
- package/src/stack-references.test.ts +0 -96
- package/src/stack-references.ts +0 -110
- package/src/testdata/plunge-drift/README.md +0 -10
- package/src/testdata/plunge-drift/assets-drifted.ndjson +0 -3
- package/src/testdata/plunge-drift/component-unsupported.ndjson +0 -3
- package/src/testdata/plunge-drift/role-in-sync.ndjson +0 -3
- package/src/testdata/plunge-drift/settled-empty.ndjson +0 -2
- package/src/testdata/plunge-graph/Pulumi.yaml +0 -4
- package/src/testdata/plunge-graph/README.md +0 -12
- package/src/testdata/plunge-graph/engine-graph.json +0 -158
- package/src/testdata/plunge-graph/stack-export.json +0 -49
- package/src/testdata/plunge-member/Pulumi.yaml +0 -4
- package/src/testdata/plunge-member/README.md +0 -3
- package/src/testdata/plunge-member/stack-export.json +0 -480
- package/src/testdata/plunge-outputs/Pulumi.yaml +0 -9
- package/src/testdata/plunge-outputs/README.md +0 -7
- package/src/testdata/plunge-outputs/stack-export.json +0 -2003
- package/src/testdata/plunge-outputs/stack-output.json +0 -19
- package/src/testdata/pulumi-member/Pulumi.yaml +0 -2
- package/src/testdata/pulumi-member/README.md +0 -50
- package/src/testdata/pulumi-member/recording/Pulumi.dev.yaml +0 -19
- package/src/testdata/pulumi-member/recording/Pulumi.yaml +0 -7
- package/src/testdata/pulumi-member/recording/index.js +0 -47
- package/src/testdata/pulumi-member/recording/package-lock.json +0 -2707
- package/src/testdata/pulumi-member/recording/package.json +0 -9
- package/src/testdata/pulumi-member/stack-export.json +0 -746
- package/src/testdata/pulumi-outputs/Pulumi.yaml +0 -7
- package/src/testdata/pulumi-outputs/README.md +0 -9
- package/src/testdata/pulumi-outputs/preview-replaced.json +0 -2894
- package/src/testdata/pulumi-outputs/preview-settled.json +0 -2894
- package/src/testdata/pulumi-outputs/stack-export.json +0 -1919
- package/src/testdata/pulumi-outputs/stack-output.json +0 -19
- package/src/testdata/pulumi-preview/Pulumi.yaml +0 -7
- package/src/testdata/pulumi-preview/README.md +0 -9
- package/src/testdata/pulumi-preview/preview-create.json +0 -992
- package/src/testdata/pulumi-preview/preview.json +0 -2894
- package/src/testdata/pulumi-preview/stack-export.json +0 -1919
- package/src/testdata/pulumi-refresh/Pulumi.yaml +0 -7
- package/src/testdata/pulumi-refresh/README.md +0 -14
- package/src/testdata/pulumi-refresh/all.json +0 -3742
- package/src/testdata/pulumi-refresh/bucket-edited.json +0 -468
- package/src/testdata/pulumi-refresh/policy-deleted.json +0 -95
- package/src/testdata/pulumi-refresh/queue-edited.json +0 -250
- package/src/testdata/pulumi-refresh/role-same.json +0 -242
- package/src/testdata/pulumi-refresh/secret-edited.json +0 -247
- package/src/testdata/pulumi-refresh/stack-export.json +0 -1907
- package/src/testdata/pulumi-stream/README.md +0 -16
- package/src/testdata/pulumi-stream/preview-stream.ndjson +0 -42
- package/src/testdata/pulumi-stream/up-failed-plunge.ndjson +0 -5
- package/src/testdata/pulumi-unexported/Pulumi.yaml +0 -2
- package/src/testdata/pulumi-urn-node/Pulumi.yaml +0 -7
- package/src/testdata/pulumi-urn-node/README.md +0 -9
- package/src/testdata/pulumi-urn-node/preview.json +0 -2894
- package/src/testdata/pulumi-urn-node/stack-export.json +0 -1919
- package/src/trace-facts.test.ts +0 -38
- package/src/trace-facts.ts +0 -83
- package/src/values.ts +0 -147
- package/src/workspace-kinds.test.ts +0 -47
- package/src/workspace-member.test.ts +0 -127
- package/src/workspace-member.ts +0 -304
package/src/package-cli.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env tsx
|
|
2
|
-
/** `npm run bundle`: write the pulumi lexicon's dist/ bundle, manifest included (#4468). */
|
|
3
|
-
import { join, dirname } from "path";
|
|
4
|
-
import { fileURLToPath } from "url";
|
|
5
|
-
import { writeBundleSpec } from "@intentius/chant/codegen/package";
|
|
6
|
-
import { packageLexicon } from "./codegen/package";
|
|
7
|
-
|
|
8
|
-
const srcDir = dirname(fileURLToPath(import.meta.url));
|
|
9
|
-
const { spec, stats } = await packageLexicon({ verbose: true });
|
|
10
|
-
const distDir = join(dirname(srcDir), "dist");
|
|
11
|
-
writeBundleSpec(spec, distDir);
|
|
12
|
-
|
|
13
|
-
console.error(`Packaged ${stats.resources} resources, ${stats.ruleCount} rules, ${stats.skillCount} skills`);
|
|
14
|
-
console.error(`dist/ written to ${distDir}`);
|
package/src/plan-shape.test.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The plan shape of a Pulumi stack (#4541, item 4), over the recorded
|
|
3
|
-
* preview of the plunge corpus on floci (`testdata/pulumi-preview`, #4475):
|
|
4
|
-
* a replaced VPC and security group, two updates and two deletes. Nothing
|
|
5
|
-
* here runs Pulumi.
|
|
6
|
-
*/
|
|
7
|
-
import { readFileSync } from "node:fs";
|
|
8
|
-
import { join } from "node:path";
|
|
9
|
-
import { describe, expect, test } from "vitest";
|
|
10
|
-
import { pulumiMayAppearAddress } from "@intentius/chant/pulumi-urn";
|
|
11
|
-
import { pulumiPreviewPart, type PulumiStep } from "./change-set";
|
|
12
|
-
import { pulumiPlanShape, pulumiShapeDifferences } from "./plan-shape";
|
|
13
|
-
|
|
14
|
-
const dir = join(import.meta.dirname, "testdata", "pulumi-preview");
|
|
15
|
-
const preview = JSON.parse(readFileSync(join(dir, "preview.json"), "utf-8")) as { steps: PulumiStep[] };
|
|
16
|
-
const urn = (type: string, name: string) => `urn:pulumi:floci::corpus-aws-ts::${type}::${name}`;
|
|
17
|
-
const member = "corpus-aws-ts/floci";
|
|
18
|
-
const partOf = (doc: unknown) => pulumiPreviewPart({ member, preview: doc, stack: "floci" });
|
|
19
|
-
|
|
20
|
-
describe("pulumiPlanShape", () => {
|
|
21
|
-
const shape = pulumiPlanShape(partOf(preview), member);
|
|
22
|
-
|
|
23
|
-
test("one entry per URN that changes; same and read steps are left out", () => {
|
|
24
|
-
expect(shape.member).toBe(member);
|
|
25
|
-
expect(shape.entries.map((e) => [e.logicalId, e.action])).toEqual(
|
|
26
|
-
[
|
|
27
|
-
[urn("aws:ec2/securityGroup:SecurityGroup", "app-sg"), "replace"],
|
|
28
|
-
[urn("aws:ec2/vpc:Vpc", "main"), "replace"],
|
|
29
|
-
[urn("aws:sqs/queue:Queue", "events"), "update"],
|
|
30
|
-
[urn("aws:sqs/queue:Queue", "worker-2"), "delete"],
|
|
31
|
-
[urn("aws:ssm/parameter:Parameter", "db-password"), "update"],
|
|
32
|
-
[urn("aws:ssm/parameter:Parameter", "vpc-id"), "delete"],
|
|
33
|
-
].sort((a, b) => a[0].localeCompare(b[0])),
|
|
34
|
-
);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test("a replace forced by a known input is true, an update is false, with type and the properties it writes", () => {
|
|
38
|
-
const vpc = shape.entries.find((e) => e.logicalId === urn("aws:ec2/vpc:Vpc", "main"))!;
|
|
39
|
-
expect(vpc).toMatchObject({ action: "replace", replacement: "true", type: "aws:ec2/vpc:Vpc" });
|
|
40
|
-
expect(vpc.properties).toContain("cidrBlock");
|
|
41
|
-
const queue = shape.entries.find((e) => e.logicalId === urn("aws:sqs/queue:Queue", "events"))!;
|
|
42
|
-
expect(queue).toMatchObject({ action: "update", replacement: "false", properties: ["messageRetentionSeconds"], unknown: [] });
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test("a replace forced only by an unknown input is conditional", () => {
|
|
46
|
-
const sg = shape.entries.find((e) => e.logicalId === urn("aws:ec2/securityGroup:SecurityGroup", "app-sg"))!;
|
|
47
|
-
// The security group reads the VPC's id, unknown while the VPC is replaced.
|
|
48
|
-
expect(sg.replacement).toBe("conditional");
|
|
49
|
-
expect(sg.unknown).toContain("vpcId");
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
test("inputs passed in are recorded", () => {
|
|
53
|
-
expect(pulumiPlanShape(partOf(preview), member, { unknownInputs: ["network.vpcId"] }).unknownInputs).toEqual(["network.vpcId"]);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
describe("pulumiShapeDifferences", () => {
|
|
58
|
-
const approved = pulumiPlanShape(partOf(preview), member);
|
|
59
|
-
|
|
60
|
-
test("the same steps are within the approval", () => {
|
|
61
|
-
expect(pulumiShapeDifferences(approved, pulumiPlanShape(partOf(preview), member), preview.steps)).toEqual([]);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
test("a create the approval did not hold is a difference", () => {
|
|
65
|
-
const extra: PulumiStep = { op: "create", urn: urn("aws:s3/bucket:Bucket", "extra"), newState: { type: "aws:s3/bucket:Bucket", inputs: { bucket: "extra" } } };
|
|
66
|
-
const steps = [...preview.steps, extra];
|
|
67
|
-
const differences = pulumiShapeDifferences(approved, pulumiPlanShape(partOf({ steps }), member), steps);
|
|
68
|
-
expect(differences).toEqual([`${member} now plans to create ${urn("aws:s3/bucket:Bucket", "extra")}, which the first plan did not`]);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
test("an update the approval showed as same is a difference", () => {
|
|
72
|
-
const steps = preview.steps.map((s) =>
|
|
73
|
-
s.urn === urn("aws:iam/role:Role", "app-role") ? { ...s, op: "update", diffReasons: ["assumeRolePolicy"], detailedDiff: { assumeRolePolicy: { kind: "update" } } } : s,
|
|
74
|
-
);
|
|
75
|
-
expect(pulumiShapeDifferences(approved, pulumiPlanShape(partOf({ steps }), member), steps)[0]).toMatch(/now plans to update .*app-role/);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
test("a resource registered under a component the approval marked mayAppear is within it", () => {
|
|
79
|
-
const site = urn("corpus:index:Site", "docs");
|
|
80
|
-
const marked = { ...approved, entries: [...approved.entries, { logicalId: pulumiMayAppearAddress(site), action: "create" as const }] };
|
|
81
|
-
const child: PulumiStep = {
|
|
82
|
-
op: "create",
|
|
83
|
-
urn: urn("corpus:index:Site$aws:s3/bucket:Bucket", "docs-logs"),
|
|
84
|
-
newState: { type: "aws:s3/bucket:Bucket", parent: site, inputs: { bucket: "docs-logs" } },
|
|
85
|
-
};
|
|
86
|
-
const steps = [...preview.steps, child];
|
|
87
|
-
expect(pulumiShapeDifferences(marked, pulumiPlanShape(partOf({ steps }), member), steps)).toEqual([]);
|
|
88
|
-
// Without the mark the same create is a difference.
|
|
89
|
-
expect(pulumiShapeDifferences(approved, pulumiPlanShape(partOf({ steps }), member), steps)).toHaveLength(1);
|
|
90
|
-
});
|
|
91
|
-
});
|
package/src/plan-shape.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The plan shape of a Pulumi or plunge stack (#4541, item 4): what a preview
|
|
3
|
-
* does, without the values, in the form core's covered rounds compare
|
|
4
|
-
* (`@intentius/chant/components/covered-round`, #4419). The `pulumi-up`
|
|
5
|
-
* capability's `plan` returns it, and a stock apply holds the steps `up`
|
|
6
|
-
* ran to it (ruling A).
|
|
7
|
-
*
|
|
8
|
-
* The shape is read from the member's change-set part (`./change-set.ts`),
|
|
9
|
-
* which already maps a URN's steps to one action and its attributes:
|
|
10
|
-
*
|
|
11
|
-
* - one entry per URN whose action is not `no-op` or `read` (a `same` or
|
|
12
|
-
* `read` step), at the URN;
|
|
13
|
-
* - `type` is the resource type;
|
|
14
|
-
* - `replacement`: on a replace, `conditional` when every attribute that
|
|
15
|
-
* forces it (`replaceReasons`, a `detailedDiff` kind ending in
|
|
16
|
-
* `-replace`) is unknown at preview, else `true`; on an update `false`;
|
|
17
|
-
* - `properties`: the top-level inputs the change writes (`detailedDiff`
|
|
18
|
-
* and `diffReasons` on an update or replace, every input on a create);
|
|
19
|
-
* - `unknown`: those holding Pulumi's unknown sentinel;
|
|
20
|
-
* - `mayAppear` entries are kept, with no `type` or `properties`, since what
|
|
21
|
-
* an `apply()` registers is not known at preview.
|
|
22
|
-
*
|
|
23
|
-
* {@link pulumiShapeDifferences} compares an approved shape with a later one.
|
|
24
|
-
* A resource registered under a component the approved shape marks
|
|
25
|
-
* `mayAppear`, or one the approved shape lists as `mayAppear` itself, is
|
|
26
|
-
* within the approval: that is what the mark promised might happen.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
import type { ChangeSetPart } from "@intentius/chant/change-set";
|
|
30
|
-
import { normalizePlanShape, planShapeDifferences, type PlanShape, type PlanShapeEntry } from "@intentius/chant/components/covered-round";
|
|
31
|
-
import { pulumiMayAppearParent } from "@intentius/chant/pulumi-urn";
|
|
32
|
-
import type { PulumiStep } from "./change-set";
|
|
33
|
-
|
|
34
|
-
export interface PulumiPlanShapeOptions {
|
|
35
|
-
/** The inputs the plan was made without, as `<component>.<output>`. */
|
|
36
|
-
unknownInputs?: string[];
|
|
37
|
-
/** The inputs the plan read with a value, by reference. */
|
|
38
|
-
knownInputs?: Record<string, unknown>;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** The shape of a Pulumi member's change-set part, for `member` (the set digest's `<member>/<stack>`). */
|
|
42
|
-
export function pulumiPlanShape(part: ChangeSetPart, member: string, opts: PulumiPlanShapeOptions = {}): PlanShape {
|
|
43
|
-
const entries: PlanShapeEntry[] = [];
|
|
44
|
-
for (const e of part.entries) {
|
|
45
|
-
if (e.action === "no-op" || e.action === "read") continue;
|
|
46
|
-
if (e.mayAppear) {
|
|
47
|
-
entries.push({ logicalId: e.address, action: e.action });
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
const attrs = e.attributes ?? [];
|
|
51
|
-
const forcing = attrs.filter((a) => a.forcesReplacement);
|
|
52
|
-
const replacement =
|
|
53
|
-
e.action === "replace" ? (forcing.length > 0 && forcing.every((a) => a.unknown) ? "conditional" : "true") : e.action === "update" ? "false" : undefined;
|
|
54
|
-
entries.push({
|
|
55
|
-
logicalId: e.address,
|
|
56
|
-
action: e.action,
|
|
57
|
-
...(replacement ? { replacement } : {}),
|
|
58
|
-
...(e.type && e.type !== "unknown" ? { type: e.type } : {}),
|
|
59
|
-
properties: attrs.map((a) => a.path),
|
|
60
|
-
unknown: attrs.filter((a) => a.unknown).map((a) => a.path),
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
return normalizePlanShape({
|
|
64
|
-
member,
|
|
65
|
-
entries,
|
|
66
|
-
unknownInputs: [...(opts.unknownInputs ?? [])],
|
|
67
|
-
...(opts.knownInputs ? { knownInputs: opts.knownInputs } : {}),
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/** Each URN's parent, from the steps' states. */
|
|
72
|
-
function parentsOf(steps: readonly PulumiStep[]): Map<string, string> {
|
|
73
|
-
const out = new Map<string, string>();
|
|
74
|
-
for (const s of steps) {
|
|
75
|
-
const parent = s.newState?.parent ?? s.oldState?.parent;
|
|
76
|
-
if (s.urn && typeof parent === "string" && parent) out.set(s.urn, parent);
|
|
77
|
-
}
|
|
78
|
-
return out;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Every way `fresh` goes beyond `approved`, as reasons; none means within.
|
|
83
|
-
* `freshSteps` are the steps `fresh` was read from, for the parent chain: an
|
|
84
|
-
* entry under a component the approved shape marks `mayAppear`, and an
|
|
85
|
-
* entry the approved shape lists as `mayAppear`, are dropped before core's
|
|
86
|
-
* `planShapeDifferences` compares the rest.
|
|
87
|
-
*/
|
|
88
|
-
export function pulumiShapeDifferences(approved: PlanShape, fresh: PlanShape, freshSteps: readonly PulumiStep[] = []): string[] {
|
|
89
|
-
const components = new Set(approved.entries.map((e) => pulumiMayAppearParent(e.logicalId)).filter((c): c is string => typeof c === "string"));
|
|
90
|
-
const mayAppear = new Set(approved.entries.filter((e) => pulumiMayAppearParent(e.logicalId) === undefined && e.type === undefined && e.properties === undefined).map((e) => e.logicalId));
|
|
91
|
-
const parents = parentsOf(freshSteps);
|
|
92
|
-
const underMarked = (urn: string): boolean => {
|
|
93
|
-
const seen = new Set<string>();
|
|
94
|
-
for (let at = parents.get(urn); at !== undefined && !seen.has(at); at = parents.get(at)) {
|
|
95
|
-
seen.add(at);
|
|
96
|
-
if (components.has(at)) return true;
|
|
97
|
-
}
|
|
98
|
-
return false;
|
|
99
|
-
};
|
|
100
|
-
// A mark on the fresh side stands for no resource of its own; what it stands for is compared where it lands.
|
|
101
|
-
const kept = fresh.entries.filter((e) => pulumiMayAppearParent(e.logicalId) === undefined && !mayAppear.has(e.logicalId) && !underMarked(e.logicalId));
|
|
102
|
-
// The approved side's marks name no resource the fresh side can match, so they leave the comparison too.
|
|
103
|
-
const approvedKept = approved.entries.filter((e) => pulumiMayAppearParent(e.logicalId) === undefined && !mayAppear.has(e.logicalId));
|
|
104
|
-
return planShapeDifferences({ ...approved, entries: approvedKept }, { ...fresh, entries: kept });
|
|
105
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Which stack outputs a preview changes (#4635), over the recorded previews
|
|
3
|
-
* in `testdata/pulumi-outputs` (pulumi 3.272.0, the plunge corpus's aws-ts
|
|
4
|
-
* program on floci, #4475) and copies of their steps edited in the test.
|
|
5
|
-
* No engine runs.
|
|
6
|
-
*/
|
|
7
|
-
import { readFileSync } from "node:fs";
|
|
8
|
-
import { join } from "node:path";
|
|
9
|
-
import { describe, expect, test } from "vitest";
|
|
10
|
-
import { pulumiPreviewPart, type PulumiStep } from "./change-set";
|
|
11
|
-
import { pulumiMemberPlannedOutputs } from "./member-outputs";
|
|
12
|
-
import { pulumiPlannedOutputChanges } from "./planned-output-changes";
|
|
13
|
-
|
|
14
|
-
const dir = join(import.meta.dirname, "testdata", "pulumi-outputs");
|
|
15
|
-
const read = (f: string) => JSON.parse(readFileSync(join(dir, f), "utf8")) as { steps: PulumiStep[] };
|
|
16
|
-
const exported = JSON.parse(readFileSync(join(dir, "stack-export.json"), "utf8")) as unknown;
|
|
17
|
-
const partOf = (preview: { steps: PulumiStep[] }, targeted = false) => pulumiPreviewPart({ member: "aws", preview, prior: exported, ...(targeted ? { targeted } : {}) });
|
|
18
|
-
|
|
19
|
-
describe("the recorded previews", () => {
|
|
20
|
-
test("a replaced VPC moves its id, the security group's, the deleted parameter's name and the deleted queue's URL", () => {
|
|
21
|
-
const r = pulumiPlannedOutputChanges({ part: partOf(read("preview-replaced.json")), exported });
|
|
22
|
-
expect(r.unknown).toEqual(["securityGroupId", "vpcId", "vpcParameterName", "workerQueueUrls"]);
|
|
23
|
-
expect(r.outputs.find((o) => o.output === "vpcId")).toEqual({ output: "vpcId", verdict: "changing", because: "aws:ec2/vpc:Vpc::main.id (replace)" });
|
|
24
|
-
expect(r.outputs.find((o) => o.output === "workerQueueUrls")).toMatchObject({ verdict: "changing", because: "aws:sqs/queue:Queue::worker-2.id (delete)" });
|
|
25
|
-
// The events queue updates in place: its id (its URL) stays.
|
|
26
|
-
expect(r.outputs.find((o) => o.output === "eventsQueueUrl")).toMatchObject({ verdict: "unchanged", because: "aws:sqs/queue:Queue::events.id (update)" });
|
|
27
|
-
expect(r.known.siteBucketName).toBe("rec-ts-site");
|
|
28
|
-
expect(r.outputs.map((o) => o.output)).not.toContain("dbPasswordValue");
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
test("a settled preview changes nothing", () => {
|
|
32
|
-
expect(pulumiPlannedOutputChanges({ part: partOf(read("preview-settled.json")), exported }).unknown).toEqual([]);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test("pulumiMemberPlannedOutputs takes the trace when the preview plans no stack outputs", () => {
|
|
36
|
-
const preview = read("preview-replaced.json");
|
|
37
|
-
const planned = pulumiMemberPlannedOutputs("aws", { part: partOf(preview), preview, exported });
|
|
38
|
-
expect(planned.unknown).toEqual(["securityGroupId", "vpcId", "vpcParameterName", "workerQueueUrls"]);
|
|
39
|
-
expect(planned.outputChanges?.length).toBe(12);
|
|
40
|
-
// With no export there is nothing to trace and no output to name.
|
|
41
|
-
expect(pulumiMemberPlannedOutputs("aws", { part: partOf(preview), preview })).toMatchObject({ known: {}, unknown: [] });
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
describe("edited from the recording", () => {
|
|
46
|
-
const settled = () => structuredClone(read("preview-settled.json"));
|
|
47
|
-
const at = (p: { steps: PulumiStep[] }, tail: string) => p.steps.find((s) => s.urn?.endsWith(tail))!;
|
|
48
|
-
|
|
49
|
-
test("an update whose diff names the input an output reads moves it", () => {
|
|
50
|
-
const p = settled();
|
|
51
|
-
const s = at(p, "aws:s3/bucket:Bucket::site-bucket");
|
|
52
|
-
s.op = "update";
|
|
53
|
-
s.newState = { ...s.newState!, inputs: { ...(s.newState!.inputs as object), bucket: "rec-ts-site-2" } };
|
|
54
|
-
s.diffReasons = ["bucket"];
|
|
55
|
-
const r = pulumiPlannedOutputChanges({ part: partOf(p), exported });
|
|
56
|
-
// siteBucketName matches the bucket's id too, and an id stays through an in-place update; bucket is the input the diff names.
|
|
57
|
-
expect(r.outputs.find((o) => o.output === "siteBucketName")).toMatchObject({ verdict: "changing", because: "aws:s3/bucket:Bucket::site-bucket.bucket (update)" });
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test("an output only a provider-computed property holds may move on an update, so it is changing", () => {
|
|
61
|
-
const exp = structuredClone(exported) as { deployment: { resources: Array<Record<string, unknown>> } };
|
|
62
|
-
const stack = exp.deployment.resources.find((r) => r.type === "pulumi:pulumi:Stack")!;
|
|
63
|
-
const queue = exp.deployment.resources.find((r) => String(r.urn).endsWith("Queue::events"))!;
|
|
64
|
-
(queue.outputs as Record<string, unknown>).computedMark = "mark-0042";
|
|
65
|
-
(stack.outputs as Record<string, unknown>).eventsMark = "mark-0042";
|
|
66
|
-
const r = pulumiPlannedOutputChanges({ part: pulumiPreviewPart({ member: "aws", preview: read("preview-replaced.json"), prior: exp }), exported: exp });
|
|
67
|
-
expect(r.outputs.find((o) => o.output === "eventsMark")).toEqual({ output: "eventsMark", verdict: "changing", because: "aws:sqs/queue:Queue::events.computedMark (update)" });
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
test("an output no property holds is untraced, so unknown", () => {
|
|
71
|
-
const exp = structuredClone(exported) as { deployment: { resources: Array<Record<string, unknown>> } };
|
|
72
|
-
const stack = exp.deployment.resources.find((r) => r.type === "pulumi:pulumi:Stack")!;
|
|
73
|
-
(stack.outputs as Record<string, unknown>).sitePattern = "arn:aws:s3:::rec-ts-site/*";
|
|
74
|
-
const r = pulumiPlannedOutputChanges({ part: pulumiPreviewPart({ member: "aws", preview: read("preview-replaced.json"), prior: exp }), exported: exp });
|
|
75
|
-
expect(r.outputs.find((o) => o.output === "sitePattern")).toEqual({ output: "sitePattern", verdict: "untraced" });
|
|
76
|
-
expect(r.unknown).toContain("sitePattern");
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
test("a resource a targeted preview does not list is left alone; an untargeted one that leaves it out may register it again", () => {
|
|
80
|
-
const p = settled();
|
|
81
|
-
p.steps = p.steps.filter((s) => !s.urn?.endsWith("aws:ec2/vpc:Vpc::main"));
|
|
82
|
-
expect(pulumiPlannedOutputChanges({ part: partOf(p, true), exported, targeted: true }).outputs.find((o) => o.output === "vpcId")?.verdict).toBe("unchanged");
|
|
83
|
-
expect(pulumiPlannedOutputChanges({ part: partOf(p), exported }).outputs.find((o) => o.output === "vpcId")?.verdict).toBe("changing");
|
|
84
|
-
});
|
|
85
|
-
});
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Which of a stack's outputs its preview changes (#4635). A real `pulumi
|
|
3
|
-
* preview --json` plans no stack outputs (recorded, #4475), so until this
|
|
4
|
-
* module every output of a stack with any change was unknown, and every
|
|
5
|
-
* stack reading any of them waited for the `up`. Here each output the last
|
|
6
|
-
* deployment holds is traced, by value, to the resource properties in the
|
|
7
|
-
* export that hold the same value, and the preview's entry for each such
|
|
8
|
-
* resource says whether the value can move:
|
|
9
|
-
*
|
|
10
|
-
* | the resource's entry | the property | verdict |
|
|
11
|
-
* |---|---|---|
|
|
12
|
-
* | replace, delete, or a `mayAppear` update | any | changes |
|
|
13
|
-
* | update | an input the diff names, or one that is unknown | changes |
|
|
14
|
-
* | update | an input the diff leaves alone; `id`, `arn` or `urn` | stable |
|
|
15
|
-
* | update | any other output (a provider-computed `version`) | may change |
|
|
16
|
-
* | no-op, read, or no entry in a targeted preview | any | stable |
|
|
17
|
-
*
|
|
18
|
-
* An output is changing when one of its matches changes, or when every
|
|
19
|
-
* match only may change; it is unchanged, with the export's value, when no
|
|
20
|
-
* match changes and one is stable. An output no property matches (one the
|
|
21
|
-
* program computed, such as `` `${bucket.arn}/*` ``), or an object, is
|
|
22
|
-
* untraced, and so unknown while the stack has changes. A list traces each
|
|
23
|
-
* string in it. Strings shorter than four characters match nothing, so a
|
|
24
|
-
* `"1"` or a `"true"` traces no output. Secret outputs are left out, as
|
|
25
|
-
* everywhere: chant reads outputs blind.
|
|
26
|
-
*
|
|
27
|
-
* The trace runs only when the preview plans no stack outputs and has
|
|
28
|
-
* changes; core's `member-outputs` and `pulumi-up`'s plan then take its
|
|
29
|
-
* unchanged outputs as known and the rest as unknown, so a stack reading
|
|
30
|
-
* through `StackReference` (#4547) an output the change moves is held until
|
|
31
|
-
* the producer applied and the reader is previewed again, and one reading
|
|
32
|
-
* only unchanged outputs plans now.
|
|
33
|
-
*/
|
|
34
|
-
import type { ChangeSetEntry, ChangeSetPart } from "@intentius/chant/change-set";
|
|
35
|
-
import { isPulumiNodeless } from "@intentius/chant/pulumi-urn";
|
|
36
|
-
import { pulumiExportedStackOutputs } from "./stack-outputs";
|
|
37
|
-
import { isObject, isSecret } from "./values";
|
|
38
|
-
|
|
39
|
-
/** One output's verdict, and the resource property that decided it. */
|
|
40
|
-
export interface PulumiOutputChange {
|
|
41
|
-
output: string;
|
|
42
|
-
verdict: "changing" | "unchanged" | "untraced";
|
|
43
|
-
/** The deciding match: `<urn tail>.<property>` and the resource's action. Absent when untraced. */
|
|
44
|
-
because?: string;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/** The trace of every output the export holds that is not secret, by name. */
|
|
48
|
-
export interface PulumiPlannedOutputChanges {
|
|
49
|
-
outputs: PulumiOutputChange[];
|
|
50
|
-
/** Unchanged outputs with the export's value. */
|
|
51
|
-
known: Record<string, unknown>;
|
|
52
|
-
/** Changing and untraced outputs. */
|
|
53
|
-
unknown: string[];
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/** Properties that stay put through an in-place update. */
|
|
57
|
-
const STABLE_OUTPUTS = new Set(["id", "arn", "urn"]);
|
|
58
|
-
|
|
59
|
-
type Verdict = "changes" | "stable" | "maybe";
|
|
60
|
-
|
|
61
|
-
interface Holder {
|
|
62
|
-
urn: string;
|
|
63
|
-
prop: string;
|
|
64
|
-
input: boolean;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const tailOf = (urn: string): string => urn.split("::").slice(2).join("::") || urn;
|
|
68
|
-
|
|
69
|
-
/** Every (resource, property) of the export holding a string worth matching, by value. */
|
|
70
|
-
function holdersByValue(exported: unknown): Map<string, Holder[]> {
|
|
71
|
-
const deployment = isObject(exported) && isObject(exported.deployment) ? exported.deployment : {};
|
|
72
|
-
const resources = Array.isArray(deployment.resources) ? deployment.resources : [];
|
|
73
|
-
const by = new Map<string, Holder[]>();
|
|
74
|
-
const add = (value: unknown, h: Holder) => {
|
|
75
|
-
if (typeof value !== "string" || value.length < 4) return;
|
|
76
|
-
const list = by.get(value) ?? [];
|
|
77
|
-
list.push(h);
|
|
78
|
-
by.set(value, list);
|
|
79
|
-
};
|
|
80
|
-
for (const r of resources) {
|
|
81
|
-
if (!isObject(r) || typeof r.urn !== "string" || typeof r.type !== "string") continue;
|
|
82
|
-
if (r.custom !== true || isPulumiNodeless(r.type)) continue;
|
|
83
|
-
const inputs = isObject(r.inputs) ? r.inputs : {};
|
|
84
|
-
add(r.id, { urn: r.urn, prop: "id", input: false });
|
|
85
|
-
for (const [k, v] of Object.entries(isObject(r.outputs) ? r.outputs : {})) {
|
|
86
|
-
if (isSecret(v)) continue;
|
|
87
|
-
add(v, { urn: r.urn, prop: k, input: k in inputs });
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return by;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function verdictOf(h: Holder, entry: ChangeSetEntry | undefined, targeted: boolean): Verdict {
|
|
94
|
-
if (!entry) return targeted ? "stable" : "changes";
|
|
95
|
-
if (entry.mayAppear === true || entry.action === "replace" || entry.action === "delete" || entry.action === "forget") return "changes";
|
|
96
|
-
if (entry.action !== "update") return "stable";
|
|
97
|
-
const attr = entry.attributes.find((a) => a.path === h.prop);
|
|
98
|
-
if (attr) return "changes";
|
|
99
|
-
if (h.input || STABLE_OUTPUTS.has(h.prop)) return "stable";
|
|
100
|
-
return "maybe";
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Trace each of the export's stack outputs through the member's part (the
|
|
105
|
-
* change set its preview became). `targeted` says the preview was narrowed
|
|
106
|
-
* with `--target`, so a resource it did not list is not touched by it.
|
|
107
|
-
*/
|
|
108
|
-
export function pulumiPlannedOutputChanges(input: { part: ChangeSetPart; exported: unknown; targeted?: boolean }): PulumiPlannedOutputChanges {
|
|
109
|
-
const byUrn = new Map<string, ChangeSetEntry>();
|
|
110
|
-
for (const e of input.part.entries) if (!byUrn.has(e.address)) byUrn.set(e.address, e);
|
|
111
|
-
const holders = holdersByValue(input.exported);
|
|
112
|
-
const targeted = input.targeted === true;
|
|
113
|
-
|
|
114
|
-
const traceString = (value: string): { verdict: PulumiOutputChange["verdict"]; because?: string } => {
|
|
115
|
-
const list = holders.get(value) ?? [];
|
|
116
|
-
if (list.length === 0) return { verdict: "untraced" };
|
|
117
|
-
const judged = list.map((h) => ({ h, v: verdictOf(h, byUrn.get(h.urn), targeted), action: byUrn.get(h.urn)?.action ?? "unlisted" }));
|
|
118
|
-
const why = (j: (typeof judged)[number]) => `${tailOf(j.h.urn)}.${j.h.prop} (${j.action})`;
|
|
119
|
-
const changes = judged.find((j) => j.v === "changes");
|
|
120
|
-
if (changes) return { verdict: "changing", because: why(changes) };
|
|
121
|
-
const stable = judged.find((j) => j.v === "stable");
|
|
122
|
-
if (stable) return { verdict: "unchanged", because: why(stable) };
|
|
123
|
-
return { verdict: "changing", because: why(judged[0]!) };
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
const outputs: PulumiOutputChange[] = [];
|
|
127
|
-
const known: Record<string, unknown> = {};
|
|
128
|
-
for (const o of pulumiExportedStackOutputs(input.exported)) {
|
|
129
|
-
if (o.secret) continue;
|
|
130
|
-
let traced: { verdict: PulumiOutputChange["verdict"]; because?: string };
|
|
131
|
-
if (typeof o.value === "string") traced = traceString(o.value);
|
|
132
|
-
else if (Array.isArray(o.value) && o.value.length > 0 && o.value.every((v) => typeof v === "string")) {
|
|
133
|
-
const each = (o.value as string[]).map(traceString);
|
|
134
|
-
traced = each.find((t) => t.verdict === "changing") ?? each.find((t) => t.verdict === "untraced") ?? each[0]!;
|
|
135
|
-
} else traced = { verdict: "untraced" };
|
|
136
|
-
outputs.push({ output: o.name, verdict: traced.verdict, ...(traced.because ? { because: traced.because } : {}) });
|
|
137
|
-
if (traced.verdict === "unchanged") known[o.name] = o.value;
|
|
138
|
-
}
|
|
139
|
-
outputs.sort((a, b) => (a.output < b.output ? -1 : a.output > b.output ? 1 : 0));
|
|
140
|
-
return { outputs, known, unknown: outputs.filter((o) => o.verdict !== "unchanged").map((o) => o.output) };
|
|
141
|
-
}
|
package/src/plugin.test.ts
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The pulumi lexicon plugin (#4453): a LexiconPlugin with no declarable
|
|
3
|
-
* kinds, whose job is the `pulumi` member kind's graph read. Nothing here
|
|
4
|
-
* runs Pulumi.
|
|
5
|
-
*/
|
|
6
|
-
import { readFileSync } from "node:fs";
|
|
7
|
-
import { join } from "node:path";
|
|
8
|
-
import { describe, expect, test } from "vitest";
|
|
9
|
-
import { isLexiconPlugin } from "@intentius/chant/lexicon";
|
|
10
|
-
import { pulumiConfigSchema } from "./config";
|
|
11
|
-
import { pulumiPlugin } from "./plugin";
|
|
12
|
-
import { lastMemberRead } from "./workspace-member";
|
|
13
|
-
|
|
14
|
-
const member = join(import.meta.dirname, "testdata", "pulumi-member");
|
|
15
|
-
|
|
16
|
-
describe("pulumiPlugin", () => {
|
|
17
|
-
test("is a LexiconPlugin named pulumi", () => {
|
|
18
|
-
expect(isLexiconPlugin(pulumiPlugin)).toBe(true);
|
|
19
|
-
expect(pulumiPlugin.name).toBe("pulumi");
|
|
20
|
-
expect(pulumiPlugin.serializer.name).toBe("pulumi");
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test("the config namespace takes a member and nothing else", () => {
|
|
24
|
-
expect(pulumiConfigSchema.parse({ member: { dir: member, label: "infra" } })).toEqual({ member: { dir: member, label: "infra" } });
|
|
25
|
-
expect(() => pulumiConfigSchema.parse({ member: { dir: "" } })).toThrow();
|
|
26
|
-
expect(() => pulumiConfigSchema.parse({ pulumiMember: { dir: member } })).toThrow();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test("buildRoots reads the member's export and graphMeta reports it", async () => {
|
|
30
|
-
const roots = await pulumiPlugin.buildRoots!({ config: { pulumi: { member: { dir: member, label: "infra" } } } } as never);
|
|
31
|
-
expect([...roots.entities.keys()]).toContain("infra/aws:s3/bucket:Bucket::assets");
|
|
32
|
-
expect(pulumiPlugin.graphMeta!(roots.entities)).toEqual({ pulumiMember: { export: "stack-export.json", exportSource: "file", objects: 5, exported: true } });
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test("with no member in the config, no entities and no report", async () => {
|
|
36
|
-
const roots = await pulumiPlugin.buildRoots!({ config: {} } as never);
|
|
37
|
-
expect(roots.entities.size).toBe(0);
|
|
38
|
-
expect(pulumiPlugin.graphMeta!(roots.entities)).toBeUndefined();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
test("a relative member dir resolves against the project root (#4468)", async () => {
|
|
42
|
-
const roots = await pulumiPlugin.buildRoots!({
|
|
43
|
-
projectRoot: import.meta.dirname,
|
|
44
|
-
config: { pulumi: { member: { dir: "testdata/pulumi-member", label: "infra" } } },
|
|
45
|
-
} as never);
|
|
46
|
-
expect([...roots.entities.keys()]).toContain("infra/aws:s3/bucket:Bucket::assets");
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test("meets the tier-1 lexicon surface: lint, post-synth, completion, hover, docs (#4468)", () => {
|
|
50
|
-
expect(pulumiPlugin.lintRules!().map((r) => r.id)).toEqual(["PUL101"]);
|
|
51
|
-
expect(pulumiPlugin.postSynthChecks!().map((c) => c.id)).toHaveLength(15);
|
|
52
|
-
expect(typeof pulumiPlugin.completionProvider).toBe("function");
|
|
53
|
-
expect(typeof pulumiPlugin.hoverProvider).toBe("function");
|
|
54
|
-
expect(typeof pulumiPlugin.docs).toBe("function");
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
test("buildRoots leaves the member read for PUL003 to PUL015, and clears it with no member (#4510)", async () => {
|
|
58
|
-
await pulumiPlugin.buildRoots!({ config: { pulumi: { member: { dir: member, label: "infra", stack: "dev" } } } } as never);
|
|
59
|
-
expect(lastMemberRead()).toMatchObject({ dir: member, label: "infra", stack: "dev" });
|
|
60
|
-
expect(lastMemberRead()?.doc).toMatchObject({ deployment: {} });
|
|
61
|
-
await pulumiPlugin.buildRoots!({ config: {} } as never);
|
|
62
|
-
expect(lastMemberRead()).toBeUndefined();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
test("detectTemplate recognises a stack export and a Pulumi.yaml, and nothing else (#4510)", () => {
|
|
66
|
-
const detect = pulumiPlugin.detectTemplate!;
|
|
67
|
-
const exported = JSON.parse(readFileSync(join(member, "stack-export.json"), "utf-8"));
|
|
68
|
-
expect(detect(exported)).toBe(true);
|
|
69
|
-
expect(detect({ version: 3, deployment: { manifest: {}, resources: [] } })).toBe(true);
|
|
70
|
-
expect(detect({ name: "app", runtime: "nodejs" })).toBe(true);
|
|
71
|
-
expect(detect({ name: "app", runtime: { name: "python", options: { toolchain: "uv" } } })).toBe(true);
|
|
72
|
-
|
|
73
|
-
expect(detect({ name: "app", runtime: "node" })).toBe(false);
|
|
74
|
-
expect(detect({ AWSTemplateFormatVersion: "2010-09-09", Resources: {} })).toBe(false);
|
|
75
|
-
expect(detect({ apiVersion: "v1", kind: "ConfigMap", metadata: { name: "x" } })).toBe(false);
|
|
76
|
-
expect(detect({ services: { web: { image: "nginx" } } })).toBe(false);
|
|
77
|
-
expect(detect({ version: 3 })).toBe(false);
|
|
78
|
-
expect(detect("name: app\nruntime: nodejs\n")).toBe(false);
|
|
79
|
-
expect(detect(null)).toBe(false);
|
|
80
|
-
expect(detect([])).toBe(false);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
test("initTemplates: member by default, watch and plunge by name (#4510)", () => {
|
|
84
|
-
const init = pulumiPlugin.initTemplates!;
|
|
85
|
-
expect(init()).toEqual(init("member"));
|
|
86
|
-
expect(Object.keys(init().src)).toEqual(["infra.ts"]);
|
|
87
|
-
expect(init().root?.["chant.config.ts"]).toContain(`member: { dir: "./infra", label: "infra" }`);
|
|
88
|
-
|
|
89
|
-
expect(Object.keys(init("watch").src).sort()).toEqual(["infra.ts", "watch.op.ts"]);
|
|
90
|
-
expect(init("watch").src["watch.op.ts"]).toContain("PulumiWatchOp({");
|
|
91
|
-
expect(init("watch").src["watch.op.ts"]).not.toContain("engine");
|
|
92
|
-
|
|
93
|
-
expect(init("plunge").src["watch.op.ts"]).toContain(`engine: "plunge"`);
|
|
94
|
-
expect(init("plunge").root?.["chant.config.ts"]).toContain(`engine: "plunge"`);
|
|
95
|
-
});
|
|
96
|
-
});
|