@intentius/chant-lexicon-pulumi 0.124.102 → 0.124.103
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/change-set.d.ts +5 -0
- package/dist/change-set.js +4 -0
- package/dist/chant-floors.d.ts +36 -0
- package/dist/chant-floors.js +36 -0
- package/dist/cost-hold.d.ts +45 -0
- package/dist/cost-hold.js +49 -0
- package/dist/describe-resources.d.ts +10 -0
- package/dist/describe-resources.js +79 -3
- package/dist/disruption.d.ts +50 -0
- package/dist/disruption.js +104 -0
- package/dist/engine-graph.d.ts +1 -1
- package/dist/engine-graph.js +40 -1
- package/dist/health-targets.d.ts +25 -0
- package/dist/health-targets.js +57 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +8 -0
- package/dist/integrity.json +2 -2
- package/dist/manifest.json +1 -1
- package/dist/plugin.js +33 -1
- package/dist/preview-observation.d.ts +97 -0
- package/dist/preview-observation.js +218 -0
- package/dist/pulumi-up.d.ts +44 -3
- package/dist/pulumi-up.js +71 -11
- package/dist/reference-catalog.d.ts +84 -0
- package/dist/reference-catalog.js +383 -0
- package/dist/reference-props.d.ts +19 -0
- package/dist/reference-props.js +93 -0
- package/dist/stack-references.js +6 -1
- package/dist/workspace-member.js +9 -3
- package/dist/workspace-stack-reads.d.ts +12 -0
- package/dist/workspace-stack-reads.js +60 -0
- package/package.json +3 -3
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a member's node carries for the reference catalog (#5330): the values
|
|
3
|
+
* a resource's inputs and outputs name other resources by. The graph read
|
|
4
|
+
* used to copy neither, since an export can hold secrets; the catalog needs
|
|
5
|
+
* the names, ids and ARNs, so this copies those and nothing else.
|
|
6
|
+
*
|
|
7
|
+
* - `inputs` keep their Pulumi shape (`vpcId`, `metadata.namespace`), minus
|
|
8
|
+
* Pulumi's own `__` keys. A secret envelope and a value under a key that
|
|
9
|
+
* reads as a credential are left out, and so are the `data`, `stringData`
|
|
10
|
+
* and `binaryData` of a Kubernetes Secret or ConfigMap.
|
|
11
|
+
* - `outputs` keep the top-level strings a resource is named by elsewhere
|
|
12
|
+
* (`arn`, `name`, `selfLink`, `email`), and the resource's `id`, under one
|
|
13
|
+
* `outputs` key so an output never replaces an input of the same name.
|
|
14
|
+
*
|
|
15
|
+
* A string longer than {@link MAX_VALUE} is a document, not a name, and is
|
|
16
|
+
* left out. Pure.
|
|
17
|
+
*/
|
|
18
|
+
import { isObject, isSecret, isUnknown } from "./values.js";
|
|
19
|
+
/** Longest string worth matching: an ARN or a self link fits, a policy document does not. */
|
|
20
|
+
const MAX_VALUE = 1024;
|
|
21
|
+
/** Keys whose values are credentials or their carriers. */
|
|
22
|
+
const SENSITIVE_KEY = /(password|passwd|secret|token|credential|private|apikey|accesskey|connectionstring|userdata|sasurl|certificatebody|pem|kubeconfig)/i;
|
|
23
|
+
/** A key that ends like a reference to a thing, which a credential-sounding word may precede (`secretArn`, `tokenName`). */
|
|
24
|
+
const REFERENCE_KEY = /(Arns?|Ids?|IDs?|Names?|Uris?|Urls?)$/;
|
|
25
|
+
/** Kubernetes kinds whose payload is data, not references. */
|
|
26
|
+
const DATA_KINDS = new Set(["kubernetes:core/v1:Secret", "kubernetes:core/v1:ConfigMap"]);
|
|
27
|
+
const DATA_KEYS = new Set(["data", "stringData", "binaryData"]);
|
|
28
|
+
const sensitiveKey = (key) => SENSITIVE_KEY.test(key) && !REFERENCE_KEY.test(key);
|
|
29
|
+
/**
|
|
30
|
+
* Whether a property named `key` may be copied to a node (#5332): not a
|
|
31
|
+
* Pulumi `__` key, not credential-like, and, at the top level of a Kubernetes
|
|
32
|
+
* Secret or ConfigMap, not its payload. The preview observation
|
|
33
|
+
* (`./preview-observation.ts`) asks this of every path it puts on a node.
|
|
34
|
+
*/
|
|
35
|
+
export function mayCarryKey(key, opts = {}) {
|
|
36
|
+
if (key.startsWith("__") || sensitiveKey(key))
|
|
37
|
+
return false;
|
|
38
|
+
const dataKind = typeof opts.type === "string" && DATA_KINDS.has(opts.type);
|
|
39
|
+
return !(dataKind && opts.topLevel && DATA_KEYS.has(key));
|
|
40
|
+
}
|
|
41
|
+
/** Whether a string is short enough to be a name rather than a document. */
|
|
42
|
+
export const isNameSized = (value) => value.length <= MAX_VALUE;
|
|
43
|
+
function clean(value, depth) {
|
|
44
|
+
if (depth > 8 || isSecret(value) || isUnknown(value) || value === null || value === undefined)
|
|
45
|
+
return undefined;
|
|
46
|
+
if (typeof value === "string")
|
|
47
|
+
return value.length <= MAX_VALUE ? value : undefined;
|
|
48
|
+
if (typeof value === "number" || typeof value === "boolean")
|
|
49
|
+
return value;
|
|
50
|
+
if (Array.isArray(value)) {
|
|
51
|
+
const items = value.map((v) => clean(v, depth + 1)).filter((v) => v !== undefined);
|
|
52
|
+
return items.length > 0 ? items : undefined;
|
|
53
|
+
}
|
|
54
|
+
if (isObject(value)) {
|
|
55
|
+
const out = {};
|
|
56
|
+
for (const [k, v] of Object.entries(value)) {
|
|
57
|
+
if (k.startsWith("__") || sensitiveKey(k))
|
|
58
|
+
continue;
|
|
59
|
+
const c = clean(v, depth + 1);
|
|
60
|
+
if (c !== undefined)
|
|
61
|
+
out[k] = c;
|
|
62
|
+
}
|
|
63
|
+
return Object.keys(out).length > 0 ? out : undefined;
|
|
64
|
+
}
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
/** The inputs and `outputs` a resource's node carries, as the node's props. */
|
|
68
|
+
export function referenceProps(resource) {
|
|
69
|
+
const props = {};
|
|
70
|
+
const dataKind = typeof resource.type === "string" && DATA_KINDS.has(resource.type);
|
|
71
|
+
if (isObject(resource.inputs)) {
|
|
72
|
+
for (const [k, v] of Object.entries(resource.inputs)) {
|
|
73
|
+
if (k.startsWith("__") || sensitiveKey(k) || (dataKind && DATA_KEYS.has(k)))
|
|
74
|
+
continue;
|
|
75
|
+
const c = clean(v, 0);
|
|
76
|
+
if (c !== undefined)
|
|
77
|
+
props[k] = c;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const outputs = {};
|
|
81
|
+
if (isObject(resource.outputs) && !dataKind) {
|
|
82
|
+
for (const [k, v] of Object.entries(resource.outputs)) {
|
|
83
|
+
if (k.startsWith("__") || sensitiveKey(k) || typeof v !== "string" || v.length > MAX_VALUE || isSecret(v) || isUnknown(v))
|
|
84
|
+
continue;
|
|
85
|
+
outputs[k] = v;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (typeof resource.id === "string" && resource.id !== "" && outputs.id === undefined)
|
|
89
|
+
outputs.id = resource.id;
|
|
90
|
+
if (Object.keys(outputs).length > 0)
|
|
91
|
+
props.outputs = outputs;
|
|
92
|
+
return props;
|
|
93
|
+
}
|
package/dist/stack-references.js
CHANGED
|
@@ -18,7 +18,12 @@
|
|
|
18
18
|
* waves put the referenced stack first, a failed upstream holds the reader,
|
|
19
19
|
* and a reader whose upstream's plan cannot say a value waits for its `up`.
|
|
20
20
|
*
|
|
21
|
-
*
|
|
21
|
+
* `graphReads` (`./pulumi-up.ts`, #5331) is the same reader for `chant graph
|
|
22
|
+
* --components`: an edge from the reader's component to the upstream's, one
|
|
23
|
+
* per output the export recorded (secret ones by name), and for a reference
|
|
24
|
+
* to a stack no step applies, a node marked external to draw the edge to.
|
|
25
|
+
*
|
|
26
|
+
* What adds no edge to the wave order, and is reported on the plan by name
|
|
22
27
|
* (`PulumiUpArtifact.stackReferences.outside`): a reference to a stack no
|
|
23
28
|
* step in the project applies, one two steps could own, and one whose
|
|
24
29
|
* export recorded no output that is not secret (core reads a stack's
|
package/dist/workspace-member.js
CHANGED
|
@@ -29,8 +29,10 @@
|
|
|
29
29
|
* resources that name them are not edged to them. Edges come from each
|
|
30
30
|
* resource's `dependencies` and `parent`, kept only when the target is a node,
|
|
31
31
|
* each with `grain: "instance"` (#4529): it joins two resources, not two
|
|
32
|
-
* blocks of source.
|
|
33
|
-
*
|
|
32
|
+
* blocks of source. A node carries the values its resource is named by and
|
|
33
|
+
* names others by (`./reference-props.ts`, #5330): inputs and the top-level
|
|
34
|
+
* string outputs, minus secrets and credential-like keys, for the lexicon's
|
|
35
|
+
* `referenceCatalog` to read. Nothing else of the inputs and outputs is copied.
|
|
34
36
|
*
|
|
35
37
|
* A member on plunge may also check in {@link PULUMI_ENGINE_GRAPH_FILE}
|
|
36
38
|
* beside the export: what `plunge graph --json --stack <stack>` printed
|
|
@@ -49,6 +51,7 @@ import { DECLARABLE_MARKER } from "@intentius/chant/declarable";
|
|
|
49
51
|
import { isPulumiNodeless, pulumiNodeKey } from "@intentius/chant/pulumi-urn";
|
|
50
52
|
import { PULUMI_ENGINE_GRAPH_FILE, readPlungeEngineGraph } from "./engine-graph.js";
|
|
51
53
|
import { pulumiMemberEngine } from "./member-engine.js";
|
|
54
|
+
import { referenceProps } from "./reference-props.js";
|
|
52
55
|
import { PULUMI_EXPORT_FILE } from "./member-report.js";
|
|
53
56
|
export function readPulumiMember(opts) {
|
|
54
57
|
const { member } = opts;
|
|
@@ -112,12 +115,15 @@ export function readPulumiMember(opts) {
|
|
|
112
115
|
if (references.size > before)
|
|
113
116
|
propertyEdges++;
|
|
114
117
|
}
|
|
118
|
+
// The component that registered it (#5403): the export's `parent`, when that is a node.
|
|
119
|
+
const component = node(r.parent);
|
|
115
120
|
const entity = {
|
|
116
121
|
lexicon: "pulumi",
|
|
117
122
|
entityType: r.type,
|
|
118
123
|
kind: "resource",
|
|
119
|
-
props:
|
|
124
|
+
props: referenceProps(r),
|
|
120
125
|
references: [...references.values()],
|
|
126
|
+
...(component && component !== key ? { component } : {}),
|
|
121
127
|
[DECLARABLE_MARKER]: true,
|
|
122
128
|
};
|
|
123
129
|
const facts = engine?.facts.get(urn);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LexiconStackReads } from "@intentius/chant/lexicon";
|
|
2
|
+
export declare function pulumiWorkspaceStackReads(ctx: {
|
|
3
|
+
root: string;
|
|
4
|
+
env?: string;
|
|
5
|
+
members: readonly {
|
|
6
|
+
name: string;
|
|
7
|
+
dir: string;
|
|
8
|
+
kind: string;
|
|
9
|
+
}[];
|
|
10
|
+
}, opts?: {
|
|
11
|
+
exportStore?: null;
|
|
12
|
+
}): Promise<LexiconStackReads | undefined>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `StackReference` reads between workspace members (#5331), for `chant
|
|
3
|
+
* workspace graph`. The graph composition asks the lexicon once with every
|
|
4
|
+
* declared member; each member of kind `pulumi` is a step of the same shape
|
|
5
|
+
* `pulumi-up` takes (`dir`, `stack`), and {@link pulumiStackReads}, the
|
|
6
|
+
* reader behind `declaredReads` and `graphReads`, finds its references. A
|
|
7
|
+
* reference to the stack another member applies is a read of that member; one
|
|
8
|
+
* to a stack no member applies is external.
|
|
9
|
+
*
|
|
10
|
+
* A member's stack is `--env` when the member has a `Pulumi.<env>.yaml`
|
|
11
|
+
* (the stack the environment deploys), else the stack its checked-in export
|
|
12
|
+
* records. A member with neither takes part in no read. The node each member
|
|
13
|
+
* is drawn as is `pulumi:pulumi:Stack`, the type token of the stack's own
|
|
14
|
+
* resource, which the member read leaves out.
|
|
15
|
+
*/
|
|
16
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
17
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
18
|
+
import { PULUMI_STACK_TYPE } from "@intentius/chant/pulumi-urn";
|
|
19
|
+
import { pulumiStackReads } from "./pulumi-up.js";
|
|
20
|
+
import { PULUMI_EXPORT_FILE } from "./member-report.js";
|
|
21
|
+
import { isObject } from "./values.js";
|
|
22
|
+
/** The stack a checked-in export records: the stack of its first URN (`urn:pulumi:<stack>::<project>::...`). */
|
|
23
|
+
function exportedStack(dir) {
|
|
24
|
+
try {
|
|
25
|
+
const doc = JSON.parse(readFileSync(join(dir, PULUMI_EXPORT_FILE), "utf-8"));
|
|
26
|
+
const list = isObject(doc) && isObject(doc.deployment) && Array.isArray(doc.deployment.resources) ? doc.deployment.resources : [];
|
|
27
|
+
for (const r of list) {
|
|
28
|
+
const urn = isObject(r) && typeof r.urn === "string" ? r.urn : undefined;
|
|
29
|
+
const m = urn ? /^urn:pulumi:([^:]+)::/.exec(urn) : undefined;
|
|
30
|
+
if (m)
|
|
31
|
+
return m[1];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// No readable export: the member has no stack to name.
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
export async function pulumiWorkspaceStackReads(ctx, opts = {}) {
|
|
40
|
+
const steps = ctx.members
|
|
41
|
+
.filter((m) => m.kind === "pulumi")
|
|
42
|
+
.map((m) => {
|
|
43
|
+
const dir = isAbsolute(m.dir) ? m.dir : resolve(ctx.root, m.dir);
|
|
44
|
+
const stack = ctx.env && existsSync(join(dir, `Pulumi.${ctx.env}.yaml`)) ? ctx.env : exportedStack(dir);
|
|
45
|
+
return stack === undefined ? undefined : { component: m.name, index: 0, step: { dir, stack } };
|
|
46
|
+
})
|
|
47
|
+
.filter((s) => s !== undefined);
|
|
48
|
+
if (steps.length === 0)
|
|
49
|
+
return undefined;
|
|
50
|
+
const reads = await pulumiStackReads({ root: ctx.root }, steps, opts);
|
|
51
|
+
return {
|
|
52
|
+
lexicon: "pulumi",
|
|
53
|
+
stacks: steps.map((s) => ({ member: s.component, id: PULUMI_STACK_TYPE, kind: PULUMI_STACK_TYPE, attrs: { stack: s.step.stack } })),
|
|
54
|
+
reads: reads.flatMap((r) => {
|
|
55
|
+
const where = "upstream" in r.target ? { upstream: r.target.upstream } : { external: r.target.external };
|
|
56
|
+
const outputs = [...r.outputs, ...r.secretOutputs].sort();
|
|
57
|
+
return outputs.length === 0 ? [{ reader: r.reader, ...where }] : outputs.map((output) => ({ reader: r.reader, ...where, output }));
|
|
58
|
+
}),
|
|
59
|
+
};
|
|
60
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/chant-lexicon-pulumi",
|
|
3
|
-
"version": "0.124.
|
|
3
|
+
"version": "0.124.103",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"bundle": "tsx src/package-cli.ts",
|
|
42
42
|
"docs": "npx tsx src/codegen/docs-cli.ts",
|
|
43
43
|
"build": "../../scripts/tsc7.sh -p tsconfig.build.json --sourceMap false && tsc-alias -p tsconfig.build.json && node ../../scripts/copy-lexicon-assets.mjs",
|
|
44
|
-
"prepack": "npm run generate && npm run bundle && npm run validate && npm run build"
|
|
44
|
+
"prepack": "npm run generate && npm run bundle && npm run validate && tsx ../../scripts/release-floors.ts --lexicon pulumi --pack npm run build"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@intentius/chant": "*",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"access": "public"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@intentius/chant": "^0.124.
|
|
56
|
+
"@intentius/chant": "^0.124.110",
|
|
57
57
|
"zod": "^4.3.6"
|
|
58
58
|
},
|
|
59
59
|
"description": "pulumi lexicon for chant: a Pulumi program as a workspace member, its preview in the change set and its refresh as drift records",
|