@intentius/chant 0.124.103 → 0.124.105
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/audit/secrets.d.ts +6 -0
- package/dist/audit/secrets.js +9 -2
- package/dist/capabilities/templates.d.ts +66 -3
- package/dist/capabilities/templates.js +220 -81
- package/dist/cli/commands/import-index.d.ts +15 -0
- package/dist/cli/commands/import-index.js +37 -3
- package/dist/cli/handlers/lifecycle.js +6 -0
- package/dist/cli/handlers/release-config.d.ts +15 -0
- package/dist/cli/handlers/release-config.js +58 -0
- package/dist/cli/handlers/release-doctor.js +8 -3
- package/dist/cli/handlers/release-init.js +7 -4
- package/dist/cli/handlers/release.js +36 -3
- package/dist/cli/handlers/search.d.ts +1 -1
- package/dist/cli/handlers/search.js +24 -2
- package/dist/cli/main.js +12 -2
- package/dist/cli/parse-args.js +9 -2
- package/dist/cli/registry.d.ts +2 -0
- package/dist/cli/release-commands/cut.js +3 -0
- package/dist/cli/release-commands/doctor.js +5 -2
- package/dist/cloud-lister/aws.d.ts +9 -0
- package/dist/cloud-lister/aws.js +20 -0
- package/dist/config-import.js +26 -4
- package/dist/config.d.ts +24 -0
- package/dist/config.js +6 -0
- package/dist/floor-table.data.js +8 -6
- package/dist/floor-table.js +3 -1
- package/dist/graph-refs.d.ts +22 -0
- package/dist/graph-refs.js +20 -11
- package/dist/lifecycle/cloud-index.d.ts +6 -0
- package/dist/lifecycle/cloud-index.js +32 -5
- package/dist/lifecycle/derive-edges.d.ts +1 -1
- package/dist/lifecycle/derive-edges.js +5 -3
- package/dist/lifecycle/identity-match.d.ts +18 -2
- package/dist/lifecycle/identity-match.js +10 -5
- package/dist/lifecycle/index-drift.d.ts +13 -0
- package/dist/lifecycle/index-drift.js +21 -3
- package/dist/lifecycle/index-import.d.ts +24 -2
- package/dist/lifecycle/index-import.js +61 -9
- package/dist/lifecycle/index-join.d.ts +1 -1
- package/dist/lifecycle/index-join.js +1 -1
- package/dist/lifecycle/publish-declaration.d.ts +6 -0
- package/dist/lifecycle/publish-declaration.js +18 -1
- package/dist/lifecycle/publish-forge.d.ts +2 -0
- package/dist/lifecycle/publish-forge.js +3 -1
- package/dist/lifecycle/publish-oci.d.ts +27 -0
- package/dist/lifecycle/publish-oci.js +63 -8
- package/dist/lifecycle/release-artifacts.js +3 -1
- package/dist/lifecycle/release-at.d.ts +5 -1
- package/dist/lifecycle/release-at.js +69 -4
- package/dist/lifecycle/release-changelog.d.ts +18 -5
- package/dist/lifecycle/release-changelog.js +22 -10
- package/dist/lifecycle/release-cut.d.ts +13 -1
- package/dist/lifecycle/release-cut.js +3 -0
- package/dist/lifecycle/release-doctor.d.ts +10 -0
- package/dist/lifecycle/release-doctor.js +84 -14
- package/dist/lifecycle/release-green.d.ts +5 -2
- package/dist/lifecycle/release-green.js +40 -8
- package/dist/lifecycle/release-images.d.ts +39 -3
- package/dist/lifecycle/release-images.js +84 -7
- package/dist/lifecycle/release-init-goreleaser-images.d.ts +21 -0
- package/dist/lifecycle/release-init-goreleaser-images.js +160 -0
- package/dist/lifecycle/release-init.d.ts +38 -7
- package/dist/lifecycle/release-init.js +298 -52
- package/dist/lifecycle/release-next.d.ts +1 -1
- package/dist/lifecycle/release-next.js +9 -4
- package/dist/local-chant.d.ts +3 -0
- package/dist/local-chant.js +28 -2
- package/dist/release-floors.d.ts +10 -6
- package/dist/release-floors.js +10 -6
- package/dist/ts-loader.d.ts +12 -3
- package/dist/ts-loader.js +27 -11
- package/dist/wave-runtime.mjs +292 -291
- package/dist/workspace/capabilities-contract.d.ts +15 -5
- package/dist/workspace/capabilities-contract.js +7 -4
- package/dist/workspace/capabilities.schema.json +45 -1
- package/dist/workspace/catalog-edges.d.ts +22 -0
- package/dist/workspace/catalog-edges.js +23 -0
- package/dist/workspace/release-changed.d.ts +2 -0
- package/dist/workspace/release-changed.js +7 -2
- package/dist/workspace/release-steps/doctor.js +2 -1
- package/dist/workspace/release-steps/goreleaser.d.ts +6 -3
- package/dist/workspace/release-steps/goreleaser.js +12 -6
- package/dist/workspace/release-toolchains.d.ts +6 -0
- package/dist/workspace/release-toolchains.js +8 -0
- package/dist/workspace/release-train-workflow.d.ts +18 -0
- package/dist/workspace/release-train-workflow.js +135 -7
- package/dist/workspace/release-train.js +1 -1
- package/dist/workspace/release-workflow.d.ts +26 -0
- package/dist/workspace/release-workflow.js +60 -12
- package/dist/workspace/train-artifacts.js +3 -4
- package/dist/workspace/train-cut.d.ts +22 -1
- package/dist/workspace/train-cut.js +80 -16
- package/package.json +2 -2
package/dist/floor-table.js
CHANGED
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
* rows are written by scripts/floor-table.ts from the constants themselves
|
|
13
13
|
* (./floor-table.data.ts), and scripts/release-floors.ts fails while a floor
|
|
14
14
|
* is missing from them. A floor added since the last release has the version
|
|
15
|
-
* of the next one, NEXT_RELEASE
|
|
15
|
+
* of the next one, NEXT_RELEASE; core's prepack writes each floor still on
|
|
16
|
+
* NEXT_RELEASE as the release that first carried it, read from the release
|
|
17
|
+
* tags, or as the version being packed (#5260). Each name is
|
|
16
18
|
* declared once (#4916), and scripts/floor-table.ts fails on a second.
|
|
17
19
|
*
|
|
18
20
|
* `chant dev dead-guards` (./dead-guards.ts) reads this table against a
|
package/dist/graph-refs.d.ts
CHANGED
|
@@ -179,6 +179,17 @@ export interface ReferenceCatalog {
|
|
|
179
179
|
refs: RefRule[];
|
|
180
180
|
/** Typed tag rules, used over indexed nodes only (#4522). */
|
|
181
181
|
tagRefs?: TagRefRule[];
|
|
182
|
+
/**
|
|
183
|
+
* How this lexicon's ids are unique in an index (#5286). `regionless`: an id
|
|
184
|
+
* is unique in the whole account, so a node with no location, or in any
|
|
185
|
+
* location, joins with every node of its account (an ARM id names its
|
|
186
|
+
* subscription). `caseInsensitive`: two ids that differ only in case are one
|
|
187
|
+
* (ARM compares ids that way). Over an index only.
|
|
188
|
+
*/
|
|
189
|
+
indexIds?: {
|
|
190
|
+
regionless?: boolean;
|
|
191
|
+
caseInsensitive?: boolean;
|
|
192
|
+
};
|
|
182
193
|
/** Kinds whose names are scoped by a value on the node, on a declared graph (#5097). */
|
|
183
194
|
scopes?: ScopeRule[];
|
|
184
195
|
/**
|
|
@@ -409,6 +420,8 @@ export interface IndexedNodeScope {
|
|
|
409
420
|
* holder scoped by namespace.
|
|
410
421
|
*/
|
|
411
422
|
member?: string;
|
|
423
|
+
/** Compare values case-insensitively in this scope (#5286). */
|
|
424
|
+
foldCase?: boolean;
|
|
412
425
|
}
|
|
413
426
|
/** The region of a node held by one member (a `ScopeRule` with no `path`). */
|
|
414
427
|
export declare const memberRegion: (member: string) => string;
|
|
@@ -457,6 +470,15 @@ export interface NodeIdentityValue {
|
|
|
457
470
|
/** `native-id`, or the cloud id's kind (`arn`, `provider-id`, ...). */
|
|
458
471
|
kind: string;
|
|
459
472
|
value: string;
|
|
473
|
+
/**
|
|
474
|
+
* The attribute paths this value names the node at (#5250): a holder's
|
|
475
|
+
* string at `path` joins only when `path` is one of these or ends in `.`
|
|
476
|
+
* plus one. For a name that is unique only among objects of one kind (a
|
|
477
|
+
* Kubernetes cluster-scoped name), where the same string at another field
|
|
478
|
+
* names something else. Absent: the value names the node wherever it
|
|
479
|
+
* appears.
|
|
480
|
+
*/
|
|
481
|
+
paths?: readonly string[];
|
|
460
482
|
}
|
|
461
483
|
/** The lexicon whose nodes can be identity-matched, and the values that name each one. */
|
|
462
484
|
export interface IdentityOwners {
|
package/dist/graph-refs.js
CHANGED
|
@@ -257,7 +257,7 @@ const byString = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
|
257
257
|
*/
|
|
258
258
|
export function reconstructIndexedEdges(nodes, catalogs, scopeOf) {
|
|
259
259
|
const sorted = [...nodes].sort((a, b) => byString(a.id, b.id));
|
|
260
|
-
const keyOf = (scope, value) => `${scope.account}\u0000${scope.region ?? ""}\u0000${value}`;
|
|
260
|
+
const keyOf = (scope, value) => `${scope.account}\u0000${scope.region ?? ""}\u0000${scope.foldCase ? value.toLowerCase() : value}`;
|
|
261
261
|
const index = new Map();
|
|
262
262
|
// The same nodes by the name of the scope they sit in (the text after the
|
|
263
263
|
// first `:` of a region), for a join that names a scope itself.
|
|
@@ -366,7 +366,8 @@ export function reconstructIndexedEdges(nodes, catalogs, scopeOf) {
|
|
|
366
366
|
if (node.lexicon !== lexicon)
|
|
367
367
|
continue;
|
|
368
368
|
for (const rule of catalog.refs) {
|
|
369
|
-
|
|
369
|
+
// `from: "*"` is a rule that reads every node of the lexicon (#5286); its `join` picks the nodes.
|
|
370
|
+
if (rule.from !== node.kind && !(rule.from === "*" && rule.join))
|
|
370
371
|
continue;
|
|
371
372
|
const spec = {
|
|
372
373
|
id: refRuleId(lexicon, rule.from, rule.path),
|
|
@@ -378,7 +379,13 @@ export function reconstructIndexedEdges(nodes, catalogs, scopeOf) {
|
|
|
378
379
|
...(rule.optional ? { optional: true } : {}),
|
|
379
380
|
};
|
|
380
381
|
if (rule.join) {
|
|
381
|
-
const find = (value, scope) =>
|
|
382
|
+
const find = (value, scope) => {
|
|
383
|
+
if (scope === undefined)
|
|
384
|
+
return [...lookup(node, value).keys()].map((id) => byId.get(id));
|
|
385
|
+
// Over an index a namespace is the whole region (a node's location), so the holder's account and that region name the scope too (#5284).
|
|
386
|
+
const ids = new Map([...(named.get(`${scope}\u0000${value}`) ?? []), ...(index.get(keyOf({ account: scopeOf(node).account, region: scope }, value)) ?? [])]);
|
|
387
|
+
return [...ids.keys()].map((id) => byId.get(id));
|
|
388
|
+
};
|
|
382
389
|
for (const j of rule.join(node, find))
|
|
383
390
|
resolve(node, j.value, { ...spec, via: j.via ?? spec.via }, j);
|
|
384
391
|
continue;
|
|
@@ -490,8 +497,8 @@ function stringLeaves(attrs) {
|
|
|
490
497
|
export function reconstructIdentityEdges(nodes, owners, scopeOf, existing = []) {
|
|
491
498
|
const sorted = [...nodes].sort((a, b) => byString(a.id, b.id));
|
|
492
499
|
const ownerBy = new Map(owners.map((o) => [o.lexicon, o]));
|
|
493
|
-
const keyOf = (scope, value) => `${scope.account}\u0000${scope.region ?? ""}\u0000${value}`;
|
|
494
|
-
// key -> node id -> the rule that names it
|
|
500
|
+
const keyOf = (scope, value) => `${scope.account}\u0000${scope.region ?? ""}\u0000${scope.foldCase ? value.toLowerCase() : value}`;
|
|
501
|
+
// key -> node id -> the rule that names it, and the paths it names the node at
|
|
495
502
|
const index = new Map();
|
|
496
503
|
const own = new Map();
|
|
497
504
|
for (const node of sorted) {
|
|
@@ -501,15 +508,15 @@ export function reconstructIdentityEdges(nodes, owners, scopeOf, existing = [])
|
|
|
501
508
|
const scope = scopeOf(node);
|
|
502
509
|
const values = (owner.identities ?? defaultNodeIdentities)(node);
|
|
503
510
|
own.set(node.id, new Set(values.map((v) => v.value)));
|
|
504
|
-
for (const { kind, value } of values) {
|
|
511
|
+
for (const { kind, value, paths } of values) {
|
|
505
512
|
if (!identityCandidateValue(value))
|
|
506
513
|
continue;
|
|
507
514
|
const k = keyOf(scope, value);
|
|
508
515
|
const m = index.get(k) ?? index.set(k, new Map()).get(k);
|
|
509
516
|
const rule = identityMatchRuleId(owner.lexicon, node.kind, kind);
|
|
510
517
|
const prev = m.get(node.id);
|
|
511
|
-
if (prev === undefined || byString(rule, prev) < 0)
|
|
512
|
-
m.set(node.id, rule);
|
|
518
|
+
if (prev === undefined || byString(rule, prev.rule) < 0)
|
|
519
|
+
m.set(node.id, { rule, paths });
|
|
513
520
|
}
|
|
514
521
|
}
|
|
515
522
|
const joined = new Set(existing.map((e) => `${e.from}|${e.to}`));
|
|
@@ -523,10 +530,12 @@ export function reconstructIdentityEdges(nodes, owners, scopeOf, existing = [])
|
|
|
523
530
|
if (!identityCandidateValue(value) || mine.has(value))
|
|
524
531
|
continue;
|
|
525
532
|
const found = new Map();
|
|
526
|
-
for (const k of keys(value))
|
|
527
|
-
for (const [id, rule] of index.get(k) ?? [])
|
|
528
|
-
if (id !== holder.id)
|
|
533
|
+
for (const k of keys(value)) {
|
|
534
|
+
for (const [id, { rule, paths }] of index.get(k) ?? []) {
|
|
535
|
+
if (id !== holder.id && (paths === undefined || paths.some((p) => path === p || path.endsWith(`.${p}`))))
|
|
529
536
|
found.set(id, rule);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
530
539
|
if (found.size === 0)
|
|
531
540
|
continue;
|
|
532
541
|
if (found.size > 1) {
|
|
@@ -145,6 +145,12 @@ export interface IndexSummary {
|
|
|
145
145
|
notObserved: number;
|
|
146
146
|
};
|
|
147
147
|
notes: string[];
|
|
148
|
+
/** The same notes with their kind and, where there is one, the command to run yourself. */
|
|
149
|
+
noteDetails: Array<{
|
|
150
|
+
kind?: string;
|
|
151
|
+
message: string;
|
|
152
|
+
command?: string;
|
|
153
|
+
}>;
|
|
148
154
|
}
|
|
149
155
|
export interface RunCloudIndexOptions extends IndexCloudDeps {
|
|
150
156
|
/** The command name in messages: `chant index` (default) or `behold index`. */
|
|
@@ -477,6 +477,31 @@ export async function substrateLexicons(substrate) {
|
|
|
477
477
|
}
|
|
478
478
|
return { lexicons: [plugin] };
|
|
479
479
|
}
|
|
480
|
+
/** A kind that repeats more than this many times prints as one line with a count. */
|
|
481
|
+
const NOTE_REPEAT_LIMIT = 3;
|
|
482
|
+
/** The note lines the CLI prints: a command goes under its note, a long run of one kind collapses to a count. */
|
|
483
|
+
function noteLines(details) {
|
|
484
|
+
const byKind = new Map();
|
|
485
|
+
for (const n of details)
|
|
486
|
+
if (n.kind)
|
|
487
|
+
byKind.set(n.kind, (byKind.get(n.kind) ?? 0) + 1);
|
|
488
|
+
const lines = [];
|
|
489
|
+
const seen = new Set();
|
|
490
|
+
for (const n of details) {
|
|
491
|
+
const count = n.kind ? (byKind.get(n.kind) ?? 0) : 0;
|
|
492
|
+
if (n.kind && count > NOTE_REPEAT_LIMIT) {
|
|
493
|
+
if (seen.has(n.kind))
|
|
494
|
+
continue;
|
|
495
|
+
seen.add(n.kind);
|
|
496
|
+
lines.push(` note: ${count} ${n.kind} notes, for example: ${n.message}\n (all ${count} are in the stored version and in --json)\n`);
|
|
497
|
+
continue;
|
|
498
|
+
}
|
|
499
|
+
lines.push(` note: ${n.message}\n`);
|
|
500
|
+
if (n.command)
|
|
501
|
+
lines.push(` run: ${n.command}\n`);
|
|
502
|
+
}
|
|
503
|
+
return lines;
|
|
504
|
+
}
|
|
480
505
|
function summarize(doc) {
|
|
481
506
|
const nodes = doc.graph.nodes;
|
|
482
507
|
const unmapped = nodes.filter((n) => n.unmappedKind === true).length;
|
|
@@ -571,11 +596,12 @@ export async function runCloudIndex(argv, opts = {}) {
|
|
|
571
596
|
return 1;
|
|
572
597
|
}
|
|
573
598
|
const { doc, write } = result;
|
|
574
|
-
const
|
|
599
|
+
const noteDetails = [];
|
|
575
600
|
if (lex.note)
|
|
576
|
-
|
|
601
|
+
noteDetails.push({ message: lex.note });
|
|
577
602
|
for (const n of doc.notes ?? [])
|
|
578
|
-
|
|
603
|
+
noteDetails.push({ kind: n.kind, message: n.message, ...(n.command ? { command: n.command } : {}) });
|
|
604
|
+
const notes = noteDetails.map((n) => n.message);
|
|
579
605
|
const version = write.path ? basename(write.path) : undefined;
|
|
580
606
|
const summary = {
|
|
581
607
|
substrate: args.substrate,
|
|
@@ -590,6 +616,7 @@ export async function runCloudIndex(argv, opts = {}) {
|
|
|
590
616
|
...(write.reason ? { reason: write.reason } : {}),
|
|
591
617
|
...summarize(doc),
|
|
592
618
|
notes,
|
|
619
|
+
noteDetails,
|
|
593
620
|
};
|
|
594
621
|
if (args.json) {
|
|
595
622
|
out(`${JSON.stringify(summary, null, 2)}\n`);
|
|
@@ -597,8 +624,8 @@ export async function runCloudIndex(argv, opts = {}) {
|
|
|
597
624
|
else {
|
|
598
625
|
out(`${args.substrate} ${scope.scopeId}: ${summary.nodes} nodes (${summary.typed} typed, ${summary.unmapped} of unknown kind), ${summary.derivedEdges} derived edges\n`);
|
|
599
626
|
out(`coverage: ${summary.coverage.listed} (type, location) listed, ${summary.coverage.notObserved} not observed\n`);
|
|
600
|
-
for (const
|
|
601
|
-
out(
|
|
627
|
+
for (const line of noteLines(noteDetails))
|
|
628
|
+
out(line);
|
|
602
629
|
if (write.written)
|
|
603
630
|
out(`${command}: wrote ${version} under ${summary.scopeKey} in ${store.where}\n`);
|
|
604
631
|
else
|
|
@@ -44,7 +44,7 @@ export interface EdgeLexicon {
|
|
|
44
44
|
indexIdentity?: IndexIdentity;
|
|
45
45
|
}
|
|
46
46
|
/** The scope an indexed node's identifiers are unique in, from its document's stamp and its own location. */
|
|
47
|
-
export declare function indexedNodeScope(doc: IndexDocument, node: IRNode): IndexedNodeScope;
|
|
47
|
+
export declare function indexedNodeScope(doc: IndexDocument, node: IRNode, ids?: ReferenceCatalog["indexIds"]): IndexedNodeScope;
|
|
48
48
|
/** Derived edges over one index document. */
|
|
49
49
|
export declare function deriveEdges(doc: IndexDocument, lexicons: readonly EdgeLexicon[]): IndexDocument;
|
|
50
50
|
/**
|
|
@@ -3,11 +3,12 @@ import { indexDocumentDigest } from "./index-document.js";
|
|
|
3
3
|
/** Locations that hold global types: AWS's `global`, Kubernetes' cluster-scoped objects. */
|
|
4
4
|
const GLOBAL_LOCATIONS = new Set(["global", "cluster", ""]);
|
|
5
5
|
/** The scope an indexed node's identifiers are unique in, from its document's stamp and its own location. */
|
|
6
|
-
export function indexedNodeScope(doc, node) {
|
|
6
|
+
export function indexedNodeScope(doc, node, ids) {
|
|
7
7
|
const scope = doc.stamp.scope;
|
|
8
8
|
const account = scope.kind === "cloud" ? `${scope.substrate}/${scope.scopeId}` : doc.stamp.scopeKey;
|
|
9
9
|
const location = node.location ?? "";
|
|
10
|
-
|
|
10
|
+
const fold = ids?.caseInsensitive ? { foldCase: true } : {};
|
|
11
|
+
return GLOBAL_LOCATIONS.has(location) || ids?.regionless ? { account, ...fold } : { account, region: location, ...fold };
|
|
11
12
|
}
|
|
12
13
|
const byString = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
13
14
|
function noteKey(n) {
|
|
@@ -46,13 +47,14 @@ export function deriveEdgesAcross(docs, lexicons) {
|
|
|
46
47
|
.sort((a, b) => byString(a.name, b.name))
|
|
47
48
|
.map((l) => ({ lexicon: l.name, catalog: l.referenceCatalog }));
|
|
48
49
|
const withCatalog = new Set(named.map((c) => c.lexicon));
|
|
50
|
+
const idsOf = new Map(named.map((c) => [c.lexicon, c.catalog.indexIds]));
|
|
49
51
|
const holderDoc = new Map();
|
|
50
52
|
const scopes = new Map();
|
|
51
53
|
const all = [];
|
|
52
54
|
docs.forEach((d, i) => {
|
|
53
55
|
for (const n of d.graph.nodes) {
|
|
54
56
|
holderDoc.set(n.id, i);
|
|
55
|
-
scopes.set(n.id, indexedNodeScope(d, n));
|
|
57
|
+
scopes.set(n.id, indexedNodeScope(d, n, idsOf.get(n.lexicon)));
|
|
56
58
|
all.push(n);
|
|
57
59
|
}
|
|
58
60
|
});
|
|
@@ -39,14 +39,21 @@ export type DeclaredIdentity = {
|
|
|
39
39
|
kind: "identifier";
|
|
40
40
|
/** The inventory API's type name the identifier belongs to (the CloudFormation type for aws). */
|
|
41
41
|
listedType: string;
|
|
42
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* The identifier as the index's `nativeId` spells it (Cloud Control's,
|
|
44
|
+
* `|`-joined for a multi-part one), or as the lexicon's
|
|
45
|
+
* {@link IndexIdentity.nodeKey} spells a node's key.
|
|
46
|
+
*/
|
|
43
47
|
identifier: string;
|
|
44
48
|
/** A global type is indexed once per account at location `global`. */
|
|
45
49
|
global: boolean;
|
|
46
50
|
/**
|
|
47
51
|
* The location the declaration itself names, ahead of the entity's
|
|
48
52
|
* region: a Kubernetes namespace, or `cluster` for a cluster-scoped
|
|
49
|
-
* kind.
|
|
53
|
+
* kind. `"*"` matches the identifier at every location, for a
|
|
54
|
+
* declaration whose location is not a literal (an Azure resource that
|
|
55
|
+
* takes its resource group's), and absence is then read from the
|
|
56
|
+
* coverage at `*`. Absent: `global` or the region.
|
|
50
57
|
*/
|
|
51
58
|
location?: string;
|
|
52
59
|
/**
|
|
@@ -78,6 +85,13 @@ export interface IndexIdentity {
|
|
|
78
85
|
* Absent: its native id and its ARN cloud ids.
|
|
79
86
|
*/
|
|
80
87
|
nodeIdentities?(node: IRNode): NodeIdentityValue[];
|
|
88
|
+
/**
|
|
89
|
+
* The value a declared identifier is compared with, for a substrate whose
|
|
90
|
+
* native id holds parts no declaration spells: the resource group in an
|
|
91
|
+
* Azure id, the project and location in a GCP asset name. Undefined leaves
|
|
92
|
+
* the node out of the match. Absent: its native id.
|
|
93
|
+
*/
|
|
94
|
+
nodeKey?(node: IRNode): string | undefined;
|
|
81
95
|
}
|
|
82
96
|
/** One declared entity, as the build output names it. */
|
|
83
97
|
export interface DeclaredEntity {
|
|
@@ -126,6 +140,8 @@ export interface MatchOptions {
|
|
|
126
140
|
/** The region of an entity that names none. */
|
|
127
141
|
region?: string;
|
|
128
142
|
}
|
|
143
|
+
/** A declared location that matches every indexed location ({@link DeclaredIdentity}). */
|
|
144
|
+
export declare const ANY_LOCATION = "*";
|
|
129
145
|
/**
|
|
130
146
|
* Whether the index looked at (type, location), from its coverage. `listed`
|
|
131
147
|
* means a missing node is absent; anything else is a reason it is not
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { indexCoverageFor } from "./index-document.js";
|
|
2
2
|
const byString = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
|
3
|
+
/** A declared location that matches every indexed location ({@link DeclaredIdentity}). */
|
|
4
|
+
export const ANY_LOCATION = "*";
|
|
3
5
|
/** The documents must be cloud reads of one substrate, one account and one read, or a candidate from another read would bind. */
|
|
4
6
|
function cloudScopes(docs, substrate) {
|
|
5
7
|
const scopes = [];
|
|
@@ -80,17 +82,20 @@ export function matchDeclaredToIndex(entities, docs, identity, options = {}) {
|
|
|
80
82
|
// listedType -> nativeId -> nodes, and the same keyed by lexicon kind
|
|
81
83
|
const byIdentity = new Map();
|
|
82
84
|
const byKind = new Map();
|
|
83
|
-
const add = (index, t, n) => {
|
|
85
|
+
const add = (index, t, key, n) => {
|
|
84
86
|
const m = index.get(t) ?? index.set(t, new Map()).get(t);
|
|
85
|
-
(m.get(
|
|
87
|
+
(m.get(key) ?? m.set(key, []).get(key)).push(n);
|
|
86
88
|
};
|
|
87
89
|
for (const d of docs) {
|
|
88
90
|
for (const n of d.graph.nodes) {
|
|
89
91
|
if (n.nativeId === undefined)
|
|
90
92
|
continue;
|
|
91
|
-
|
|
93
|
+
const key = identity.nodeKey ? identity.nodeKey(n) : n.nativeId;
|
|
94
|
+
if (key === undefined)
|
|
95
|
+
continue;
|
|
96
|
+
add(byIdentity, listedTypeOf(n), key, n);
|
|
92
97
|
if (!n.unmappedKind)
|
|
93
|
-
add(byKind, n.kind, n);
|
|
98
|
+
add(byKind, n.kind, key, n);
|
|
94
99
|
}
|
|
95
100
|
}
|
|
96
101
|
const matches = {};
|
|
@@ -105,7 +110,7 @@ export function matchDeclaredToIndex(entities, docs, identity, options = {}) {
|
|
|
105
110
|
const region = entity.region ?? options.region;
|
|
106
111
|
const location = declared.location ?? (declared.global ? "global" : region);
|
|
107
112
|
const all = (declared.entityKind !== undefined ? byKind.get(declared.entityKind) : byIdentity.get(listedType))?.get(identifier) ?? [];
|
|
108
|
-
const inScope = location === undefined ? all : all.filter((n) => n.location === location);
|
|
113
|
+
const inScope = location === undefined || location === ANY_LOCATION ? all : all.filter((n) => n.location === location);
|
|
109
114
|
const candidates = [...new Set(inScope.map((n) => n.id))].sort(byString);
|
|
110
115
|
if (candidates.length > 1) {
|
|
111
116
|
matches[entity.name] = {
|
|
@@ -15,6 +15,13 @@
|
|
|
15
15
|
* and the observation baseline (`.chant/observation-baseline/<env>.json`,
|
|
16
16
|
* #4519) subtracted, value-bound. An accepted deviation stays quiet until
|
|
17
17
|
* the indexed value moves again.
|
|
18
|
+
*
|
|
19
|
+
* The index carries what the provider's listing returned, which is often
|
|
20
|
+
* a few properties per type (Cloud Control's `ListResources` gives a role
|
|
21
|
+
* its name and path, not its trust policy). A declared top-level property
|
|
22
|
+
* the indexed node does not carry was never observed, so it is left out
|
|
23
|
+
* of the comparison and reported as not observed, never as drift to
|
|
24
|
+
* `<absent>`. The record says so in `attributesUnobserved`.
|
|
18
25
|
* 3. Every row becomes one drift record (`drift: "v1"`, ../drift-record.ts).
|
|
19
26
|
*
|
|
20
27
|
* A row that is not bound is reported with its join verdict and never
|
|
@@ -83,6 +90,12 @@ export interface IndexDriftLexiconResult {
|
|
|
83
90
|
joins: Record<string, IndexJoin>;
|
|
84
91
|
/** The deep diff over the bound rows only. Unbound rows are never in it. */
|
|
85
92
|
deep: DeepDiffResult;
|
|
93
|
+
/**
|
|
94
|
+
* Per bound row, the declared top-level properties its indexed node does
|
|
95
|
+
* not carry, sorted. They were left out of {@link deep}: the index never
|
|
96
|
+
* observed them. Rows with none are not listed.
|
|
97
|
+
*/
|
|
98
|
+
unobservedProperties: Record<string, string[]>;
|
|
86
99
|
}
|
|
87
100
|
export interface IndexDriftCounts {
|
|
88
101
|
/** Declared entities compared. */
|
|
@@ -86,6 +86,7 @@ export function diffDeclaredAgainstIndex(input) {
|
|
|
86
86
|
// The bound rows are the observed side, each its indexed node's tree.
|
|
87
87
|
const bound = new Map();
|
|
88
88
|
const resources = {};
|
|
89
|
+
const unobservedProperties = {};
|
|
89
90
|
for (const [name, entity] of entities) {
|
|
90
91
|
const j = joins[name];
|
|
91
92
|
if (j?.verdict !== "bound")
|
|
@@ -93,11 +94,24 @@ export function diffDeclaredAgainstIndex(input) {
|
|
|
93
94
|
const hit = indexed.get(j.node);
|
|
94
95
|
if (!hit)
|
|
95
96
|
continue;
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
const attrs = (hit.attrs ?? {});
|
|
98
|
+
// Only what the index observed is compared: a declared property the
|
|
99
|
+
// listing never returned is unknown, not removed.
|
|
100
|
+
const props = {};
|
|
101
|
+
const missing = [];
|
|
102
|
+
for (const [key, value] of Object.entries(entity.props ?? {})) {
|
|
103
|
+
if (Object.prototype.hasOwnProperty.call(attrs, key))
|
|
104
|
+
props[key] = value;
|
|
105
|
+
else
|
|
106
|
+
missing.push(key);
|
|
107
|
+
}
|
|
108
|
+
if (missing.length > 0)
|
|
109
|
+
unobservedProperties[name] = missing.sort();
|
|
110
|
+
bound.set(name, { ...entity, props });
|
|
111
|
+
resources[name] = { type: entity.entityType, physicalId: hit.physicalId ?? j.nativeId, properties: attrs };
|
|
98
112
|
}
|
|
99
113
|
const deep = diffDeepObservation(bound, { resources, unobserved: {} }, plugin.deepNormalizationHooks, baselineForLexicon(input.baseline, lexicon));
|
|
100
|
-
byLexicon[lexicon] = { joins, deep };
|
|
114
|
+
byLexicon[lexicon] = { joins, deep, unobservedProperties };
|
|
101
115
|
// Bound rows: the deep diff's records, and in-sync for a row whose every
|
|
102
116
|
// difference is accepted (the deep diff lists it under neither).
|
|
103
117
|
const deepRecords = new Map(deepDiffDriftRecords({ ...adapter, diff: deep, command }).map((r) => [r.address, r]));
|
|
@@ -109,6 +123,7 @@ export function diffDeclaredAgainstIndex(input) {
|
|
|
109
123
|
if (j?.verdict === "bound" && bound.has(name)) {
|
|
110
124
|
counts.bound++;
|
|
111
125
|
const r = deepRecords.get(name);
|
|
126
|
+
const missing = unobservedProperties[name];
|
|
112
127
|
records.push(driftRecord({
|
|
113
128
|
...(r ?? {
|
|
114
129
|
member: input.member,
|
|
@@ -122,6 +137,9 @@ export function diffDeclaredAgainstIndex(input) {
|
|
|
122
137
|
address: address(name),
|
|
123
138
|
...at,
|
|
124
139
|
resourceType: entity.entityType,
|
|
140
|
+
...(missing
|
|
141
|
+
? { attributesUnobserved: { reason: "not-reached", detail: `the index does not carry ${missing.join(", ")}; compared only the properties it holds` } }
|
|
142
|
+
: {}),
|
|
125
143
|
}));
|
|
126
144
|
continue;
|
|
127
145
|
}
|
|
@@ -34,12 +34,21 @@ export interface IndexImportCodegen {
|
|
|
34
34
|
* `DeletionPolicy: Retain` on every imported resource, #4536). `notes`
|
|
35
35
|
* go into the file's header comment after the logical id (the k8s
|
|
36
36
|
* lexicon names the keys of a Secret it writes as a referenced secret).
|
|
37
|
+
* `missing` names the properties the type requires that the node's
|
|
38
|
+
* attrs do not hold, as dotted paths (`properties.tenantId`); each
|
|
39
|
+
* becomes a parameter from {@link requiredParameter}. `partition` splits
|
|
40
|
+
* the resources of one lexicon and location into groups that deploy
|
|
41
|
+
* apart (the azure lexicon writes a resource group's resources apart from
|
|
42
|
+
* the subscription-scope resource groups themselves); it is a directory
|
|
43
|
+
* name under the location.
|
|
37
44
|
*/
|
|
38
45
|
resource(node: IRNode): {
|
|
39
46
|
type: string;
|
|
40
47
|
properties: Record<string, unknown>;
|
|
41
48
|
attributes?: Record<string, unknown>;
|
|
42
49
|
notes?: readonly string[];
|
|
50
|
+
missing?: readonly string[];
|
|
51
|
+
partition?: string;
|
|
43
52
|
} | {
|
|
44
53
|
unsupported: string;
|
|
45
54
|
};
|
|
@@ -55,6 +64,15 @@ export interface IndexImportCodegen {
|
|
|
55
64
|
logicalId: string;
|
|
56
65
|
path: string;
|
|
57
66
|
}): ParameterIR;
|
|
67
|
+
/**
|
|
68
|
+
* The parameter that stands in for a required property the listing did
|
|
69
|
+
* not hold. Absent: such a property is named in the header only.
|
|
70
|
+
*/
|
|
71
|
+
requiredParameter?(name: string, context: {
|
|
72
|
+
node: IRNode;
|
|
73
|
+
logicalId: string;
|
|
74
|
+
path: string;
|
|
75
|
+
}): ParameterIR;
|
|
58
76
|
/** A reference to that parameter, as a property value in this lexicon's IR. */
|
|
59
77
|
parameterReference(name: string): unknown;
|
|
60
78
|
/** The type's short name for logical ids (`Bucket` for `AWS::S3::Bucket`). Absent: the kind's last segment. */
|
|
@@ -107,6 +125,8 @@ export interface IndexImportParameterReport {
|
|
|
107
125
|
node: string;
|
|
108
126
|
path: string;
|
|
109
127
|
group: string;
|
|
128
|
+
/** Why the value is a parameter: `masked` in the index, or a required property the listing did not hold. */
|
|
129
|
+
cause: "masked" | "missing";
|
|
110
130
|
}
|
|
111
131
|
/** The import report (`chant-index-import.json`), deterministic for one index and selection. */
|
|
112
132
|
export interface IndexImportReport {
|
|
@@ -124,15 +144,17 @@ export interface IndexImportReport {
|
|
|
124
144
|
group: string;
|
|
125
145
|
lexicon: string;
|
|
126
146
|
location: string;
|
|
147
|
+
partition?: string;
|
|
127
148
|
resources: number;
|
|
128
149
|
}>;
|
|
129
150
|
}
|
|
130
|
-
/** One output group: a lexicon and a location, written to `dir` under the output. */
|
|
151
|
+
/** One output group: a lexicon and a location (and a partition, when the lexicon names one), written to `dir` under the output. */
|
|
131
152
|
export interface IndexImportGroup {
|
|
132
|
-
/** `""` when the import has one group, else `<lexicon>/<location>`. */
|
|
153
|
+
/** `""` when the import has one group, else `<lexicon>/<location>` or `<lexicon>/<location>/<partition>`. */
|
|
133
154
|
dir: string;
|
|
134
155
|
lexicon: string;
|
|
135
156
|
location: string;
|
|
157
|
+
partition?: string;
|
|
136
158
|
ir: TemplateIR;
|
|
137
159
|
/** Comment lines (without `// `) to put at the top of the group's first file. */
|
|
138
160
|
header: string[];
|
|
@@ -23,6 +23,10 @@
|
|
|
23
23
|
* comment in the file names the edge and why;
|
|
24
24
|
* - a value the listing masked (`[REDACTED]`) is never written. Each one
|
|
25
25
|
* becomes a parameter to fill in;
|
|
26
|
+
* - a property the lexicon requires that the listing does not hold (a
|
|
27
|
+
* listing returns part of a resource's model) becomes a parameter to fill
|
|
28
|
+
* in too, with a header line saying so, rather than source that leaves it
|
|
29
|
+
* out;
|
|
26
30
|
* - output is deterministic: nodes, edges, parameters and logical ids are
|
|
27
31
|
* ordered by id, so the same index and selection give the same IR, and the
|
|
28
32
|
* same files.
|
|
@@ -250,6 +254,15 @@ function setExact(tree, parts, value) {
|
|
|
250
254
|
const obj = tree;
|
|
251
255
|
return { ...obj, [head]: setExact(obj[head], rest, value) };
|
|
252
256
|
}
|
|
257
|
+
/** `tree` with `value` at the object path `parts`, making each missing object on the way. */
|
|
258
|
+
function setCreating(tree, parts, value) {
|
|
259
|
+
const [head, ...rest] = parts;
|
|
260
|
+
if (rest.length === 0)
|
|
261
|
+
return { ...tree, [head]: value };
|
|
262
|
+
const child = tree[head];
|
|
263
|
+
const obj = child !== null && typeof child === "object" && !Array.isArray(child) ? child : {};
|
|
264
|
+
return { ...tree, [head]: setCreating(obj, rest, value) };
|
|
265
|
+
}
|
|
253
266
|
function getExact(tree, parts) {
|
|
254
267
|
let cur = tree;
|
|
255
268
|
for (const p of parts) {
|
|
@@ -357,6 +370,8 @@ export function planIndexImport(docs, selection, lexicons, options = {}) {
|
|
|
357
370
|
properties: r.properties,
|
|
358
371
|
...(r.attributes ? { attributes: r.attributes } : {}),
|
|
359
372
|
...(r.notes && r.notes.length > 0 ? { notes: r.notes } : {}),
|
|
373
|
+
...(r.missing && r.missing.length > 0 ? { missing: [...new Set(r.missing)].sort(byString) } : {}),
|
|
374
|
+
...(r.partition ? { partition: r.partition } : {}),
|
|
360
375
|
});
|
|
361
376
|
}
|
|
362
377
|
// Groups: lexicon + location. Global nodes join their lexicon's only regional group, when there is one.
|
|
@@ -373,12 +388,17 @@ export function planIndexImport(docs, selection, lexicons, options = {}) {
|
|
|
373
388
|
const regions = regional.get(n.lexicon);
|
|
374
389
|
return regions && regions.size === 1 ? [...regions][0] : loc === "" ? "global" : loc;
|
|
375
390
|
};
|
|
376
|
-
const
|
|
391
|
+
const partitionOf = new Map(writable.map((w) => [w.node.id, w.partition]));
|
|
392
|
+
const groupKey = (n) => {
|
|
393
|
+
const partition = partitionOf.get(n.id);
|
|
394
|
+
return `${n.lexicon}/${groupLocation(n)}${partition ? `/${partition}` : ""}`;
|
|
395
|
+
};
|
|
396
|
+
const groupKeys = [...new Set(writable.map((w) => groupKey(w.node)))].sort(byString);
|
|
377
397
|
const single = groupKeys.length === 1;
|
|
378
|
-
const groupDir = (n) => (single ? "" :
|
|
398
|
+
const groupDir = (n) => (single ? "" : groupKey(n));
|
|
379
399
|
const logicalIds = new Map();
|
|
380
400
|
for (const key of groupKeys) {
|
|
381
|
-
const members = writable.filter((w) =>
|
|
401
|
+
const members = writable.filter((w) => groupKey(w.node) === key);
|
|
382
402
|
const codegen = members[0].codegen;
|
|
383
403
|
const label = (n) => codegen.typeLabel?.(n) ?? defaultTypeLabel(n);
|
|
384
404
|
for (const [id, name] of assignLogicalIds(members.map((m) => m.node), label))
|
|
@@ -387,7 +407,7 @@ export function planIndexImport(docs, selection, lexicons, options = {}) {
|
|
|
387
407
|
const groups = [];
|
|
388
408
|
const parameterReports = [];
|
|
389
409
|
for (const key of groupKeys) {
|
|
390
|
-
const members = writable.filter((w) =>
|
|
410
|
+
const members = writable.filter((w) => groupKey(w.node) === key);
|
|
391
411
|
const dir = groupDir(members[0].node);
|
|
392
412
|
const header = [];
|
|
393
413
|
const resources = [];
|
|
@@ -465,25 +485,51 @@ export function planIndexImport(docs, selection, lexicons, options = {}) {
|
|
|
465
485
|
references.push({ path: at, target: e.to, ...(e.rule ? { rule: e.rule } : {}), written: "reference" });
|
|
466
486
|
}
|
|
467
487
|
const params = [];
|
|
468
|
-
|
|
488
|
+
const parameterName = (at) => {
|
|
469
489
|
let name = `${logicalId}${pascalWords(at)}`;
|
|
470
490
|
for (let i = 2; usedParams.has(name); i++)
|
|
471
491
|
name = `${logicalId}${pascalWords(at)}${i}`;
|
|
472
492
|
usedParams.add(name);
|
|
493
|
+
return name;
|
|
494
|
+
};
|
|
495
|
+
for (const { at, parts } of maskedPaths(props)) {
|
|
496
|
+
const name = parameterName(at);
|
|
473
497
|
parameters.push(w.codegen.secretParameter(name, { node: w.node, logicalId, path: at }));
|
|
474
498
|
props = setExact(props, parts, w.codegen.parameterReference(name));
|
|
475
499
|
params.push(name);
|
|
476
|
-
parameterReports.push({ name, node: w.node.id, path: at, group: dir });
|
|
500
|
+
parameterReports.push({ name, node: w.node.id, path: at, group: dir, cause: "masked" });
|
|
477
501
|
header.push(`${logicalId}.${at} was masked in the index; fill in the parameter ${name}`);
|
|
478
502
|
}
|
|
503
|
+
for (const at of w.missing ?? []) {
|
|
504
|
+
const parts = at.split(".");
|
|
505
|
+
if (getExact(props, parts) !== undefined)
|
|
506
|
+
continue;
|
|
507
|
+
if (!w.codegen.requiredParameter) {
|
|
508
|
+
header.push(`${logicalId}.${at} is required and the index listing did not hold it; add it before building`);
|
|
509
|
+
continue;
|
|
510
|
+
}
|
|
511
|
+
const name = parameterName(at);
|
|
512
|
+
parameters.push(w.codegen.requiredParameter(name, { node: w.node, logicalId, path: at }));
|
|
513
|
+
props = setCreating(props, parts, w.codegen.parameterReference(name));
|
|
514
|
+
params.push(name);
|
|
515
|
+
parameterReports.push({ name, node: w.node.id, path: at, group: dir, cause: "missing" });
|
|
516
|
+
header.push(`${logicalId}.${at} is required and the index listing did not hold it; fill in the parameter ${name}`);
|
|
517
|
+
}
|
|
479
518
|
if (references.length > 0)
|
|
480
519
|
report.references = references;
|
|
481
520
|
if (params.length > 0)
|
|
482
521
|
report.parameters = params;
|
|
483
522
|
resources.push({ logicalId, type: w.type, properties: props, ...(w.attributes && Object.keys(w.attributes).length > 0 ? { attributes: w.attributes } : {}) });
|
|
484
523
|
}
|
|
485
|
-
const
|
|
486
|
-
groups.push({
|
|
524
|
+
const first = members[0];
|
|
525
|
+
groups.push({
|
|
526
|
+
dir,
|
|
527
|
+
lexicon: first.node.lexicon,
|
|
528
|
+
location: groupLocation(first.node),
|
|
529
|
+
...(first.partition ? { partition: first.partition } : {}),
|
|
530
|
+
ir: { resources, parameters },
|
|
531
|
+
header,
|
|
532
|
+
});
|
|
487
533
|
}
|
|
488
534
|
const report = {
|
|
489
535
|
report: "chant-index-import/v1",
|
|
@@ -493,7 +539,13 @@ export function planIndexImport(docs, selection, lexicons, options = {}) {
|
|
|
493
539
|
selection: sel,
|
|
494
540
|
resources: [...reports.values()].sort((a, b) => byString(a.node, b.node)),
|
|
495
541
|
parameters: parameterReports,
|
|
496
|
-
groups: groups.map((g) => ({
|
|
542
|
+
groups: groups.map((g) => ({
|
|
543
|
+
group: g.dir,
|
|
544
|
+
lexicon: g.lexicon,
|
|
545
|
+
location: g.location,
|
|
546
|
+
...(g.partition ? { partition: g.partition } : {}),
|
|
547
|
+
resources: g.ir.resources.length,
|
|
548
|
+
})),
|
|
497
549
|
};
|
|
498
550
|
return { groups, report };
|
|
499
551
|
}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* `--live` lays a live read over it (`sourceOverlayGraphs`).
|
|
15
15
|
*
|
|
16
16
|
* The join goes through each lexicon's own index match, its plugin's
|
|
17
|
-
* `indexIdentity` (#4523, ./identity-match.ts). aws
|
|
17
|
+
* `indexIdentity` (#4523, ./identity-match.ts). aws, k8s, gcp and azure have one; a lexicon with
|
|
18
18
|
* none gets `not-observed`, reason `unsupported-kind`, on every row, never a
|
|
19
19
|
* guessed match. The verdicts:
|
|
20
20
|
*
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* `--live` lays a live read over it (`sourceOverlayGraphs`).
|
|
15
15
|
*
|
|
16
16
|
* The join goes through each lexicon's own index match, its plugin's
|
|
17
|
-
* `indexIdentity` (#4523, ./identity-match.ts). aws
|
|
17
|
+
* `indexIdentity` (#4523, ./identity-match.ts). aws, k8s, gcp and azure have one; a lexicon with
|
|
18
18
|
* none gets `not-observed`, reason `unsupported-kind`, on every row, never a
|
|
19
19
|
* guessed match. The verdicts:
|
|
20
20
|
*
|