cdk-real-drift 0.30.0 → 0.31.0
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/README.md +11 -1
- package/dist/cli.js +58 -22
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -515,7 +515,7 @@ treated as non-interactive: the report is written cleanly with no prompt (which
|
|
|
515
515
|
would otherwise deadlock, waiting on stdin for a prompt written into the file) and
|
|
516
516
|
no spinner frames leaking into the text. `--yes` in a TTY skips the write
|
|
517
517
|
confirmation AND each verb's selection
|
|
518
|
-
multiselect — `record` records ALL, `ignore` ignores ALL, `revert` applies the full
|
|
518
|
+
multiselect — `record` records ALL, `ignore` ignores ALL drift (never a coverage gap), `revert` applies the full
|
|
519
519
|
plan. `check --yes` never opens the action menu (Record / Revert / Ignore / …) —
|
|
520
520
|
it just reports (#1054/#1185); use the standalone `record --yes` / `ignore --yes`
|
|
521
521
|
/ `revert --yes` verbs for scripted, non-interactive decisions.
|
|
@@ -696,6 +696,16 @@ ignore:
|
|
|
696
696
|
does not); a
|
|
697
697
|
failed-read readGap matches at the resource or the property
|
|
698
698
|
(`ClusterRestorer/Verifier.Environment`). A gap no rule matches keeps failing.
|
|
699
|
+
You need not hand-write the key: the interactive **`cdkrd ignore`** picker lists
|
|
700
|
+
every gap that fails `--strict` as a `[coverage gap — …]` row beside the drift,
|
|
701
|
+
and picking one writes exactly the key form that matches it (the construct path
|
|
702
|
+
on a CDK-synthesized app, the logicalId — `Fn9270CBC0.Environment` — on an
|
|
703
|
+
assembly without `aws:cdk:path` metadata). By-nature readGaps, `Custom::*` skips
|
|
704
|
+
and already-acknowledged gaps are not offered, and `ignore --yes` (or any
|
|
705
|
+
non-interactive run) never acknowledges a gap — it ignores the drift only and
|
|
706
|
+
notes how many gaps it left. The rule is an ordinary ignore rule: once the read
|
|
707
|
+
succeeds (you grant the permission), it ignores drift on that resource / property
|
|
708
|
+
too, so remove it when the gap is fixed.
|
|
699
709
|
|
|
700
710
|
```yaml
|
|
701
711
|
ignore:
|
package/dist/cli.js
CHANGED
|
@@ -953,6 +953,23 @@ function isCoverageReadGap(f) {
|
|
|
953
953
|
function isAcknowledgedGap(f) {
|
|
954
954
|
return f.acknowledgedBy !== void 0;
|
|
955
955
|
}
|
|
956
|
+
function isPendingCreationSkip$1(f) {
|
|
957
|
+
return f.tier === "skipped" && f.note === "no physical id";
|
|
958
|
+
}
|
|
959
|
+
function isCustomResourceSkip(f) {
|
|
960
|
+
return f.tier === "skipped" && (f.resourceType === "AWS::CloudFormation::CustomResource" || f.resourceType.startsWith("Custom::"));
|
|
961
|
+
}
|
|
962
|
+
/**
|
|
963
|
+
* The per-FINDING half of check.ts `hasCoverageGap` (the `--strict` gate): an
|
|
964
|
+
* UNACKNOWLEDGED skipped resource (minus a `Custom::*` skip, #724, and — under
|
|
965
|
+
* `--pre-deploy` — a pending-creation skip, #727) or failed-read readGap. The other half is
|
|
966
|
+
* an un-recursed nested stack, which is a template RESOURCE, not a finding. The `ignore`
|
|
967
|
+
* picker (#1976) offers exactly these, so every gap it lists is one whose acknowledgement
|
|
968
|
+
* changes the `--strict` verdict, and none it omits is one `--strict` fails on.
|
|
969
|
+
*/
|
|
970
|
+
function isStrictCoverageGapFinding(f, preDeploy = false) {
|
|
971
|
+
return !isAcknowledgedGap(f) && (f.tier === "skipped" && !(preDeploy && isPendingCreationSkip$1(f)) && !isCustomResourceSkip(f) || isCoverageReadGap(f));
|
|
972
|
+
}
|
|
956
973
|
|
|
957
974
|
// src/config/config-file.ts
|
|
958
975
|
const CONFIG_PATH = ".cdkrd/ignore.yaml";
|
|
@@ -18611,7 +18628,7 @@ const INFO_TIERS = [
|
|
|
18611
18628
|
"unresolved",
|
|
18612
18629
|
"skipped"
|
|
18613
18630
|
];
|
|
18614
|
-
function isPendingCreationSkip
|
|
18631
|
+
function isPendingCreationSkip(f) {
|
|
18615
18632
|
return f.tier === "skipped" && f.note === "no physical id";
|
|
18616
18633
|
}
|
|
18617
18634
|
function formatFinding(f, stackName = "") {
|
|
@@ -18804,13 +18821,13 @@ function report(rawFindings, header, opts = {}) {
|
|
|
18804
18821
|
return `${t}=${items.length} (${groupReasons(items)})`;
|
|
18805
18822
|
};
|
|
18806
18823
|
const skippedSummaryFor = (all) => {
|
|
18807
|
-
const isPending = (f) => !!opts.preDeploy && isPendingCreationSkip
|
|
18824
|
+
const isPending = (f) => !!opts.preDeploy && isPendingCreationSkip(f);
|
|
18808
18825
|
const acked = all.filter((f) => isAcknowledgedGap(f) && !isPending(f));
|
|
18809
18826
|
const items = all.filter((f) => !isAcknowledgedGap(f) || isPending(f));
|
|
18810
18827
|
const ackLine = acked.length > 0 ? [`acknowledged-skip=${acked.length} — NOT checked, acknowledged in .cdkrd/ignore.yaml (${groupReasons(acked)})`] : [];
|
|
18811
18828
|
if (!opts.preDeploy) return [...items.length > 0 ? [summaryFor("skipped", items)] : [], ...ackLine];
|
|
18812
|
-
const pending = items.filter(isPendingCreationSkip
|
|
18813
|
-
const gaps = items.filter((f) => !isPendingCreationSkip
|
|
18829
|
+
const pending = items.filter(isPendingCreationSkip);
|
|
18830
|
+
const gaps = items.filter((f) => !isPendingCreationSkip(f));
|
|
18814
18831
|
const lines = [];
|
|
18815
18832
|
if (gaps.length > 0) lines.push(summaryFor("skipped", gaps));
|
|
18816
18833
|
if (pending.length > 0) lines.push(`pending creation=${pending.length} (not yet deployed — the next deploy will create them, not a coverage gap)`);
|
|
@@ -22857,10 +22874,11 @@ async function recordStack(p) {
|
|
|
22857
22874
|
}
|
|
22858
22875
|
/** Header for ignore's multiselect. The key hints are rendered by `bulkMultiselect`
|
|
22859
22876
|
* itself, so this is just the one-line prompt. Pure + exported for unit tests. */
|
|
22860
|
-
function ignoreSelectMessage(stackName, region) {
|
|
22861
|
-
|
|
22877
|
+
function ignoreSelectMessage(stackName, region, gaps = 0) {
|
|
22878
|
+
const base = `${stackLabel$1(stackName, region)}: select drift to ignore — stops reporting it (writes .cdkrd/ignore.yaml)`;
|
|
22879
|
+
return gaps > 0 ? `${base}; a [coverage gap] row is ACKNOWLEDGED instead — still listed, no longer fails --strict (once the read succeeds, the rule ignores drift there too — remove it after granting the read)` : base;
|
|
22862
22880
|
}
|
|
22863
|
-
const ignoreFindingKey = (f) => `${f.logicalId}::${f.path}`;
|
|
22881
|
+
const ignoreFindingKey = (f) => f.tier === "skipped" || f.tier === "readGap" ? `${f.tier}::${f.logicalId}::${f.path}` : `${f.logicalId}::${f.path}`;
|
|
22864
22882
|
/**
|
|
22865
22883
|
* The ignore multiselect rows. EVERY row starts UNSELECTED (→ selects all) — mirroring
|
|
22866
22884
|
* revert's picker (R137): ignore STOPS watching permanently, and check's interactive flow
|
|
@@ -22873,17 +22891,36 @@ function ignoreSelectOptions(ignorable, stackName = "") {
|
|
|
22873
22891
|
const id = f.constructPath ? withinStackPath(f.constructPath, stackName) : f.logicalId;
|
|
22874
22892
|
return {
|
|
22875
22893
|
value: ignoreFindingKey(f),
|
|
22876
|
-
label: `${id}${f.path ? `.${f.path}` : ""}
|
|
22894
|
+
label: `${id}${f.path ? `.${f.path}` : ""} ${ignoreRowKind(f)}`,
|
|
22877
22895
|
selected: false
|
|
22878
22896
|
};
|
|
22879
22897
|
});
|
|
22880
22898
|
}
|
|
22881
22899
|
/**
|
|
22900
|
+
* The coverage gaps the `ignore` picker offers to ACKNOWLEDGE (#1976): exactly the findings
|
|
22901
|
+
* `check --strict` fails on (isStrictCoverageGapFinding, deployed path) — an unacknowledged
|
|
22902
|
+
* non-custom `skipped` resource, or a readGap whose read FAILED. A by-nature readGap
|
|
22903
|
+
* (write-only / not returned) never fails `--strict`, a `Custom::*` skip is excluded from
|
|
22904
|
+
* the gate (#724), and an acknowledged one already carries `acknowledgedBy` — none of them
|
|
22905
|
+
* is offered. Pure + exported.
|
|
22906
|
+
*/
|
|
22907
|
+
function acknowledgeableGaps(findings) {
|
|
22908
|
+
return findings.filter((f) => isStrictCoverageGapFinding(f));
|
|
22909
|
+
}
|
|
22910
|
+
function ignoreRowKind(f) {
|
|
22911
|
+
if (f.tier === "skipped") return `[coverage gap — resource not read${f.note ? `: ${sanitizeForTerminal(f.note).slice(0, 80)}` : ""}]`;
|
|
22912
|
+
if (f.tier === "readGap") return f.path ? "[coverage gap — property read failed]" : "[coverage gap — resource read failed]";
|
|
22913
|
+
return `(${f.tier})`;
|
|
22914
|
+
}
|
|
22915
|
+
/**
|
|
22882
22916
|
* Write `ignore` rules into `.cdkrd/ignore.yaml` for the chosen declared/undeclared
|
|
22883
22917
|
* findings — they stop being reported entirely (re-tagged `ignored` on the next check),
|
|
22884
22918
|
* the "stop watching" counterpart to record's "keep watching". Interactive runs pick
|
|
22885
22919
|
* WHICH findings to ignore (default NONE selected — → selects all, R137); `--yes`
|
|
22886
|
-
* ignores all shown.
|
|
22920
|
+
* ignores all shown drift. The interactive picker also lists the `--strict`-failing
|
|
22921
|
+
* coverage gaps (#1976, acknowledgeableGaps): a picked one gets the rule ignoreRuleFor
|
|
22922
|
+
* writes for it — RESOURCE-level for a skip (empty path), property-level for a failed
|
|
22923
|
+
* read — which applyIgnores matches to stamp `acknowledgedBy`. `--yes` never picks a gap.
|
|
22887
22924
|
* Non-interactively without `--yes` it refuses (a required decision, like record, R38).
|
|
22888
22925
|
* Idempotent: rules already in the file are reported, not duplicated. Shared by `cdkrd
|
|
22889
22926
|
* ignore` and (PR-B2) check's interactive flow, so both write rules identically.
|
|
@@ -22891,7 +22928,10 @@ function ignoreSelectOptions(ignorable, stackName = "") {
|
|
|
22891
22928
|
async function ignoreStack(p) {
|
|
22892
22929
|
const { stackName, findings, yes, interactive, accountId = "", region = "" } = p;
|
|
22893
22930
|
const ignorable = findings.filter((f) => f.tier === "declared" || f.tier === "undeclared" || f.tier === "added");
|
|
22894
|
-
|
|
22931
|
+
const gaps = acknowledgeableGaps(findings);
|
|
22932
|
+
const pickGaps = !yes && interactive && gaps.length > 0;
|
|
22933
|
+
if (gaps.length > 0 && !pickGaps) console.error(`note: ${stackName}: ${gaps.length} coverage gap(s) left unacknowledged — only the interactive picker acknowledges a gap (run \`cdkrd ignore ${stackName}\` in a terminal without --yes)`);
|
|
22934
|
+
if (ignorable.length === 0 && !pickGaps) {
|
|
22895
22935
|
if (!p.json) console.log(style.clean(`${stackName}: no ignorable drift to ignore.`));
|
|
22896
22936
|
return {
|
|
22897
22937
|
wrote: false,
|
|
@@ -22909,7 +22949,8 @@ async function ignoreStack(p) {
|
|
|
22909
22949
|
added: 0
|
|
22910
22950
|
};
|
|
22911
22951
|
}
|
|
22912
|
-
const
|
|
22952
|
+
const offered = [...ignorable, ...gaps];
|
|
22953
|
+
const picked = await bulkMultiselect(ignoreSelectMessage(stackName, region, gaps.length), ignoreSelectOptions(offered, stackName));
|
|
22913
22954
|
if (picked === void 0) {
|
|
22914
22955
|
console.error(`note: ${stackName}: ignore cancelled — config unchanged`);
|
|
22915
22956
|
return {
|
|
@@ -22919,7 +22960,7 @@ async function ignoreStack(p) {
|
|
|
22919
22960
|
};
|
|
22920
22961
|
}
|
|
22921
22962
|
const set = new Set(picked);
|
|
22922
|
-
chosen =
|
|
22963
|
+
chosen = offered.filter((f) => set.has(ignoreFindingKey(f)));
|
|
22923
22964
|
if (chosen.length === 0) {
|
|
22924
22965
|
console.error(`note: ${stackName}: nothing selected — config unchanged`);
|
|
22925
22966
|
return {
|
|
@@ -24191,14 +24232,8 @@ function nestedStackWarning(resources, stackName) {
|
|
|
24191
24232
|
const names = nested.map((r) => r.constructPath ? withinStackPath(r.constructPath, stackName) : r.logicalId).sort();
|
|
24192
24233
|
return `warning: ${stackName} has ${nested.length} nested CloudFormation stack(s) — cdkrd does not recurse into them, so the resources INSIDE them are NOT checked: ${names.join(", ")}`;
|
|
24193
24234
|
}
|
|
24194
|
-
function isPendingCreationSkip(f) {
|
|
24195
|
-
return f.tier === "skipped" && f.note === "no physical id";
|
|
24196
|
-
}
|
|
24197
|
-
function isCustomResourceSkip(f) {
|
|
24198
|
-
return f.tier === "skipped" && (f.resourceType === "AWS::CloudFormation::CustomResource" || f.resourceType.startsWith("Custom::"));
|
|
24199
|
-
}
|
|
24200
24235
|
function coverageWarning(findings, stackName, preDeploy = false) {
|
|
24201
|
-
const skipped = findings.filter((f) => f.tier === "skipped" && !(preDeploy && isPendingCreationSkip(f)) && !isAcknowledgedGap(f));
|
|
24236
|
+
const skipped = findings.filter((f) => f.tier === "skipped" && !(preDeploy && isPendingCreationSkip$1(f)) && !isAcknowledgedGap(f));
|
|
24202
24237
|
if (skipped.length === 0) return null;
|
|
24203
24238
|
const names = skipped.map((f) => f.constructPath ? withinStackPath(f.constructPath, stackName) : f.logicalId).sort();
|
|
24204
24239
|
const shown = names.slice(0, 10);
|
|
@@ -24216,7 +24251,7 @@ function readFailureWarning(findings, stackName) {
|
|
|
24216
24251
|
return `warning: ${stackName}: ${gaps.length} propert(ies) could NOT be read (coverage incomplete — grant the missing read permission, or acknowledge it in .cdkrd/ignore.yaml) — ${shown.join(", ")}${more}`;
|
|
24217
24252
|
}
|
|
24218
24253
|
function pendingCreationInfo(findings, stackName) {
|
|
24219
|
-
const pending = findings.filter(isPendingCreationSkip);
|
|
24254
|
+
const pending = findings.filter(isPendingCreationSkip$1);
|
|
24220
24255
|
if (pending.length === 0) return null;
|
|
24221
24256
|
const names = pending.map((f) => f.constructPath ? withinStackPath(f.constructPath, stackName) : f.logicalId).sort();
|
|
24222
24257
|
const shown = names.slice(0, 10);
|
|
@@ -24224,7 +24259,7 @@ function pendingCreationInfo(findings, stackName) {
|
|
|
24224
24259
|
return `info: ${stackName}: ${pending.length} resource(s) not yet deployed — will be created by the next deploy (pending creation, not a coverage gap): ${shown.join(", ")}${more}`;
|
|
24225
24260
|
}
|
|
24226
24261
|
function hasCoverageGap(findings, resources, preDeploy = false) {
|
|
24227
|
-
return findings.some((f) =>
|
|
24262
|
+
return findings.some((f) => isStrictCoverageGapFinding(f, preDeploy)) || resources.some((r) => r.resourceType === "AWS::CloudFormation::Stack");
|
|
24228
24263
|
}
|
|
24229
24264
|
function strictCoverageExit(strict, findings, resources, preDeploy = false) {
|
|
24230
24265
|
return strict && hasCoverageGap(findings, resources, preDeploy) ? 1 : 0;
|
|
@@ -24833,7 +24868,8 @@ OPTIONS
|
|
|
24833
24868
|
--yes, -y skip the write confirm AND the op multiselect — apply the
|
|
24834
24869
|
FULL plan (revert) / skip the selection multiselect +
|
|
24835
24870
|
overwrite notice, record ALL (record) / ignore ALL shown
|
|
24836
|
-
drift without the multiselect (ignore
|
|
24871
|
+
drift without the multiselect (ignore; a --strict coverage
|
|
24872
|
+
gap is acknowledged only from the interactive picker)
|
|
24837
24873
|
--help, -h --version, -v (bare \`cdkrd -v\` prints the version; inside a verb,
|
|
24838
24874
|
\`-v\` is the short alias for --verbose, e.g. check -v)
|
|
24839
24875
|
|