@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/changed-units.ts
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Pulumi stacks a change touched, judged from the changed files alone
|
|
3
|
-
* (`LexiconPlugin.changedUnits`, #3183; INTENTIUS/plywood#22). A Pulumi
|
|
4
|
-
* program and its stack configs are not chant source, so `chant lifecycle
|
|
5
|
-
* affected`'s artifact diff never shows them, and without this a pull request
|
|
6
|
-
* that edits `Pulumi.dev.yaml` selects no component at all.
|
|
7
|
-
*
|
|
8
|
-
* A file belongs to the nearest directory at or above it holding a
|
|
9
|
-
* `Pulumi.yaml` (or `Pulumi.yml`), the project, never above the project root:
|
|
10
|
-
*
|
|
11
|
-
* - `Pulumi.<stack>.yaml` in that directory is the stack's config, so it
|
|
12
|
-
* touches that stack alone;
|
|
13
|
-
* - any other file there or below (the program, `Pulumi.yaml`, the
|
|
14
|
-
* package files) touches every stack of the project, which is each
|
|
15
|
-
* `Pulumi.<stack>.yaml` beside `Pulumi.yaml` at head and any the change
|
|
16
|
-
* deleted. A stack with no config file has no file to find it by, so a
|
|
17
|
-
* program change does not reach it.
|
|
18
|
-
*
|
|
19
|
-
* Files under a directory whose name starts with a dot (`.forgejo`, `.chant`,
|
|
20
|
-
* `.git`) or under `node_modules` are not the program. A file outside every
|
|
21
|
-
* project, such as a module the program imports from `../shared`, is not
|
|
22
|
-
* claimed.
|
|
23
|
-
*
|
|
24
|
-
* Each unit is named as core's `DEPLOY_UNIT_RULES` names a `pulumi-up` step:
|
|
25
|
-
* `<dir>/<stack>`, or `<stack>` for a project at the project root.
|
|
26
|
-
*/
|
|
27
|
-
import { existsSync, readdirSync } from "node:fs";
|
|
28
|
-
import { join, posix } from "node:path";
|
|
29
|
-
|
|
30
|
-
const PROJECT_FILES = ["Pulumi.yaml", "Pulumi.yml"];
|
|
31
|
-
const STACK_CONFIG = /^Pulumi\.(.+)\.ya?ml$/;
|
|
32
|
-
|
|
33
|
-
/** The unit core names for a `pulumi-up` step on `stack` in `dir` (deploy-units.ts `pulumiStackUnit`). */
|
|
34
|
-
export function pulumiStackUnit(dir: string, stack: string): string {
|
|
35
|
-
const d = dir.replace(/\\/g, "/").replace(/^(\.\/)+/, "").replace(/\/+$/, "");
|
|
36
|
-
return d === "" || d === "." ? stack : `${d}/${stack}`;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/** The project directory (relative, `""` for the root) holding `file`, or undefined when none does. */
|
|
40
|
-
function projectOf(projectRoot: string, file: string, changed: ReadonlySet<string>): string | undefined {
|
|
41
|
-
let dir = posix.dirname(file);
|
|
42
|
-
for (;;) {
|
|
43
|
-
const rel = dir === "." ? "" : dir;
|
|
44
|
-
for (const name of PROJECT_FILES) {
|
|
45
|
-
const p = rel === "" ? name : `${rel}/${name}`;
|
|
46
|
-
// A deleted Pulumi.yaml still names its project for the change that deleted it.
|
|
47
|
-
if (existsSync(join(projectRoot, p)) || changed.has(p)) return rel;
|
|
48
|
-
}
|
|
49
|
-
if (rel === "") return undefined;
|
|
50
|
-
dir = posix.dirname(dir);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** The stacks of the project in `dir`: the stack configs at head, and the ones the change names. */
|
|
55
|
-
function stacksOf(projectRoot: string, dir: string, changed: readonly string[]): string[] {
|
|
56
|
-
const out = new Set<string>();
|
|
57
|
-
let names: string[] = [];
|
|
58
|
-
try {
|
|
59
|
-
names = readdirSync(join(projectRoot, dir));
|
|
60
|
-
} catch {
|
|
61
|
-
// The project directory is gone at head; the change's own files still name stacks.
|
|
62
|
-
}
|
|
63
|
-
for (const n of names) {
|
|
64
|
-
const m = STACK_CONFIG.exec(n);
|
|
65
|
-
if (m) out.add(m[1]!);
|
|
66
|
-
}
|
|
67
|
-
for (const f of changed) {
|
|
68
|
-
if (posix.dirname(f) !== (dir === "" ? "." : dir)) continue;
|
|
69
|
-
const m = STACK_CONFIG.exec(posix.basename(f));
|
|
70
|
-
if (m) out.add(m[1]!);
|
|
71
|
-
}
|
|
72
|
-
return [...out];
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function ignored(file: string): boolean {
|
|
76
|
-
const parts = file.split("/");
|
|
77
|
-
return parts.slice(0, -1).some((p) => p.startsWith(".") || p === "node_modules");
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/** The stack units `changedFiles` (relative to `projectRoot`, `/` separators) touch, sorted. */
|
|
81
|
-
export function pulumiChangedUnits(projectRoot: string, changedFiles: readonly string[]): string[] {
|
|
82
|
-
const files = changedFiles.map((f) => f.replace(/\\/g, "/").replace(/^\.\//, "")).filter((f) => f !== "" && !f.startsWith("../") && !ignored(f));
|
|
83
|
-
const changed = new Set(files);
|
|
84
|
-
const units = new Set<string>();
|
|
85
|
-
const whole = new Set<string>();
|
|
86
|
-
for (const f of files) {
|
|
87
|
-
const dir = projectOf(projectRoot, f, changed);
|
|
88
|
-
if (dir === undefined) continue;
|
|
89
|
-
const here = posix.dirname(f) === (dir === "" ? "." : dir);
|
|
90
|
-
const m = STACK_CONFIG.exec(posix.basename(f));
|
|
91
|
-
if (here && m && !PROJECT_FILES.includes(posix.basename(f))) units.add(pulumiStackUnit(dir, m[1]!));
|
|
92
|
-
else whole.add(dir);
|
|
93
|
-
}
|
|
94
|
-
for (const dir of whole) for (const stack of stacksOf(projectRoot, dir, files)) units.add(pulumiStackUnit(dir, stack));
|
|
95
|
-
return [...units].sort();
|
|
96
|
-
}
|
package/src/check-step.test.ts
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The pulumi check steps (#4633): install, stack config against the
|
|
3
|
-
* project's schema, and about, with a fake runner, so no binary runs and no
|
|
4
|
-
* backend is read or written.
|
|
5
|
-
*/
|
|
6
|
-
import { mkdtempSync, mkdirSync, writeFileSync } from "node:fs";
|
|
7
|
-
import { tmpdir } from "node:os";
|
|
8
|
-
import { join } from "node:path";
|
|
9
|
-
import { describe, expect, test } from "vitest";
|
|
10
|
-
import { runCheckStage } from "@intentius/chant/components/check-steps";
|
|
11
|
-
import { listedStacks, pulumiAboutDetail, pulumiCheckSteps, pulumiMemberCheck, pulumiProjectSchema, pulumiStackConfigProblems } from "./check-step";
|
|
12
|
-
import { pulumiPlugin } from "./plugin";
|
|
13
|
-
import { allowedCheck, runCheckPulumi, type PulumiRunner } from "./run";
|
|
14
|
-
|
|
15
|
-
const PROJECT = `name: shop
|
|
16
|
-
runtime: nodejs
|
|
17
|
-
config:
|
|
18
|
-
aws:region: us-east-1
|
|
19
|
-
replicas:
|
|
20
|
-
type: integer
|
|
21
|
-
size:
|
|
22
|
-
type: string
|
|
23
|
-
default: small
|
|
24
|
-
dbPassword:
|
|
25
|
-
type: string
|
|
26
|
-
secret: true
|
|
27
|
-
zones:
|
|
28
|
-
type: array
|
|
29
|
-
items:
|
|
30
|
-
type: string
|
|
31
|
-
`;
|
|
32
|
-
|
|
33
|
-
const ABOUT = JSON.stringify({
|
|
34
|
-
cli: { version: "3.140.0" },
|
|
35
|
-
plugins: [{ name: "aws", version: "6.60.0" }, { name: "nodejs", version: "unknown" }],
|
|
36
|
-
backend: { name: "laptop", url: "file:///tmp/state", user: "ci" },
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
function member(files: Record<string, string>, fields: Record<string, unknown> | null = null) {
|
|
40
|
-
const dir = mkdtempSync(join(tmpdir(), "chant-pulumi-check-"));
|
|
41
|
-
for (const [name, text] of Object.entries(files)) {
|
|
42
|
-
mkdirSync(join(dir, name, ".."), { recursive: true });
|
|
43
|
-
writeFileSync(join(dir, name), text);
|
|
44
|
-
}
|
|
45
|
-
return { name: "shop", dir, kind: "pulumi", fields };
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function fake(answers: Record<string, { stdout?: string; fail?: { code?: number | string; stderr?: string; stdout?: string } }>) {
|
|
49
|
-
const calls: Array<{ engine: string; args: string[]; env?: Record<string, string> }> = [];
|
|
50
|
-
const runner = (engine: string, env: Record<string, string>): PulumiRunner => async (args) => {
|
|
51
|
-
calls.push({ engine, args, env });
|
|
52
|
-
const a = answers[args.join(" ")] ?? { stdout: "" };
|
|
53
|
-
if (a.fail) throw Object.assign(new Error(`${engine} ${args.join(" ")} failed`), a.fail);
|
|
54
|
-
return { stdout: a.stdout ?? "" };
|
|
55
|
-
};
|
|
56
|
-
return { calls, runner };
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const ctx = { env: { PATH: "/bin" }, log: () => {} };
|
|
60
|
-
|
|
61
|
-
describe("the check argv (#4633)", () => {
|
|
62
|
-
test("install and about --json, optionally with a stack, and nothing else", () => {
|
|
63
|
-
expect(allowedCheck(["install"])).toBe(true);
|
|
64
|
-
expect(allowedCheck(["about", "--json"])).toBe(true);
|
|
65
|
-
expect(allowedCheck(["about", "--json", "--stack", "dev"])).toBe(true);
|
|
66
|
-
expect(allowedCheck(["install", "--reinstall"])).toBe(false);
|
|
67
|
-
expect(allowedCheck(["about"])).toBe(false);
|
|
68
|
-
expect(allowedCheck(["about", "--json", "--stack", "--yes"])).toBe(false);
|
|
69
|
-
expect(allowedCheck(["up", "--yes"])).toBe(false);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
test("runCheckPulumi refuses an argv off the list before the runner sees it", async () => {
|
|
73
|
-
let ran = false;
|
|
74
|
-
const run: PulumiRunner = async () => {
|
|
75
|
-
ran = true;
|
|
76
|
-
return { stdout: "" };
|
|
77
|
-
};
|
|
78
|
-
await expect(runCheckPulumi(run, ["up", "--yes"], "/tmp")).rejects.toThrow(/check stage runs only/);
|
|
79
|
-
expect(ran).toBe(false);
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
describe("stack config against the project's schema", () => {
|
|
84
|
-
const schema = pulumiProjectSchema({ name: "shop", config: { "aws:region": "us-east-1", replicas: { type: "integer" }, size: { type: "string", default: "small" }, dbPassword: { type: "string", secret: true }, zones: { type: "array", items: { type: "string" } } } });
|
|
85
|
-
|
|
86
|
-
test("reads the keys in full form", () => {
|
|
87
|
-
expect(schema.keys.map((k) => k.key)).toEqual(["aws:region", "shop:replicas", "shop:size", "shop:dbPassword", "shop:zones"]);
|
|
88
|
-
expect(schema.stackConfigDir).toBe(".");
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
test("a stack that sets every required key with the right types passes", () => {
|
|
92
|
-
expect(pulumiStackConfigProblems(schema, "dev", { config: { "shop:replicas": "3", "shop:dbPassword": { secure: "AAAB" }, "shop:zones": ["a", "b"] } })).toEqual([]);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
test("a missing key with no default, a wrong type and a plain-text secret are each named", () => {
|
|
96
|
-
const problems = pulumiStackConfigProblems(schema, "prod", { config: { "shop:size": 3, "shop:dbPassword": "hunter2", "shop:zones": ["a", ["b"]] } });
|
|
97
|
-
expect(problems).toEqual([
|
|
98
|
-
"stack prod is missing the configuration value shop:replicas (type integer, no default)",
|
|
99
|
-
"stack prod sets shop:dbPassword in plain text, and the project declares it secret; set it with pulumi config set --secret",
|
|
100
|
-
'stack prod sets shop:zones[1] to ["b"], which is not of type string',
|
|
101
|
-
]);
|
|
102
|
-
expect(pulumiStackConfigProblems(schema, "qa", { config: { replicas: "three" } })[0]).toBe('stack qa sets shop:replicas to "three", which is not of type integer');
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
test("the listed stacks are the stack files", () => {
|
|
106
|
-
const m = member({ "Pulumi.yaml": PROJECT, "Pulumi.dev.yaml": "config: {}\n", "Pulumi.prod.yml": "config: {}\n" });
|
|
107
|
-
expect(listedStacks(m.dir)).toEqual(["dev", "prod"]);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
describe("pulumi about --json", () => {
|
|
112
|
-
test("reads the engine, plugins and backend", () => {
|
|
113
|
-
expect(pulumiAboutDetail("pulumi", ABOUT)).toEqual({
|
|
114
|
-
engine: "pulumi",
|
|
115
|
-
version: "3.140.0",
|
|
116
|
-
plugins: [{ name: "aws", version: "6.60.0" }, { name: "nodejs", version: "unknown" }],
|
|
117
|
-
backend: { name: "laptop", url: "file:///tmp/state", user: "ci" },
|
|
118
|
-
});
|
|
119
|
-
expect(pulumiAboutDetail("pulumi", "not json")).toBeUndefined();
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
describe("a member's steps", () => {
|
|
124
|
-
test("install, each stack's config and about pass in order, with the check job's environment", async () => {
|
|
125
|
-
const m = member({ "Pulumi.yaml": PROJECT, "Pulumi.dev.yaml": "config:\n shop:replicas: \"2\"\n shop:dbPassword:\n secure: AAAB\n shop:zones: [a, b]\n" });
|
|
126
|
-
const { calls, runner } = fake({ "about --json": { stdout: ABOUT } });
|
|
127
|
-
const out = await pulumiMemberCheck(m, ctx, { runner });
|
|
128
|
-
expect(out.map((o) => [o.step, o.stack ?? "", o.outcome])).toEqual([
|
|
129
|
-
["pulumi-install", "", "passed"],
|
|
130
|
-
["stack-config", "dev", "passed"],
|
|
131
|
-
["pulumi-about", "", "passed"],
|
|
132
|
-
]);
|
|
133
|
-
expect(calls.map((c) => c.args.join(" "))).toEqual(["install", "about --json"]);
|
|
134
|
-
expect(calls.every((c) => c.engine === "pulumi" && c.env?.PATH === "/bin")).toBe(true);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
test("a member on plunge runs plunge, and its declared stack goes to about", async () => {
|
|
138
|
-
const m = member({ "Pulumi.yaml": PROJECT }, { engine: "plunge", stack: "dev" });
|
|
139
|
-
const { calls, runner } = fake({ "about --json --stack dev": { stdout: ABOUT } });
|
|
140
|
-
const out = await pulumiMemberCheck(m, ctx, { runner });
|
|
141
|
-
expect(calls.map((c) => `${c.engine} ${c.args.join(" ")}`)).toEqual(["plunge install", "plunge about --json --stack dev"]);
|
|
142
|
-
// dev has no stack file, and replicas has no default.
|
|
143
|
-
expect(out.find((o) => o.step === "stack-config")).toMatchObject({ stack: "dev", outcome: "failed", reason: expect.stringContaining("member shop: stack dev is missing the configuration value shop:replicas") });
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
test("a failed install names the member, and about does not run", async () => {
|
|
147
|
-
const m = member({ "Pulumi.yaml": PROJECT, "Pulumi.dev.yaml": "config:\n shop:replicas: 1\n shop:dbPassword:\n secure: x\n" });
|
|
148
|
-
const { calls, runner } = fake({ install: { fail: { code: 255, stderr: "error: npm install failed\n" } } });
|
|
149
|
-
const out = await pulumiMemberCheck(m, ctx, { runner });
|
|
150
|
-
expect(out[0]).toMatchObject({ step: "pulumi-install", outcome: "failed", exit: 255, reason: "pulumi install failed for member shop: error: npm install failed" });
|
|
151
|
-
expect(out.at(-1)).toMatchObject({ step: "pulumi-about", outcome: "skipped" });
|
|
152
|
-
expect(calls.map((c) => c.args.join(" "))).toEqual(["install"]);
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
test("about that exits non-zero but prints its JSON still reports", async () => {
|
|
156
|
-
const m = member({ "Pulumi.yaml": "name: shop\nruntime: nodejs\n" });
|
|
157
|
-
const { runner } = fake({ "about --json": { fail: { code: 1, stdout: ABOUT, stderr: "error: not logged in" } } });
|
|
158
|
-
const out = await pulumiMemberCheck(m, ctx, { runner });
|
|
159
|
-
expect(out.find((o) => o.step === "pulumi-about")).toMatchObject({ outcome: "passed", exit: 1, detail: { version: "3.140.0" } });
|
|
160
|
-
expect(out.find((o) => o.step === "stack-config")).toMatchObject({ outcome: "skipped" });
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
test("a member with no Pulumi.yaml fails, naming it", async () => {
|
|
164
|
-
const m = member({ "README.md": "x" });
|
|
165
|
-
const out = await pulumiMemberCheck(m, ctx, { runner: fake({}).runner });
|
|
166
|
-
expect(out).toEqual([expect.objectContaining({ step: "pulumi-install", outcome: "failed", reason: expect.stringContaining("has no Pulumi.yaml") })]);
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
describe("in the check stage", () => {
|
|
171
|
-
test("the plugin gives the steps for the pulumi kind", () => {
|
|
172
|
-
expect(pulumiPlugin.checkSteps?.()).toMatchObject({ lexicon: "pulumi", kinds: ["pulumi"] });
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
test("a failed step fails the stage after the hooks, naming member and stack", async () => {
|
|
176
|
-
const m = member({ "Pulumi.yaml": PROJECT, "Pulumi.prod.yaml": "config: {}\n" });
|
|
177
|
-
const cwd = mkdtempSync(join(tmpdir(), "chant-pulumi-stage-"));
|
|
178
|
-
const report = await runCheckStage({
|
|
179
|
-
base: "abc123",
|
|
180
|
-
cwd,
|
|
181
|
-
read: { base: "abc123", hooks: [] },
|
|
182
|
-
members: [m],
|
|
183
|
-
adapters: [pulumiCheckSteps({ runner: fake({ "about --json": { stdout: ABOUT } }).runner })],
|
|
184
|
-
env: {},
|
|
185
|
-
log: () => {},
|
|
186
|
-
});
|
|
187
|
-
expect(report.status).toBe("failed");
|
|
188
|
-
expect(report.failed).toContain("member shop: stack prod is missing the configuration value shop:replicas");
|
|
189
|
-
expect(report.steps?.map((s) => s.step)).toEqual(["pulumi-install", "stack-config", "pulumi-about"]);
|
|
190
|
-
});
|
|
191
|
-
});
|
package/src/check-step.ts
DELETED
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The pulumi lexicon's steps in chant's check stage (#4633). `chant ci
|
|
3
|
-
* check` runs them after the `ci.hooks.check` hooks, for each workspace
|
|
4
|
-
* member of kind `pulumi` (`LexiconPlugin.checkSteps`,
|
|
5
|
-
* `@intentius/chant/components/check-steps`), so a product's check
|
|
6
|
-
* (`plywood check`) gets them through chant with nothing of its own:
|
|
7
|
-
*
|
|
8
|
-
* - `pulumi-install`: `pulumi install` (`plunge install` for a member on
|
|
9
|
-
* plunge, `./member-engine.ts`) in the member's directory, which fetches
|
|
10
|
-
* the program's dependencies and plugins the way `Pulumi.yaml` says;
|
|
11
|
-
* - `stack-config`: each stack's `Pulumi.<stack>.yaml` checked against the
|
|
12
|
-
* project's config schema in `Pulumi.yaml`, with no command run (a key
|
|
13
|
-
* with a type and no default must be set, a value must read as its type,
|
|
14
|
-
* and a `secret: true` key must be encrypted). The stacks are the ones the
|
|
15
|
-
* project lists by their files, plus the member's declared stack;
|
|
16
|
-
* - `pulumi-about`: `pulumi about --json`, which reports the engine, its
|
|
17
|
-
* plugins and the backend for the report.
|
|
18
|
-
*
|
|
19
|
-
* The argv go through `runCheckPulumi` (`./run.ts`), which refuses any
|
|
20
|
-
* other. The environment is the check job's ({@link CheckStepsContext.env}):
|
|
21
|
-
* no forge token, no OIDC request variables, no cloud credential, so neither
|
|
22
|
-
* command can write a stack. A failure names the member and stack, and the
|
|
23
|
-
* check exits with chant's `failed` code.
|
|
24
|
-
*
|
|
25
|
-
* The runner is injectable, so the tests run no binary.
|
|
26
|
-
*/
|
|
27
|
-
import { execFile } from "node:child_process";
|
|
28
|
-
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
29
|
-
import { join } from "node:path";
|
|
30
|
-
import { promisify } from "node:util";
|
|
31
|
-
import type { CheckStageMember, CheckStepOutcome, CheckStepsAdapter, CheckStepsContext } from "@intentius/chant/components/check-steps";
|
|
32
|
-
import { parseYAML } from "@intentius/chant/yaml";
|
|
33
|
-
import { pulumiMemberEngine, type PulumiMemberEngine } from "./member-engine";
|
|
34
|
-
import { engineEnv, pulumiRunFailure, runCheckPulumi, type PulumiRunner } from "./run";
|
|
35
|
-
|
|
36
|
-
const execFileAsync = promisify(execFile);
|
|
37
|
-
|
|
38
|
-
/** The lexicon name the report carries. */
|
|
39
|
-
const LEXICON = "pulumi";
|
|
40
|
-
|
|
41
|
-
/** A runner for `bin` with exactly `env` (the check job's), never the process's whole environment. */
|
|
42
|
-
export function checkRunner(bin: PulumiMemberEngine, env: Record<string, string>): PulumiRunner {
|
|
43
|
-
return (args, opts) => execFileAsync(bin, args, { cwd: opts.cwd, maxBuffer: 64 * 1024 * 1024, env: engineEnv({ ...env, ...opts.env }) });
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// ── Stack config against the project's schema ───────────────────────
|
|
47
|
-
|
|
48
|
-
/** One key the project declares in `Pulumi.yaml`'s `config:`. */
|
|
49
|
-
export interface PulumiConfigKey {
|
|
50
|
-
/** The full key, `<project>:<name>` for a project key. */
|
|
51
|
-
key: string;
|
|
52
|
-
type?: string;
|
|
53
|
-
items?: { type?: string };
|
|
54
|
-
secret: boolean;
|
|
55
|
-
/** Whether it has a `default` or a project-level `value`. */
|
|
56
|
-
hasDefault: boolean;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** The project's config schema: its name, the keys it declares, and where its stack files are. */
|
|
60
|
-
export interface PulumiProjectSchema {
|
|
61
|
-
project: string;
|
|
62
|
-
keys: PulumiConfigKey[];
|
|
63
|
-
/** The directory the stack files are in, relative to the project (`stackConfigDir`), or "." */
|
|
64
|
-
stackConfigDir: string;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const isRecord = (v: unknown): v is Record<string, unknown> => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
68
|
-
|
|
69
|
-
/** The key in its full form: a bare name belongs to the project. */
|
|
70
|
-
function fullKey(project: string, key: string): string {
|
|
71
|
-
return key.includes(":") ? key : `${project}:${key}`;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/** Read `Pulumi.yaml`'s schema from its parsed document. A short-form entry (`key: value`) is a value with no type. */
|
|
75
|
-
export function pulumiProjectSchema(doc: unknown): PulumiProjectSchema {
|
|
76
|
-
const d = isRecord(doc) ? doc : {};
|
|
77
|
-
const project = typeof d.name === "string" ? d.name : "";
|
|
78
|
-
const config = isRecord(d.config) ? d.config : {};
|
|
79
|
-
const keys: PulumiConfigKey[] = [];
|
|
80
|
-
for (const [name, entry] of Object.entries(config)) {
|
|
81
|
-
const key = fullKey(project, name);
|
|
82
|
-
const schema = isRecord(entry) && ("type" in entry || "default" in entry || "value" in entry || "secret" in entry || "description" in entry || "items" in entry);
|
|
83
|
-
if (!schema) {
|
|
84
|
-
keys.push({ key, secret: false, hasDefault: true });
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
const e = entry as Record<string, unknown>;
|
|
88
|
-
keys.push({
|
|
89
|
-
key,
|
|
90
|
-
...(typeof e.type === "string" ? { type: e.type } : {}),
|
|
91
|
-
...(isRecord(e.items) && typeof e.items.type === "string" ? { items: { type: e.items.type } } : {}),
|
|
92
|
-
secret: e.secret === true,
|
|
93
|
-
hasDefault: "default" in e || "value" in e,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
return { project, keys, stackConfigDir: typeof d.stackConfigDir === "string" && d.stackConfigDir.length > 0 ? d.stackConfigDir : "." };
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const isSecure = (v: unknown): boolean => isRecord(v) && typeof v.secure === "string";
|
|
100
|
-
|
|
101
|
-
/** Whether a scalar stack value reads as `type`. Values are strings once Pulumi reads them, so `"3"` is an integer. */
|
|
102
|
-
function readsAs(type: string, value: unknown): boolean {
|
|
103
|
-
switch (type) {
|
|
104
|
-
case "string":
|
|
105
|
-
return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
106
|
-
case "integer":
|
|
107
|
-
return (typeof value === "number" && Number.isInteger(value)) || (typeof value === "string" && /^-?[0-9]+$/.test(value.trim()));
|
|
108
|
-
case "boolean":
|
|
109
|
-
return typeof value === "boolean" || value === "true" || value === "false";
|
|
110
|
-
case "array":
|
|
111
|
-
return Array.isArray(value);
|
|
112
|
-
default:
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* What is wrong with one stack's config (`config:` of its
|
|
119
|
-
* `Pulumi.<stack>.yaml`, parsed) against the project's schema, as lines
|
|
120
|
-
* naming the stack and key. Empty when it passes. Keys of other namespaces
|
|
121
|
-
* (a provider's `aws:region`) are not checked: the project declares no type
|
|
122
|
-
* for them.
|
|
123
|
-
*/
|
|
124
|
-
export function pulumiStackConfigProblems(schema: PulumiProjectSchema, stack: string, stackDoc: unknown): string[] {
|
|
125
|
-
const raw = isRecord(stackDoc) && isRecord(stackDoc.config) ? stackDoc.config : {};
|
|
126
|
-
const values = new Map<string, unknown>();
|
|
127
|
-
for (const [k, v] of Object.entries(raw)) values.set(fullKey(schema.project, k), v);
|
|
128
|
-
const problems: string[] = [];
|
|
129
|
-
for (const k of schema.keys) {
|
|
130
|
-
if (!k.type && !k.secret) continue;
|
|
131
|
-
if (!values.has(k.key)) {
|
|
132
|
-
if (k.type && !k.hasDefault) problems.push(`stack ${stack} is missing the configuration value ${k.key} (type ${k.type}, no default)`);
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
const value = values.get(k.key);
|
|
136
|
-
if (k.secret && !isSecure(value)) {
|
|
137
|
-
problems.push(`stack ${stack} sets ${k.key} in plain text, and the project declares it secret; set it with pulumi config set --secret`);
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
140
|
-
if (isSecure(value) || !k.type) continue;
|
|
141
|
-
if (!readsAs(k.type, value)) {
|
|
142
|
-
problems.push(`stack ${stack} sets ${k.key} to ${JSON.stringify(value)}, which is not of type ${k.type}`);
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
if (k.type === "array" && k.items?.type && Array.isArray(value)) {
|
|
146
|
-
const bad = value.findIndex((item) => !isSecure(item) && !readsAs(k.items!.type!, item));
|
|
147
|
-
if (bad >= 0) problems.push(`stack ${stack} sets ${k.key}[${bad}] to ${JSON.stringify(value[bad])}, which is not of type ${k.items.type}`);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return problems;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/** The project's file in `dir`, `Pulumi.yaml` or `Pulumi.yml`. */
|
|
154
|
-
function projectFile(dir: string): string | undefined {
|
|
155
|
-
return ["Pulumi.yaml", "Pulumi.yml"].map((f) => join(dir, f)).find((f) => existsSync(f));
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/** The stacks the project lists by their `Pulumi.<stack>.yaml` files in `dir`, sorted. */
|
|
159
|
-
export function listedStacks(dir: string): string[] {
|
|
160
|
-
if (!existsSync(dir)) return [];
|
|
161
|
-
return readdirSync(dir)
|
|
162
|
-
.map((f) => /^Pulumi\.(.+)\.ya?ml$/.exec(f)?.[1])
|
|
163
|
-
.filter((s): s is string => s !== undefined)
|
|
164
|
-
.sort();
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/** The stack file for `stack` in `dir`, if there is one. */
|
|
168
|
-
function stackFile(dir: string, stack: string): string | undefined {
|
|
169
|
-
return [`Pulumi.${stack}.yaml`, `Pulumi.${stack}.yml`].map((f) => join(dir, f)).find((f) => existsSync(f));
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// ── pulumi about ────────────────────────────────────────────────────
|
|
173
|
-
|
|
174
|
-
/** What `pulumi about --json` reported, for the check report. */
|
|
175
|
-
export interface PulumiAboutDetail {
|
|
176
|
-
engine: PulumiMemberEngine;
|
|
177
|
-
version?: string;
|
|
178
|
-
plugins: Array<{ name: string; version?: string }>;
|
|
179
|
-
backend?: { name?: string; url?: string; user?: string };
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/** Read `pulumi about --json`'s document. Undefined when it is not JSON. */
|
|
183
|
-
export function pulumiAboutDetail(engine: PulumiMemberEngine, stdout: string | undefined): PulumiAboutDetail | undefined {
|
|
184
|
-
if (!stdout) return undefined;
|
|
185
|
-
let doc: unknown;
|
|
186
|
-
try {
|
|
187
|
-
doc = JSON.parse(stdout);
|
|
188
|
-
} catch {
|
|
189
|
-
return undefined;
|
|
190
|
-
}
|
|
191
|
-
if (!isRecord(doc)) return undefined;
|
|
192
|
-
const cli = isRecord(doc.cli) ? doc.cli : {};
|
|
193
|
-
const plugins = Array.isArray(doc.plugins)
|
|
194
|
-
? doc.plugins.filter(isRecord).map((p) => ({ name: String(p.name ?? ""), ...(typeof p.version === "string" ? { version: p.version } : {}) })).filter((p) => p.name)
|
|
195
|
-
: [];
|
|
196
|
-
const b = isRecord(doc.backend) ? doc.backend : undefined;
|
|
197
|
-
const backend = b
|
|
198
|
-
? { ...(typeof b.name === "string" ? { name: b.name } : {}), ...(typeof b.url === "string" ? { url: b.url } : {}), ...(typeof b.user === "string" ? { user: b.user } : {}) }
|
|
199
|
-
: undefined;
|
|
200
|
-
return { engine, ...(typeof cli.version === "string" ? { version: cli.version } : {}), plugins, ...(backend ? { backend } : {}) };
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// ── The steps ───────────────────────────────────────────────────────
|
|
204
|
-
|
|
205
|
-
/** The last lines of what a failed run printed, for its reason. */
|
|
206
|
-
function tail(text: string | undefined): string {
|
|
207
|
-
const lines = (text ?? "").trim().split("\n").filter(Boolean);
|
|
208
|
-
return lines.slice(-3).join(" | ");
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
export interface PulumiCheckStepsOptions {
|
|
212
|
-
/** The runner for an engine, given the check job's environment. Default {@link checkRunner}. */
|
|
213
|
-
runner?: (engine: PulumiMemberEngine, env: Record<string, string>) => PulumiRunner;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/** The steps for one member, in order: install, each stack's config, about. */
|
|
217
|
-
export async function pulumiMemberCheck(member: CheckStageMember, ctx: Pick<CheckStepsContext, "env" | "log">, opts: PulumiCheckStepsOptions = {}): Promise<CheckStepOutcome[]> {
|
|
218
|
-
const fields = member.fields ?? {};
|
|
219
|
-
const declaredEngine = fields.engine === "pulumi" || fields.engine === "plunge" ? fields.engine : undefined;
|
|
220
|
-
const declaredStack = typeof fields.stack === "string" && fields.stack.length > 0 ? fields.stack : undefined;
|
|
221
|
-
const { engine } = pulumiMemberEngine(member.dir, declaredEngine, { env: ctx.env });
|
|
222
|
-
const run = (opts.runner ?? checkRunner)(engine, ctx.env);
|
|
223
|
-
const out: CheckStepOutcome[] = [];
|
|
224
|
-
const base = { lexicon: LEXICON, member: member.name };
|
|
225
|
-
|
|
226
|
-
const file = projectFile(member.dir);
|
|
227
|
-
if (!file) {
|
|
228
|
-
out.push({ ...base, step: "pulumi-install", exit: 1, outcome: "failed", reason: `member ${member.name} has no Pulumi.yaml in ${member.dir}` });
|
|
229
|
-
return out;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// pulumi install
|
|
233
|
-
let installed = true;
|
|
234
|
-
try {
|
|
235
|
-
await runCheckPulumi(run, ["install"], member.dir);
|
|
236
|
-
out.push({ ...base, step: "pulumi-install", exit: 0, outcome: "passed" });
|
|
237
|
-
} catch (err) {
|
|
238
|
-
installed = false;
|
|
239
|
-
const f = pulumiRunFailure(err);
|
|
240
|
-
const why = f.missingBinary ? `${engine} is not installed in the check job` : tail(f.stderr) || tail(f.stdout) || f.message;
|
|
241
|
-
out.push({ ...base, step: "pulumi-install", exit: f.exitCode ?? 1, outcome: "failed", reason: `${engine} install failed for member ${member.name}: ${why}` });
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
// Stack config, run by nothing but this module.
|
|
245
|
-
let schema: PulumiProjectSchema | undefined;
|
|
246
|
-
try {
|
|
247
|
-
schema = pulumiProjectSchema(parseYAML(readFileSync(file, "utf-8")));
|
|
248
|
-
} catch (err) {
|
|
249
|
-
out.push({ ...base, step: "stack-config", exit: 1, outcome: "failed", reason: `member ${member.name}: ${file} does not read as YAML (${err instanceof Error ? err.message : String(err)})` });
|
|
250
|
-
}
|
|
251
|
-
if (schema) {
|
|
252
|
-
const stackDir = join(member.dir, schema.stackConfigDir);
|
|
253
|
-
const stacks = [...new Set([...listedStacks(stackDir), ...(declaredStack ? [declaredStack] : [])])].sort();
|
|
254
|
-
if (stacks.length === 0) out.push({ ...base, step: "stack-config", exit: 0, outcome: "skipped", reason: `member ${member.name} lists no stack (no Pulumi.<stack>.yaml in ${stackDir})` });
|
|
255
|
-
for (const stack of stacks) {
|
|
256
|
-
const at = stackFile(stackDir, stack);
|
|
257
|
-
let doc: unknown = {};
|
|
258
|
-
if (at) {
|
|
259
|
-
try {
|
|
260
|
-
doc = parseYAML(readFileSync(at, "utf-8"));
|
|
261
|
-
} catch (err) {
|
|
262
|
-
out.push({ ...base, step: "stack-config", stack, exit: 1, outcome: "failed", reason: `member ${member.name}, stack ${stack}: ${at} does not read as YAML (${err instanceof Error ? err.message : String(err)})` });
|
|
263
|
-
continue;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
const problems = pulumiStackConfigProblems(schema, stack, doc);
|
|
267
|
-
out.push(
|
|
268
|
-
problems.length === 0
|
|
269
|
-
? { ...base, step: "stack-config", stack, exit: 0, outcome: "passed" }
|
|
270
|
-
: { ...base, step: "stack-config", stack, exit: 1, outcome: "failed", reason: `member ${member.name}: ${problems.join("; ")}`, detail: { problems } },
|
|
271
|
-
);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// pulumi about --json
|
|
276
|
-
if (!installed) {
|
|
277
|
-
out.push({ ...base, step: "pulumi-about", exit: 0, outcome: "skipped", reason: `member ${member.name}: ${engine} install failed, so about did not run` });
|
|
278
|
-
return out;
|
|
279
|
-
}
|
|
280
|
-
const aboutArgs = declaredStack ? ["about", "--json", "--stack", declaredStack] : ["about", "--json"];
|
|
281
|
-
const stackPart = declaredStack ? { stack: declaredStack } : {};
|
|
282
|
-
try {
|
|
283
|
-
const { stdout } = await runCheckPulumi(run, aboutArgs, member.dir);
|
|
284
|
-
const detail = pulumiAboutDetail(engine, stdout);
|
|
285
|
-
out.push(
|
|
286
|
-
detail
|
|
287
|
-
? { ...base, step: "pulumi-about", ...stackPart, exit: 0, outcome: "passed", detail }
|
|
288
|
-
: { ...base, step: "pulumi-about", ...stackPart, exit: 1, outcome: "failed", reason: `${engine} about --json for member ${member.name} printed no JSON` },
|
|
289
|
-
);
|
|
290
|
-
} catch (err) {
|
|
291
|
-
const f = pulumiRunFailure(err);
|
|
292
|
-
// about exits non-zero when one of its reads fails (no backend login in a check job), and still prints what it read.
|
|
293
|
-
const detail = pulumiAboutDetail(engine, f.stdout);
|
|
294
|
-
if (detail) {
|
|
295
|
-
ctx.log(`pulumi check: ${engine} about for ${member.name} exited ${f.exitCode ?? 1} and reported: ${tail(f.stderr) || "no reason"}`);
|
|
296
|
-
out.push({ ...base, step: "pulumi-about", ...stackPart, exit: f.exitCode ?? 1, outcome: "passed", detail });
|
|
297
|
-
} else {
|
|
298
|
-
const why = f.missingBinary ? `${engine} is not installed in the check job` : tail(f.stderr) || f.message;
|
|
299
|
-
out.push({ ...base, step: "pulumi-about", ...stackPart, exit: f.exitCode ?? 1, outcome: "failed", reason: `${engine} about failed for member ${member.name}${declaredStack ? `, stack ${declaredStack}` : ""}: ${why}` });
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
return out;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
/** The pulumi lexicon's check steps, for `LexiconPlugin.checkSteps`. */
|
|
306
|
-
export function pulumiCheckSteps(opts: PulumiCheckStepsOptions = {}): CheckStepsAdapter {
|
|
307
|
-
return {
|
|
308
|
-
lexicon: LEXICON,
|
|
309
|
-
kinds: ["pulumi"],
|
|
310
|
-
async run(ctx) {
|
|
311
|
-
const out: CheckStepOutcome[] = [];
|
|
312
|
-
for (const member of ctx.members) out.push(...(await pulumiMemberCheck(member, ctx, opts)));
|
|
313
|
-
return out;
|
|
314
|
-
},
|
|
315
|
-
};
|
|
316
|
-
}
|