@intentius/chant 0.124.97 → 0.124.98
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/core.d.ts +29 -0
- package/dist/audit/core.d.ts.map +1 -1
- package/dist/audit/core.js +48 -11
- package/dist/audit/identity.d.ts +27 -0
- package/dist/audit/identity.d.ts.map +1 -0
- package/dist/audit/identity.js +36 -0
- package/dist/audit/report-html.d.ts +3 -1
- package/dist/audit/report-html.d.ts.map +1 -1
- package/dist/audit/report-html.js +1 -1
- package/dist/audit/report-model.d.ts +16 -0
- package/dist/audit/report-model.d.ts.map +1 -1
- package/dist/audit/report-model.js +5 -1
- package/dist/ci-agent.d.ts +17 -0
- package/dist/ci-agent.d.ts.map +1 -1
- package/dist/ci-agent.js +32 -0
- package/dist/ci-comment-allow.d.ts +88 -0
- package/dist/ci-comment-allow.d.ts.map +1 -0
- package/dist/ci-comment-allow.js +178 -0
- package/dist/ci-comment-commands.d.ts +12 -0
- package/dist/ci-comment-commands.d.ts.map +1 -1
- package/dist/ci-comment-commands.js +22 -0
- package/dist/ci-control.d.ts +6 -1
- package/dist/ci-control.d.ts.map +1 -1
- package/dist/ci-control.js +6 -1
- package/dist/ci-product.d.ts +3 -0
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +3 -0
- package/dist/cli/commands/audit.d.ts +3 -1
- package/dist/cli/commands/audit.d.ts.map +1 -1
- package/dist/cli/commands/audit.js +23 -6
- package/dist/cli/commands/import.d.ts +8 -1
- package/dist/cli/commands/import.d.ts.map +1 -1
- package/dist/cli/commands/import.js +31 -6
- package/dist/cli/handlers/agent.d.ts.map +1 -1
- package/dist/cli/handlers/agent.js +12 -2
- package/dist/cli/handlers/pr-comment.d.ts +6 -0
- package/dist/cli/handlers/pr-comment.d.ts.map +1 -1
- package/dist/cli/handlers/pr-comment.js +12 -0
- package/dist/cli/handlers/promote.d.ts.map +1 -1
- package/dist/cli/handlers/promote.js +53 -6
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +29 -6
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +23 -0
- package/dist/cli/registry.d.ts +8 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/cloud-lister/mask.d.ts +30 -1
- package/dist/cloud-lister/mask.d.ts.map +1 -1
- package/dist/cloud-lister/mask.js +66 -3
- package/dist/components/driver.d.ts +8 -1
- package/dist/components/driver.d.ts.map +1 -1
- package/dist/components/driver.js +1 -0
- package/dist/components/product-pipeline.d.ts +23 -1
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +40 -7
- package/dist/components/product-plan.d.ts +20 -0
- package/dist/components/product-plan.d.ts.map +1 -1
- package/dist/components/product-plan.js +11 -1
- package/dist/control/applied.d.ts +8 -1
- package/dist/control/applied.d.ts.map +1 -1
- package/dist/control/applied.js +18 -2
- package/dist/control/dispatch.d.ts +52 -0
- package/dist/control/dispatch.d.ts.map +1 -1
- package/dist/control/dispatch.js +140 -4
- package/dist/control/train.d.ts +198 -0
- package/dist/control/train.d.ts.map +1 -0
- package/dist/control/train.js +294 -0
- package/dist/deep-observation.js +2 -2
- package/dist/floor-table.data.d.ts.map +1 -1
- package/dist/floor-table.data.js +11 -0
- package/dist/graph-detail.d.ts +9 -0
- package/dist/graph-detail.d.ts.map +1 -1
- package/dist/graph-detail.js +38 -13
- package/dist/graph-refs.d.ts +233 -3
- package/dist/graph-refs.d.ts.map +1 -1
- package/dist/graph-refs.js +106 -15
- package/dist/lint/post-synth.d.ts +22 -0
- package/dist/lint/post-synth.d.ts.map +1 -1
- package/dist/lint/rules/declarable-naming-convention.d.ts +12 -0
- package/dist/lint/rules/declarable-naming-convention.d.ts.map +1 -1
- package/dist/lint/rules/declarable-naming-convention.js +38 -8
- package/dist/lint/rules/imported-source.d.ts +20 -0
- package/dist/lint/rules/imported-source.d.ts.map +1 -0
- package/dist/lint/rules/imported-source.js +27 -0
- package/dist/lint/rules/no-unused-declarable.d.ts.map +1 -1
- package/dist/lint/rules/no-unused-declarable.js +3 -0
- package/dist/op/gate.d.ts +2 -0
- package/dist/op/gate.d.ts.map +1 -1
- package/dist/op/gate.js +8 -1
- package/dist/pr-forge-reads.d.ts +17 -0
- package/dist/pr-forge-reads.d.ts.map +1 -1
- package/dist/pr-forge-reads.js +55 -0
- package/dist/release-floors.d.ts +9 -1
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +9 -1
- package/dist/repo-path.d.ts +29 -0
- package/dist/repo-path.d.ts.map +1 -0
- package/dist/repo-path.js +81 -0
- package/dist/sensitive-key.d.ts +23 -0
- package/dist/sensitive-key.d.ts.map +1 -1
- package/dist/sensitive-key.js +37 -0
- package/dist/terraform/hcl2json.d.ts +7 -0
- package/dist/terraform/hcl2json.d.ts.map +1 -1
- package/dist/terraform/hcl2json.js +7 -0
- package/dist/wave-runtime.mjs +352 -345
- package/dist/workspace/catalog-edges.d.ts +147 -0
- package/dist/workspace/catalog-edges.d.ts.map +1 -0
- package/dist/workspace/catalog-edges.js +461 -0
- package/dist/workspace/compose-graph.d.ts +73 -3
- package/dist/workspace/compose-graph.d.ts.map +1 -1
- package/dist/workspace/declaration.d.ts +2 -0
- package/dist/workspace/declaration.d.ts.map +1 -1
- package/dist/workspace/declaration.js +1 -0
- package/dist/workspace/declaration.schema.json +6 -0
- package/dist/workspace/discover.d.ts +134 -0
- package/dist/workspace/discover.d.ts.map +1 -0
- package/dist/workspace/discover.js +372 -0
- package/dist/workspace/graph-cli.d.ts +20 -0
- package/dist/workspace/graph-cli.d.ts.map +1 -1
- package/dist/workspace/graph-cli.js +178 -20
- package/dist/workspace/graph.schema.json +195 -2
- package/dist/workspace/release-train.d.ts +214 -3
- package/dist/workspace/release-train.d.ts.map +1 -1
- package/dist/workspace/release-train.js +552 -16
- package/dist/workspace/repo-ref.d.ts +14 -0
- package/dist/workspace/repo-ref.d.ts.map +1 -1
- package/dist/workspace/repo-ref.js +26 -1
- package/dist/workspace/workspace-gates.d.ts +24 -0
- package/dist/workspace/workspace-gates.d.ts.map +1 -1
- package/dist/workspace/workspace-gates.js +29 -5
- package/dist/workspace/workspace-ledger.d.ts +31 -5
- package/dist/workspace/workspace-ledger.d.ts.map +1 -1
- package/dist/workspace/workspace-ledger.js +2 -1
- package/dist/workspace/workspace-run.d.ts +14 -0
- package/dist/workspace/workspace-run.d.ts.map +1 -1
- package/dist/workspace/workspace-run.js +2 -2
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +33 -8
- package/package.json +1 -1
- package/src/audit/core.test.ts +64 -1
- package/src/audit/core.ts +75 -10
- package/src/audit/identity.test.ts +31 -0
- package/src/audit/identity.ts +43 -0
- package/src/audit/report-html.ts +4 -2
- package/src/audit/report-model.ts +21 -1
- package/src/ci-agent.test.ts +32 -0
- package/src/ci-agent.ts +42 -0
- package/src/ci-comment-allow.test.ts +380 -0
- package/src/ci-comment-allow.ts +184 -0
- package/src/ci-comment-commands.ts +25 -0
- package/src/ci-control.ts +42 -0
- package/src/ci-product.ts +3 -0
- package/src/cli/commands/audit-parser-notice.test.ts +74 -0
- package/src/cli/commands/audit.test.ts +12 -0
- package/src/cli/commands/audit.ts +25 -7
- package/src/cli/commands/import-layout.test.ts +2 -1
- package/src/cli/commands/import.ts +29 -6
- package/src/cli/handlers/agent.ts +13 -2
- package/src/cli/handlers/pr-comment.ts +12 -0
- package/src/cli/handlers/promote.test.ts +68 -0
- package/src/cli/handlers/promote.ts +52 -6
- package/src/cli/main.test.ts +5 -0
- package/src/cli/main.ts +29 -6
- package/src/cli/parse-args.ts +18 -0
- package/src/cli/registry.ts +8 -0
- package/src/cloud-lister/kubernetes.k3d.e2e.test.ts +104 -0
- package/src/cloud-lister/mask-references.test.ts +132 -0
- package/src/cloud-lister/mask.ts +68 -3
- package/src/components/driver.ts +9 -1
- package/src/components/product-pipeline.ts +57 -7
- package/src/components/product-plan.ts +27 -2
- package/src/control/applied.ts +33 -3
- package/src/control/dispatch.ts +156 -5
- package/src/control/train.test.ts +215 -0
- package/src/control/train.ts +413 -0
- package/src/deep-observation.ts +2 -2
- package/src/floor-table.data.ts +6 -0
- package/src/graph-detail.ts +37 -12
- package/src/graph-refs.test.ts +45 -1
- package/src/graph-refs.ts +321 -14
- package/src/lint/post-synth.ts +20 -0
- package/src/lint/rules/declarable-naming-convention.test.ts +35 -1
- package/src/lint/rules/declarable-naming-convention.ts +35 -8
- package/src/lint/rules/imported-source.test.ts +22 -0
- package/src/lint/rules/imported-source.ts +31 -0
- package/src/lint/rules/no-unused-declarable.test.ts +16 -0
- package/src/lint/rules/no-unused-declarable.ts +7 -0
- package/src/op/gate.ts +10 -2
- package/src/pr-forge-reads.ts +62 -0
- package/src/release-floors.ts +13 -1
- package/src/repo-path.test.ts +72 -0
- package/src/repo-path.ts +103 -0
- package/src/sensitive-key.ts +38 -0
- package/src/terraform/hcl2json.ts +8 -0
- package/src/workspace/application-set.e2e.test.ts +405 -0
- package/src/workspace/catalog-edges.ts +507 -0
- package/src/workspace/ci-green-workflow.test.ts +2 -2
- package/src/workspace/cluster-join.e2e.test.ts +150 -0
- package/src/workspace/compose-graph.ts +74 -5
- package/src/workspace/declaration.schema.json +6 -0
- package/src/workspace/declaration.ts +3 -0
- package/src/workspace/discover.e2e.test.ts +122 -0
- package/src/workspace/discover.test.ts +225 -0
- package/src/workspace/discover.ts +406 -0
- package/src/workspace/external-secret-catalog.e2e.test.ts +98 -0
- package/src/workspace/external-secret-catalog.test.ts +142 -0
- package/src/workspace/graph-cli.ts +207 -21
- package/src/workspace/graph-contract.test.ts +92 -0
- package/src/workspace/graph.schema.json +195 -2
- package/src/workspace/helm-references.e2e.test.ts +135 -0
- package/src/workspace/identity-annotation-catalog.e2e.test.ts +91 -0
- package/src/workspace/identity-annotation-catalog.test.ts +139 -0
- package/src/workspace/release-train-repos.test.ts +304 -0
- package/src/workspace/release-train.test.ts +296 -0
- package/src/workspace/release-train.ts +631 -16
- package/src/workspace/repo-ref.ts +26 -1
- package/src/workspace/runs-on.test.ts +45 -0
- package/src/workspace/workspace-gates.ts +48 -5
- package/src/workspace/workspace-ledger.ts +28 -5
- package/src/workspace/workspace-run.test.ts +1 -1
- package/src/workspace/workspace-run.ts +2 -2
- package/src/yaml.test.ts +96 -8
- package/src/yaml.ts +36 -8
|
@@ -75,7 +75,7 @@ import { redeployLine, releaseRollbackLine, rollbackTarget, unsettledComponents
|
|
|
75
75
|
import { actorFromEnv } from "../../actor";
|
|
76
76
|
|
|
77
77
|
const PROMOTE_USAGE =
|
|
78
|
-
"chant components promote --to <env> [--from <env>] [--allow-skip] [--release <label|digest>] [--component <name> [--digest <sha256:...>] | --digest <component>=<sha256:...> ...] [--wave-gate <gate>] [--resume <file>] [--dry-run] [--json]";
|
|
78
|
+
"chant components promote --to <env> [--from <env>] [--allow-skip] [--release <label|digest> [--plan-only]] [--component <name> [--digest <sha256:...>] | --digest <component>=<sha256:...> ...] [--wave-gate <gate>] [--resume <file>] [--dry-run] [--json]";
|
|
79
79
|
const ROLLBACK_USAGE =
|
|
80
80
|
"chant components rollback <env> (--component <name> [--digest <sha256:...>] | --release <label|digest>) [--dry-run] [--json]";
|
|
81
81
|
const REDEPLOY_USAGE =
|
|
@@ -209,6 +209,8 @@ async function bindReleaseGate(input: {
|
|
|
209
209
|
grouped?: import("../../components/fan-out").FanOutPlan;
|
|
210
210
|
/** Each group plan this binding makes is added here, the newest first, for the run to apply. */
|
|
211
211
|
groupRuns: import("../../components/capability").GroupRun[];
|
|
212
|
+
/** `--plan-only` (#4037): plan and store the change set, and record nothing in the gate ledger, an empty pass included. */
|
|
213
|
+
planOnly?: boolean;
|
|
212
214
|
}): Promise<BoundReleaseGate | number | undefined> {
|
|
213
215
|
const { plan, under, port } = input;
|
|
214
216
|
const gate = await import("../../components/release-gate");
|
|
@@ -262,6 +264,10 @@ async function bindReleaseGate(input: {
|
|
|
262
264
|
const { readStoredChangeSet } = await import("../../lifecycle/change-set-store");
|
|
263
265
|
const { isEmptyChangeSet } = await import("../../change-set");
|
|
264
266
|
const verifyEmpty = gate.emptyVerifier((digest) => readStoredChangeSet(digest, { cwd: input.projectPath }), { releaseDigest, environment: env });
|
|
267
|
+
// #4037: a promote a train started under a workspace gate may take that gate's approval in place of its own.
|
|
268
|
+
const { resolveWorkspaceRun } = await import("../../op/workspace-run-env");
|
|
269
|
+
const underWorkspace = resolveWorkspaceRun();
|
|
270
|
+
const workspace = underWorkspace?.gate ? { workspace: releaseWorkspaceGate(input.projectPath, underWorkspace.gate) } : {};
|
|
265
271
|
|
|
266
272
|
/** Refuse, store, and pass the gates of an empty plan; the binding, or the exit code of a refusal already printed. */
|
|
267
273
|
const bindDoc = async (doc: ChangeSetDocument, names: readonly string[], what: string): Promise<{ binding: ReleaseGateBinding; empty: boolean } | number> => {
|
|
@@ -293,7 +299,7 @@ async function bindReleaseGate(input: {
|
|
|
293
299
|
(empty ? ", empty: its gates pass without an approval" : `, ${doc.summary.entries} entr${doc.summary.entries === 1 ? "y" : "ies"}, ${doc.summary.holes} hole(s)`) +
|
|
294
300
|
` (chant change-set show ${doc.digest})`,
|
|
295
301
|
));
|
|
296
|
-
if (empty) {
|
|
302
|
+
if (empty && !input.planOnly) {
|
|
297
303
|
if (!port.appendResolution) throw new Error("the gate ledger can't record a resolution, so an empty change set can't pass its gates");
|
|
298
304
|
const { resolutions } = await port.read(gate.RELEASE_GATE_OP);
|
|
299
305
|
const timestamp = new Date().toISOString();
|
|
@@ -308,7 +314,7 @@ async function bindReleaseGate(input: {
|
|
|
308
314
|
);
|
|
309
315
|
}
|
|
310
316
|
}
|
|
311
|
-
return { binding: { op: gate.RELEASE_GATE_OP, planDigest: doc.digest, releaseDigest, verifyEmpty }, empty };
|
|
317
|
+
return { binding: { op: gate.RELEASE_GATE_OP, planDigest: doc.digest, releaseDigest, verifyEmpty, ...workspace }, empty };
|
|
312
318
|
};
|
|
313
319
|
|
|
314
320
|
const later = {
|
|
@@ -334,7 +340,7 @@ async function bindReleaseGate(input: {
|
|
|
334
340
|
return {
|
|
335
341
|
doc: stored.document,
|
|
336
342
|
empty: isEmptyChangeSet(stored.document),
|
|
337
|
-
binding: { op: gate.RELEASE_GATE_OP, planDigest: stored.document.digest, releaseDigest, verifyEmpty },
|
|
343
|
+
binding: { op: gate.RELEASE_GATE_OP, planDigest: stored.document.digest, releaseDigest, verifyEmpty, ...workspace },
|
|
338
344
|
reads: fresh.reads,
|
|
339
345
|
resumedFrom: stored.document.digest,
|
|
340
346
|
...groupsOf(fresh),
|
|
@@ -359,6 +365,20 @@ async function bindReleaseGate(input: {
|
|
|
359
365
|
return { doc: first.doc, ...bound, reads: first.reads, ...groupsOf(first), ...(first.plannedOutputs ? { plannedOutputs: first.plannedOutputs } : {}), ...(first.unknownInputs ? { unknownInputs: first.unknownInputs } : {}), ...later };
|
|
360
366
|
}
|
|
361
367
|
|
|
368
|
+
/**
|
|
369
|
+
* The workspace gate stand-in for a release gate (#4037, ws-039), loading the
|
|
370
|
+
* workspace code only when a gate is asked about it. The approval must cover
|
|
371
|
+
* this member's gate, change set, environment and release.
|
|
372
|
+
*/
|
|
373
|
+
function releaseWorkspaceGate(cwd: string, gate: string): import("../../op/gate").WorkspaceGateStandIn {
|
|
374
|
+
return {
|
|
375
|
+
async standIn(q) {
|
|
376
|
+
const { memberGateStandIn } = await import("../../workspace/workspace-gates");
|
|
377
|
+
return memberGateStandIn(cwd, gate, q);
|
|
378
|
+
},
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
|
|
362
382
|
/** A later round's or wave's plan was refused (provisional or failed members); the refusal is already printed. */
|
|
363
383
|
class PromoteStageRefused extends Error {
|
|
364
384
|
constructor() {
|
|
@@ -603,15 +623,18 @@ async function deployPlanIn(
|
|
|
603
623
|
actor: actor!,
|
|
604
624
|
projectPath: project.projectPath,
|
|
605
625
|
head,
|
|
606
|
-
...(resume ? { resume } : {}),
|
|
626
|
+
...(resume && !args.planOnly ? { resume } : {}),
|
|
607
627
|
...(grouped ? { grouped } : {}),
|
|
608
628
|
groupRuns,
|
|
629
|
+
...(args.planOnly ? { planOnly: true } : {}),
|
|
609
630
|
});
|
|
610
631
|
if (typeof result === "number") {
|
|
611
632
|
tidy();
|
|
612
633
|
return result;
|
|
613
634
|
}
|
|
614
|
-
if (result) {
|
|
635
|
+
if (result && args.planOnly) {
|
|
636
|
+
bound = result;
|
|
637
|
+
} else if (result) {
|
|
615
638
|
bound = result;
|
|
616
639
|
releaseGate = result.binding;
|
|
617
640
|
changeSetJson = { changeSet: result.doc.digest, empty: result.empty };
|
|
@@ -628,6 +651,25 @@ async function deployPlanIn(
|
|
|
628
651
|
throw err;
|
|
629
652
|
}
|
|
630
653
|
}
|
|
654
|
+
// #4037: --plan-only stops here, with the change set planned and stored, and nothing deployed.
|
|
655
|
+
if (args.planOnly && under) {
|
|
656
|
+
tidy();
|
|
657
|
+
const { gateNamesOf, RELEASE_GATE_OP: op } = await import("../../components/release-gate");
|
|
658
|
+
const planned = {
|
|
659
|
+
env: plan.to,
|
|
660
|
+
releaseDigest: under.release.releaseDigest,
|
|
661
|
+
label: under.label,
|
|
662
|
+
op,
|
|
663
|
+
gates: bound ? gateNamesOf(prepared) : [],
|
|
664
|
+
changeSet: bound?.doc.digest ?? null,
|
|
665
|
+
empty: bound?.empty ?? null,
|
|
666
|
+
components: plan.items.map((i) => i.component),
|
|
667
|
+
};
|
|
668
|
+
if (args.json) console.log(JSON.stringify(planned, null, 2));
|
|
669
|
+
else if (!bound) console.error(formatInfo(`release ${under.label ?? under.release.releaseDigest} for "${plan.to}": no promoted composition declares a gate, so there is no change set to approve; nothing was deployed`));
|
|
670
|
+
else console.error(formatInfo(`release ${under.label ?? under.release.releaseDigest} for "${plan.to}": change set ${planned.changeSet}${planned.empty ? ", empty" : ""}, gates ${planned.gates.join(", ")}; nothing was deployed`));
|
|
671
|
+
return 0;
|
|
672
|
+
}
|
|
631
673
|
if (args.waveGate && !bound) {
|
|
632
674
|
console.error(formatError({ message: "--wave-gate needs a promote under --release whose compositions declare a gate", hint: PROMOTE_USAGE }));
|
|
633
675
|
tidy();
|
|
@@ -991,6 +1033,10 @@ export async function runComponentsPromote(ctx: CommandContext): Promise<number>
|
|
|
991
1033
|
return 1;
|
|
992
1034
|
}
|
|
993
1035
|
}
|
|
1036
|
+
if (args.planOnly && !args.release) {
|
|
1037
|
+
console.error(formatError({ message: "--plan-only plans a release's change set: it needs --release <label|digest>", hint: PROMOTE_USAGE }));
|
|
1038
|
+
return 1;
|
|
1039
|
+
}
|
|
994
1040
|
const who = actorOrRefuse(ctx);
|
|
995
1041
|
if (typeof who === "number") return who;
|
|
996
1042
|
|
package/src/cli/main.test.ts
CHANGED
|
@@ -910,6 +910,11 @@ describe("workspace init and ls (#2534)", () => {
|
|
|
910
910
|
expect(train).toMatchObject({ positionals: ["train", "prod"], pins: ["api=v2", "web=v1"] });
|
|
911
911
|
expect(resolveCommand(train, commandRegistry)?.def.name).toBe("workspace train");
|
|
912
912
|
expect(() => parseArgs(["workspace", "train", "prod", "--pin", "api"])).toThrow(/--pin needs a member and a release/);
|
|
913
|
+
// #4037: a train's promote, and a member's promote that only plans.
|
|
914
|
+
expect(parseArgs(["workspace", "train", "promote", "prod", "train-1", "--gate", "train-prod"])).toMatchObject({ positionals: ["train", "promote", "prod", "train-1"], gate: "train-prod" });
|
|
915
|
+
expect(parseArgs(["components", "promote", "--to", "prod", "--release", "v1", "--plan-only"])).toMatchObject({ release: "v1", planOnly: true });
|
|
916
|
+
// #5119: a train's promote across repositories, moved on from a member's answer.
|
|
917
|
+
expect(parseArgs(["workspace", "train", "promote", "prod", "train-1", "--continue", "--json"])).toMatchObject({ positionals: ["train", "promote", "prod", "train-1"], continueTrain: true, json: true });
|
|
913
918
|
expect(parseArgs(["workspace", "lint", "--cross-root", "--format", "json"])).toMatchObject({ path: "lint", crossRoot: true, format: "json" });
|
|
914
919
|
});
|
|
915
920
|
|
package/src/cli/main.ts
CHANGED
|
@@ -1221,6 +1221,14 @@ Workspace (level 1, #2524):
|
|
|
1221
1221
|
--no-cache reads every member
|
|
1222
1222
|
--capability-view: each member's chant adds its
|
|
1223
1223
|
capability view, mapped by its own lexicons
|
|
1224
|
+
workspace graph <dir> --discover [--runs-on <member>=<member>/<address>]... [--at <rev>] [--member <name>] [--detail 0..3] [--no-cache] [-o <file>]
|
|
1225
|
+
The same document for a directory with no
|
|
1226
|
+
declaration: the kinds' probes find the members, a
|
|
1227
|
+
discovered list says what each claimed directory
|
|
1228
|
+
became, and nothing is written inside <dir>.
|
|
1229
|
+
--runs-on names the cluster resource a member runs
|
|
1230
|
+
on, drawing a declared edge from its Argo CD cluster
|
|
1231
|
+
Secrets to it
|
|
1224
1232
|
workspace drift --member <name> [--read <state|plan|refresh|live-read|ownership>] [--resource <addr>] [--env <name>] [--stream] [-o <file>]
|
|
1225
1233
|
One member's drift, read by its own engine: a chant
|
|
1226
1234
|
member through lifecycle diff --live (needs --env), a
|
|
@@ -1272,11 +1280,24 @@ Workspace (level 1, #2524):
|
|
|
1272
1280
|
plan and the member sets acceptWorkspaceGates at base
|
|
1273
1281
|
workspace train <env> [--pin <member>=<label|digest>]... [--dry-run] [--json]
|
|
1274
1282
|
Record a release train: one cut release of every
|
|
1275
|
-
chant member (the newest, unless --pin picks
|
|
1276
|
-
under _members/_workspace/<env>/trains.jsonl.
|
|
1277
|
-
|
|
1283
|
+
chant and repo member (the newest, unless --pin picks
|
|
1284
|
+
one), under _members/_workspace/<env>/trains.jsonl. A
|
|
1285
|
+
repo member's releases are read at its pinned rev with
|
|
1286
|
+
its own chant release list (#5119). Refuses when a
|
|
1287
|
+
member has no release
|
|
1278
1288
|
workspace train list <env> [--json]
|
|
1279
|
-
The release trains recorded for <env>, oldest first
|
|
1289
|
+
The release trains recorded for <env>, oldest first,
|
|
1290
|
+
each with its digest and the runs that promoted it
|
|
1291
|
+
workspace train promote <env> [<train id|digest>] [--gate <name>] [--continue] [--dry-run] [--json]
|
|
1292
|
+
Promote a train (the newest for <env> unless named):
|
|
1293
|
+
each member's components promote --release, producers
|
|
1294
|
+
first. --gate plans every member first and records one
|
|
1295
|
+
workspace gate fact over their release gates; nothing
|
|
1296
|
+
deploys until run approve approves it (#4037). A train
|
|
1297
|
+
of repo members dispatches the first member repository
|
|
1298
|
+
instead; --continue moves on from the member's answer
|
|
1299
|
+
in _control/applied.jsonl, after applied or unchanged
|
|
1300
|
+
(#5119)
|
|
1280
1301
|
|
|
1281
1302
|
Lifecycle (alias: lc):
|
|
1282
1303
|
lifecycle snapshot <env> Query API, save metadata to orphan branch
|
|
@@ -1475,7 +1496,7 @@ Component release ledger + status:
|
|
|
1475
1496
|
components promote Deploy the digests one environment's release
|
|
1476
1497
|
ledger records to another, without a build
|
|
1477
1498
|
(--to <env> [--from <env>] [--allow-skip]
|
|
1478
|
-
[--release <label|digest>]
|
|
1499
|
+
[--release <label|digest> [--plan-only]]
|
|
1479
1500
|
[--component <name> [--digest <sha256:...>]];
|
|
1480
1501
|
--from defaults to the environment before --to
|
|
1481
1502
|
in the config's environments; --dry-run prints
|
|
@@ -1483,7 +1504,9 @@ Component release ledger + status:
|
|
|
1483
1504
|
--release a dependent plans against its
|
|
1484
1505
|
upstream's planned outputs and plans again once
|
|
1485
1506
|
it applies; --wave-gate <gate> checks each wave
|
|
1486
|
-
at <gate>-wave-<k>; a stop writes --resume <file
|
|
1507
|
+
at <gate>-wave-<k>; a stop writes --resume <file>;
|
|
1508
|
+
--plan-only plans and stores the release's change
|
|
1509
|
+
set and deploys nothing, #4037)
|
|
1487
1510
|
components rollback <env> Redeploy an earlier release of an environment
|
|
1488
1511
|
from its recorded digest (--component <name>
|
|
1489
1512
|
[--digest <sha256:...>]; defaults to the release
|
package/src/cli/parse-args.ts
CHANGED
|
@@ -66,10 +66,13 @@ const BOOLEAN_FLAGS = new Set([
|
|
|
66
66
|
"--bump",
|
|
67
67
|
"--no-release-record",
|
|
68
68
|
"--deploy-unchanged",
|
|
69
|
+
"--plan-only",
|
|
70
|
+
"--continue",
|
|
69
71
|
"--no-record",
|
|
70
72
|
"--fold",
|
|
71
73
|
"--no-fold",
|
|
72
74
|
"--no-cache",
|
|
75
|
+
"--discover",
|
|
73
76
|
"--no-build",
|
|
74
77
|
"--sandbox",
|
|
75
78
|
"--yes",
|
|
@@ -1110,6 +1113,12 @@ export function parseArgs(args: string[]): ParsedArgs {
|
|
|
1110
1113
|
} else if (arg === "--deploy-unchanged") {
|
|
1111
1114
|
// `chant run --components --release --deploy-unchanged` (#4695): deploy a component whose inputs did not change.
|
|
1112
1115
|
result.deployUnchanged = true;
|
|
1116
|
+
} else if (arg === "--continue") {
|
|
1117
|
+
// `chant workspace train promote --continue` (#5119): advance a train's promote across repositories from the answers recorded.
|
|
1118
|
+
result.continueTrain = true;
|
|
1119
|
+
} else if (arg === "--plan-only") {
|
|
1120
|
+
// `chant components promote --release --plan-only` (#4037): plan and store the release's change set, deploy nothing.
|
|
1121
|
+
result.planOnly = true;
|
|
1113
1122
|
} else if (arg === "--artifacts") {
|
|
1114
1123
|
// `chant release compile --artifacts` (#4026, internal)
|
|
1115
1124
|
result.artifacts = true;
|
|
@@ -1157,6 +1166,9 @@ export function parseArgs(args: string[]): ParsedArgs {
|
|
|
1157
1166
|
} else if (arg === "--no-cache") {
|
|
1158
1167
|
// `chant workspace graph --no-cache` (#2876): read every member.
|
|
1159
1168
|
result.noCache = true;
|
|
1169
|
+
} else if (arg === "--discover") {
|
|
1170
|
+
// `chant workspace graph <dir> --discover` (#5095): find the members by probe, with no declaration.
|
|
1171
|
+
result.discover = true;
|
|
1160
1172
|
} else if (arg === "--no-fold") {
|
|
1161
1173
|
// chant #1134 — fold is the default build path; this is the explicit
|
|
1162
1174
|
// opt-out, and like --fold it beats chant.config.ts's build.fold.
|
|
@@ -1334,6 +1346,12 @@ export function parseArgs(args: string[]): ParsedArgs {
|
|
|
1334
1346
|
// #2641 — `chant workspace check --generated` runs each declared
|
|
1335
1347
|
// generator and compares its output with the file in the tree.
|
|
1336
1348
|
result.generated = true;
|
|
1349
|
+
} else if (arg === "--runs-on") {
|
|
1350
|
+
// `chant workspace graph --discover --runs-on <member>=<member>/<address>` (#5101): the cluster resource a discovered member runs on. Repeatable.
|
|
1351
|
+
const value = args[++i];
|
|
1352
|
+
const at = value?.indexOf("=") ?? -1;
|
|
1353
|
+
if (!value || at < 1 || at === value.length - 1) throw new Error("--runs-on needs a member and the cluster resource it runs on: --runs-on <member>=<member>/<address>");
|
|
1354
|
+
result.runsOn = { ...(result.runsOn ?? {}), [value.slice(0, at)]: value.slice(at + 1) };
|
|
1337
1355
|
} else if (arg === "--member") {
|
|
1338
1356
|
// #2537 — `chant workspace build|lint|audit|graph --member <name>`.
|
|
1339
1357
|
// Repeatable, and a comma list works too.
|
package/src/cli/registry.ts
CHANGED
|
@@ -651,6 +651,10 @@ export interface ParsedArgs {
|
|
|
651
651
|
resource?: string;
|
|
652
652
|
/** `chant workspace graph --no-cache` (#2876): read every member, bypassing the per-member cache. */
|
|
653
653
|
noCache?: boolean;
|
|
654
|
+
/** `chant workspace graph <dir> --discover` (#5095): find the members by the kinds' probes, with no declaration and no writes inside <dir>. */
|
|
655
|
+
discover?: boolean;
|
|
656
|
+
/** `chant workspace graph --discover --runs-on <member>=<member>/<address>` (#5101): the cluster resource a discovered member runs on, by member name. */
|
|
657
|
+
runsOn?: Record<string, string>;
|
|
654
658
|
/** `chant release images --no-build` (#4657): check the archives already on disk instead of building them. */
|
|
655
659
|
noBuild?: boolean;
|
|
656
660
|
/** `chant workspace graph --composites` (#2662): print each composite instance with the components that can deploy it. */
|
|
@@ -892,6 +896,10 @@ export interface ParsedArgs {
|
|
|
892
896
|
release?: string;
|
|
893
897
|
/** `chant run --components --release --deploy-unchanged` (#4695): deploy every component, also one whose declared inputs are the same as in the release the environment runs it from. */
|
|
894
898
|
deployUnchanged?: boolean;
|
|
899
|
+
/** `chant components promote --release <label|digest> --plan-only` (#4037): plan the release's change set for `--to`, store it and print it, and deploy nothing. `chant workspace train promote --gate` asks each member for it before any member deploys. */
|
|
900
|
+
planOnly?: boolean;
|
|
901
|
+
/** `chant workspace train promote <env> <train> --continue` (#5119): advance the promote in flight of a train of repo members from the answers the control repo recorded, and start nothing new. */
|
|
902
|
+
continueTrain?: boolean;
|
|
895
903
|
/** `chant release cut --build <command>` (#4026): the shell command run in the member's directory before each environment's templates are read, with `CHANT_ENV` set to the environment. */
|
|
896
904
|
buildCommand?: string;
|
|
897
905
|
/** `chant release compile --artifacts` (#4026, internal): build the artifacts of `--component` instead of compiling the environment. */
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* chant#5116 on a real API server: what the lister returns for an
|
|
3
|
+
* ExternalSecret and an Argo CD cluster Secret.
|
|
4
|
+
*
|
|
5
|
+
* On demand only. It needs Docker, k3d and kubectl, creates the scratch
|
|
6
|
+
* cluster `chant-live-read-5116`, and leaves it running (delete it with
|
|
7
|
+
* `k3d cluster delete chant-live-read-5116`, or set CHANT_K3D_DELETE=1 to
|
|
8
|
+
* have the test delete it at the end). Run with:
|
|
9
|
+
*
|
|
10
|
+
* CHANT_K3D_SCRATCH=1 npx vitest run packages/core/src/cloud-lister/kubernetes.k3d.e2e.test.ts
|
|
11
|
+
*
|
|
12
|
+
* The kubeconfig is written to a temp directory and the default kubeconfig
|
|
13
|
+
* is never touched.
|
|
14
|
+
*/
|
|
15
|
+
import { execFileSync } from "node:child_process";
|
|
16
|
+
import { mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
|
17
|
+
import { tmpdir } from "node:os";
|
|
18
|
+
import { join } from "node:path";
|
|
19
|
+
import { describe, expect, it } from "vitest";
|
|
20
|
+
import { listCloud, kubeTargetFromKubeconfig } from "./index";
|
|
21
|
+
import { MASKED, maskKubernetesObject } from "./mask";
|
|
22
|
+
|
|
23
|
+
const CLUSTER = "chant-live-read-5116";
|
|
24
|
+
const enabled = process.env.CHANT_K3D_SCRATCH === "1";
|
|
25
|
+
|
|
26
|
+
const b64 = (s: string) => Buffer.from(s).toString("base64");
|
|
27
|
+
|
|
28
|
+
describe.skipIf(!enabled)("live read of an ExternalSecret and a cluster Secret (scratch k3d)", () => {
|
|
29
|
+
it("shows secretStoreRef, masks the Secret payloads, and the cluster identity follows the switch", async () => {
|
|
30
|
+
const dir = mkdtempSync(join(tmpdir(), "chant-5116-"));
|
|
31
|
+
const kubeconfig = join(dir, "kubeconfig");
|
|
32
|
+
const run = (cmd: string, args: string[], input?: string) =>
|
|
33
|
+
execFileSync(cmd, args, { encoding: "utf8", input, env: { ...process.env, KUBECONFIG: kubeconfig } });
|
|
34
|
+
|
|
35
|
+
const existing = run("k3d", ["cluster", "list", "--no-headers"]);
|
|
36
|
+
if (!existing.split("\n").some((l) => l.startsWith(`${CLUSTER} `))) {
|
|
37
|
+
run("k3d", ["cluster", "create", CLUSTER, "--kubeconfig-update-default=false", "--kubeconfig-switch-context=false", "--wait", "--timeout", "180s"]);
|
|
38
|
+
}
|
|
39
|
+
writeFileSync(kubeconfig, run("k3d", ["kubeconfig", "get", CLUSTER]));
|
|
40
|
+
|
|
41
|
+
const crd = {
|
|
42
|
+
apiVersion: "apiextensions.k8s.io/v1",
|
|
43
|
+
kind: "CustomResourceDefinition",
|
|
44
|
+
metadata: { name: "externalsecrets.external-secrets.io" },
|
|
45
|
+
spec: {
|
|
46
|
+
group: "external-secrets.io",
|
|
47
|
+
scope: "Namespaced",
|
|
48
|
+
names: { kind: "ExternalSecret", plural: "externalsecrets", singular: "externalsecret" },
|
|
49
|
+
versions: [{ name: "v1beta1", served: true, storage: true, schema: { openAPIV3Schema: { type: "object", "x-kubernetes-preserve-unknown-fields": true } } }],
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
run("kubectl", ["apply", "-f", "-"], JSON.stringify(crd));
|
|
53
|
+
run("kubectl", ["wait", "--for=condition=Established", "crd/externalsecrets.external-secrets.io", "--timeout=60s"]);
|
|
54
|
+
run("kubectl", ["apply", "-f", "-"], JSON.stringify({ apiVersion: "v1", kind: "Namespace", metadata: { name: "argocd" } }));
|
|
55
|
+
run(
|
|
56
|
+
"kubectl",
|
|
57
|
+
["apply", "-f", "-"],
|
|
58
|
+
JSON.stringify({
|
|
59
|
+
apiVersion: "external-secrets.io/v1beta1",
|
|
60
|
+
kind: "ExternalSecret",
|
|
61
|
+
metadata: { name: "db", namespace: "argocd" },
|
|
62
|
+
spec: {
|
|
63
|
+
secretStoreRef: { name: "vault", kind: "ClusterSecretStore" },
|
|
64
|
+
target: { name: "db-credentials" },
|
|
65
|
+
data: [{ secretKey: "password", remoteRef: { key: "prod/db", property: "password" } }],
|
|
66
|
+
},
|
|
67
|
+
}),
|
|
68
|
+
);
|
|
69
|
+
run(
|
|
70
|
+
"kubectl",
|
|
71
|
+
["apply", "-f", "-"],
|
|
72
|
+
JSON.stringify({
|
|
73
|
+
apiVersion: "v1",
|
|
74
|
+
kind: "Secret",
|
|
75
|
+
metadata: { name: "cluster-prod", namespace: "argocd", labels: { "argocd.argoproj.io/secret-type": "cluster" } },
|
|
76
|
+
type: "Opaque",
|
|
77
|
+
stringData: { name: "prod", server: "https://prod.example.com", config: '{"bearerToken":"s3cr3t-token"}' },
|
|
78
|
+
}),
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const result = await listCloud(
|
|
82
|
+
{ substrate: "kubernetes", scopeId: CLUSTER, types: ["external-secrets.io/v1beta1/ExternalSecret", "v1/Secret"], locations: ["argocd"] },
|
|
83
|
+
{ substrate: "kubernetes", kubernetes: kubeTargetFromKubeconfig(readFileSync(kubeconfig, "utf8")) },
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const es = result.resources.find((r) => r.listedType === "external-secrets.io/v1beta1/ExternalSecret")!;
|
|
87
|
+
expect((es.properties.spec as Record<string, unknown>).secretStoreRef).toEqual({ name: "vault", kind: "ClusterSecretStore" });
|
|
88
|
+
|
|
89
|
+
const secret = result.resources.find((r) => r.nativeId === "argocd/cluster-prod")!;
|
|
90
|
+
expect(secret.properties.data).toEqual({ name: MASKED, server: MASKED, config: MASKED });
|
|
91
|
+
expect(secret.properties.argoCluster).toBeUndefined();
|
|
92
|
+
expect(JSON.stringify(result)).not.toContain("s3cr3t-token");
|
|
93
|
+
expect(JSON.stringify(result)).not.toContain(b64("s3cr3t-token"));
|
|
94
|
+
|
|
95
|
+
// The same object as the API server serves it, masked with the switch on.
|
|
96
|
+
const raw = JSON.parse(run("kubectl", ["get", "secret", "cluster-prod", "-n", "argocd", "-o", "json"])) as Record<string, unknown>;
|
|
97
|
+
const exposed = maskKubernetesObject(raw, { exposeArgoClusterIdentity: true });
|
|
98
|
+
expect(exposed.argoCluster).toEqual({ name: "prod", server: "https://prod.example.com" });
|
|
99
|
+
expect(exposed.data).toEqual({ name: MASKED, server: MASKED, config: MASKED });
|
|
100
|
+
expect(JSON.stringify(exposed)).not.toContain("s3cr3t-token");
|
|
101
|
+
|
|
102
|
+
if (process.env.CHANT_K3D_DELETE === "1") run("k3d", ["cluster", "delete", CLUSTER]);
|
|
103
|
+
}, 400_000);
|
|
104
|
+
});
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* chant#5116: a reference field (`secretStoreRef`) names an object and is
|
|
3
|
+
* readable; every value that could be a secret stays masked, on both passes
|
|
4
|
+
* (the lister's and the deep observation's normalization).
|
|
5
|
+
*/
|
|
6
|
+
import { describe, expect, it } from "vitest";
|
|
7
|
+
import { MASKED, argoClusterView, maskKubernetesObject, maskValue } from "./mask";
|
|
8
|
+
import { isReferenceField } from "../sensitive-key";
|
|
9
|
+
import { normalizeDeepProperties } from "../deep-observation";
|
|
10
|
+
|
|
11
|
+
const externalSecret = {
|
|
12
|
+
apiVersion: "external-secrets.io/v1beta1",
|
|
13
|
+
kind: "ExternalSecret",
|
|
14
|
+
metadata: { name: "db", namespace: "app" },
|
|
15
|
+
spec: {
|
|
16
|
+
secretStoreRef: { name: "vault", kind: "ClusterSecretStore" },
|
|
17
|
+
target: { name: "db-credentials" },
|
|
18
|
+
data: [{ secretKey: "password", remoteRef: { key: "prod/db", property: "password" } }],
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const b64 = (s: string) => Buffer.from(s).toString("base64");
|
|
23
|
+
|
|
24
|
+
function clusterSecret(extra: Record<string, unknown> = {}) {
|
|
25
|
+
return {
|
|
26
|
+
apiVersion: "v1",
|
|
27
|
+
kind: "Secret",
|
|
28
|
+
metadata: { name: "cluster-prod", namespace: "argocd", labels: { "argocd.argoproj.io/secret-type": "cluster" } },
|
|
29
|
+
type: "Opaque",
|
|
30
|
+
data: { name: b64("prod"), server: b64("https://prod.example.com"), config: b64('{"bearerToken":"s3cr3t-token"}') },
|
|
31
|
+
...extra,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
describe("reference fields", () => {
|
|
36
|
+
it("leaves an ExternalSecret's secretStoreRef readable on the lister's pass", () => {
|
|
37
|
+
const out = maskKubernetesObject(externalSecret) as typeof externalSecret;
|
|
38
|
+
expect(out.spec.secretStoreRef).toEqual({ name: "vault", kind: "ClusterSecretStore" });
|
|
39
|
+
expect(out.spec.target).toEqual({ name: "db-credentials" });
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("leaves it readable on the deep observation's pass too", () => {
|
|
43
|
+
const out = normalizeDeepProperties(maskKubernetesObject(externalSecret), { entityType: "K8s::ExternalSecrets::ExternalSecret", side: "live" }) as { spec: Record<string, unknown> };
|
|
44
|
+
expect(out.spec.secretStoreRef).toEqual({ name: "vault", kind: "ClusterSecretStore" });
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("keeps masking a key that only looks like a reference", () => {
|
|
48
|
+
const out = maskValue({
|
|
49
|
+
secretStoreRef: "hunter2",
|
|
50
|
+
secretRef: { name: "s", key: "token-value" },
|
|
51
|
+
imagePullSecrets: [{ name: "regcred" }, { name: "x", password: "p" }],
|
|
52
|
+
secretKeyRef: { name: "db", key: "password" },
|
|
53
|
+
secretName: "also-a-key-name",
|
|
54
|
+
clientSecret: { name: "x" },
|
|
55
|
+
nested: { secretStoreRef: { name: "v", extra: { deep: "value" } } },
|
|
56
|
+
}) as Record<string, unknown>;
|
|
57
|
+
expect(out.secretStoreRef).toBe(MASKED);
|
|
58
|
+
expect(out.secretRef).toBe(MASKED);
|
|
59
|
+
expect(out.imagePullSecrets).toBe(MASKED);
|
|
60
|
+
expect(out.secretKeyRef).toBe(MASKED);
|
|
61
|
+
expect(out.secretName).toBe(MASKED);
|
|
62
|
+
expect(out.clientSecret).toBe(MASKED);
|
|
63
|
+
expect((out.nested as Record<string, unknown>).secretStoreRef).toBe(MASKED);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("allows a pointer, a list of pointers, and nothing else", () => {
|
|
67
|
+
expect(isReferenceField("secretStoreRef", { name: "a", kind: "SecretStore" })).toBe(true);
|
|
68
|
+
expect(isReferenceField("imagePullSecrets", [{ name: "a" }, { name: "b" }])).toBe(true);
|
|
69
|
+
expect(isReferenceField("imagePullSecrets", [])).toBe(false);
|
|
70
|
+
expect(isReferenceField("secretStoreRef", { name: 1 })).toBe(false);
|
|
71
|
+
expect(isReferenceField("secretStoreRef", {})).toBe(true);
|
|
72
|
+
expect(isReferenceField("secretStoreRef", null)).toBe(false);
|
|
73
|
+
expect(isReferenceField("password", { name: "a" })).toBe(false);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("still masks every Secret data key, and the Secret's annotation copy", () => {
|
|
77
|
+
const out = maskKubernetesObject({
|
|
78
|
+
apiVersion: "v1",
|
|
79
|
+
kind: "Secret",
|
|
80
|
+
metadata: { name: "s", annotations: { "kubectl.kubernetes.io/last-applied-configuration": '{"data":{"secretRef":"x"}}' } },
|
|
81
|
+
data: { secretStoreRef: b64("hunter2"), secretRef: b64("x"), other: b64("y") },
|
|
82
|
+
});
|
|
83
|
+
expect(out.data).toEqual({ secretStoreRef: MASKED, secretRef: MASKED, other: MASKED });
|
|
84
|
+
expect(JSON.stringify(out)).not.toContain(b64("hunter2"));
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
describe("an Argo CD cluster Secret on a live read", () => {
|
|
89
|
+
it("by default (the #5116 ruling) shows name and server as argoCluster, and config stays masked", () => {
|
|
90
|
+
const out = maskKubernetesObject(clusterSecret());
|
|
91
|
+
expect(out.data).toEqual({ name: MASKED, server: MASKED, config: MASKED });
|
|
92
|
+
expect(out.argoCluster).toEqual({ name: "prod", server: "https://prod.example.com" });
|
|
93
|
+
expect(JSON.stringify(out)).not.toContain("s3cr3t-token");
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("with the switch off, is masked whole: no name, no server, no argoCluster view", () => {
|
|
97
|
+
const out = maskKubernetesObject(clusterSecret(), { exposeArgoClusterIdentity: false });
|
|
98
|
+
expect(out.data).toEqual({ name: MASKED, server: MASKED, config: MASKED });
|
|
99
|
+
expect(out.argoCluster).toBeUndefined();
|
|
100
|
+
const text = JSON.stringify(out);
|
|
101
|
+
for (const leaked of [b64("prod"), b64("https://prod.example.com"), "s3cr3t-token", "prod.example.com"]) expect(text).not.toContain(leaked);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("with the switch on, exposes name and server only, and config and every other key stay masked", () => {
|
|
105
|
+
const out = maskKubernetesObject(clusterSecret({ data: { name: b64("prod"), server: b64("https://prod.example.com"), config: b64('{"bearerToken":"s3cr3t-token"}'), caData: b64("PEM") } }), { exposeArgoClusterIdentity: true });
|
|
106
|
+
expect(out.argoCluster).toEqual({ name: "prod", server: "https://prod.example.com" });
|
|
107
|
+
expect(out.data).toEqual({ name: MASKED, server: MASKED, config: MASKED, caData: MASKED });
|
|
108
|
+
const text = JSON.stringify(out);
|
|
109
|
+
expect(text).not.toContain("s3cr3t-token");
|
|
110
|
+
expect(text).not.toContain(b64('{"bearerToken":"s3cr3t-token"}'));
|
|
111
|
+
expect(text).not.toContain("PEM");
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("with the switch on, leaves a server with credentials in its URL out", () => {
|
|
115
|
+
const out = maskKubernetesObject(clusterSecret({ data: { name: b64("prod"), server: b64("https://admin:hunter2@prod.example.com") } }), { exposeArgoClusterIdentity: true });
|
|
116
|
+
expect(out.argoCluster).toEqual({ name: "prod" });
|
|
117
|
+
expect(JSON.stringify(out)).not.toContain("hunter2");
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("with the switch on, is not applied to a Secret without the cluster label or to another kind", () => {
|
|
121
|
+
const plain = clusterSecret({ metadata: { name: "x", labels: { app: "y" } } });
|
|
122
|
+
expect(maskKubernetesObject(plain, { exposeArgoClusterIdentity: true }).argoCluster).toBeUndefined();
|
|
123
|
+
expect(argoClusterView({ ...clusterSecret(), kind: "ConfigMap" })).toBeUndefined();
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("survives the deep observation's pass with config still masked", () => {
|
|
127
|
+
const masked = maskKubernetesObject(clusterSecret(), { exposeArgoClusterIdentity: true });
|
|
128
|
+
const out = normalizeDeepProperties(masked, { entityType: "K8s::Core::Secret", side: "live" }) as Record<string, unknown>;
|
|
129
|
+
expect(out.argoCluster).toEqual({ name: "prod", server: "https://prod.example.com" });
|
|
130
|
+
expect(JSON.stringify(out)).not.toContain("s3cr3t-token");
|
|
131
|
+
});
|
|
132
|
+
});
|
package/src/cloud-lister/mask.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* - any tag or label whose key matches the patterns.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { isSensitiveKey, SENSITIVE_KEY_PATTERNS } from "../sensitive-key";
|
|
18
|
+
import { isReferenceField, isSensitiveKey, SENSITIVE_KEY_PATTERNS } from "../sensitive-key";
|
|
19
19
|
|
|
20
20
|
export { isSensitiveKey, SENSITIVE_KEY_PATTERNS };
|
|
21
21
|
|
|
@@ -34,7 +34,7 @@ export function maskValue(value: unknown): unknown {
|
|
|
34
34
|
const pairKey = typeof obj.Key === "string" ? obj.Key : typeof obj.key === "string" ? obj.key : undefined;
|
|
35
35
|
const out: Record<string, unknown> = {};
|
|
36
36
|
for (const [k, v] of Object.entries(obj)) {
|
|
37
|
-
if (isSensitiveKey(k)) {
|
|
37
|
+
if (isSensitiveKey(k) && !isReferenceField(k, v)) {
|
|
38
38
|
out[k] = MASKED;
|
|
39
39
|
} else if (pairKey !== undefined && isSensitiveKey(pairKey) && (k === "Value" || k === "value")) {
|
|
40
40
|
out[k] = MASKED;
|
|
@@ -57,8 +57,69 @@ export function maskTags(tags: Record<string, string>): Record<string, string> {
|
|
|
57
57
|
|
|
58
58
|
const LAST_APPLIED = "kubectl.kubernetes.io/last-applied-configuration";
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* The maintainer's ruling on chant#5116, as a switch. An Argo CD cluster
|
|
62
|
+
* Secret (label `argocd.argoproj.io/secret-type: cluster`) keeps its `name`
|
|
63
|
+
* and `server` in `data` beside `config`, which holds credentials.
|
|
64
|
+
*
|
|
65
|
+
* - `false` (the default): the whole payload is masked, `name` and `server`
|
|
66
|
+
* included. A live read cannot join an Application to a cluster by name or
|
|
67
|
+
* server, and `argoCluster` is never emitted.
|
|
68
|
+
* - `true`: the payload stays masked key by key, and the object gains an
|
|
69
|
+
* `argoCluster: { name, server }` view with those two values decoded.
|
|
70
|
+
* `config` and every other `data` key stay masked. A `server` that carries
|
|
71
|
+
* a user name or password in its URL is left out.
|
|
72
|
+
*
|
|
73
|
+
* Ruled `true` by the maintainer on 2026-11-15 (#5116): a cluster's name and
|
|
74
|
+
* API server address are identifiers, as in any kubeconfig, not credentials,
|
|
75
|
+
* and the live read needs them to join an Application to its cluster as the
|
|
76
|
+
* files read does (#5101). Tests pass the option explicitly, so they hold
|
|
77
|
+
* whichever way it is set.
|
|
78
|
+
*/
|
|
79
|
+
export const EXPOSE_ARGO_CLUSTER_IDENTITY = true;
|
|
80
|
+
|
|
81
|
+
const ARGO_CLUSTER_LABEL = "argocd.argoproj.io/secret-type";
|
|
82
|
+
|
|
83
|
+
export interface MaskKubernetesOptions {
|
|
84
|
+
/** Overrides {@link EXPOSE_ARGO_CLUSTER_IDENTITY}. */
|
|
85
|
+
exposeArgoClusterIdentity?: boolean;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function isArgoClusterSecret(obj: Record<string, unknown>): boolean {
|
|
89
|
+
if (obj.kind !== "Secret") return false;
|
|
90
|
+
const labels = (obj.metadata as { labels?: Record<string, unknown> } | undefined)?.labels;
|
|
91
|
+
return labels?.[ARGO_CLUSTER_LABEL] === "cluster";
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** One field of a Secret's `stringData` (plain) or `data` (base64), as text. */
|
|
95
|
+
function secretText(obj: Record<string, unknown>, key: string): string | undefined {
|
|
96
|
+
const plain = (obj.stringData as Record<string, unknown> | undefined)?.[key];
|
|
97
|
+
if (typeof plain === "string") return plain;
|
|
98
|
+
const encoded = (obj.data as Record<string, unknown> | undefined)?.[key];
|
|
99
|
+
if (typeof encoded !== "string") return undefined;
|
|
100
|
+
return Buffer.from(encoded, "base64").toString("utf8");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** The `argoCluster` view of a cluster Secret: its name and server, never `config`. */
|
|
104
|
+
export function argoClusterView(obj: Record<string, unknown>): { name?: string; server?: string } | undefined {
|
|
105
|
+
if (!isArgoClusterSecret(obj)) return undefined;
|
|
106
|
+
const view: { name?: string; server?: string } = {};
|
|
107
|
+
const name = secretText(obj, "name");
|
|
108
|
+
if (name && !/[\u0000-\u001f]/.test(name)) view.name = name;
|
|
109
|
+
const server = secretText(obj, "server");
|
|
110
|
+
if (server) {
|
|
111
|
+
try {
|
|
112
|
+
const url = new URL(server);
|
|
113
|
+
if (!url.username && !url.password) view.server = server;
|
|
114
|
+
} catch {
|
|
115
|
+
// not a URL: left out
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return view;
|
|
119
|
+
}
|
|
120
|
+
|
|
60
121
|
/** A Kubernetes object, masked: key names everywhere, and a Secret's payload whole. */
|
|
61
|
-
export function maskKubernetesObject(obj: Record<string, unknown
|
|
122
|
+
export function maskKubernetesObject(obj: Record<string, unknown>, options: MaskKubernetesOptions = {}): Record<string, unknown> {
|
|
62
123
|
const masked = maskProperties(obj);
|
|
63
124
|
if (obj.kind === "Secret") {
|
|
64
125
|
for (const field of ["data", "stringData"]) {
|
|
@@ -73,5 +134,9 @@ export function maskKubernetesObject(obj: Record<string, unknown>): Record<strin
|
|
|
73
134
|
if (annotations && LAST_APPLIED in annotations && obj.kind === "Secret") {
|
|
74
135
|
annotations[LAST_APPLIED] = MASKED;
|
|
75
136
|
}
|
|
137
|
+
if (options.exposeArgoClusterIdentity ?? EXPOSE_ARGO_CLUSTER_IDENTITY) {
|
|
138
|
+
const view = argoClusterView(obj);
|
|
139
|
+
if (view) masked.argoCluster = view;
|
|
140
|
+
}
|
|
76
141
|
return masked;
|
|
77
142
|
}
|
package/src/components/driver.ts
CHANGED
|
@@ -51,7 +51,7 @@ import { isLockRowsHeldError, leaseCapabilityStep, type RowLease, type RowLeaseP
|
|
|
51
51
|
import { topoSort } from "../codegen/topo-sort";
|
|
52
52
|
import { CHANT_EXIT } from "../exit-codes";
|
|
53
53
|
import { kahnLayers } from "./layers";
|
|
54
|
-
import { evaluateGate, gitGateLedgerPort, type GateDigestMismatch, type GateLedgerPort } from "../op/gate";
|
|
54
|
+
import { evaluateGate, gitGateLedgerPort, type GateDigestMismatch, type GateLedgerPort, type WorkspaceGateStandIn } from "../op/gate";
|
|
55
55
|
import { gateName } from "../op/gate-name";
|
|
56
56
|
import { GateNotRecordableError } from "../lifecycle/no-record";
|
|
57
57
|
import { componentPlanDigest } from "./gate-plan";
|
|
@@ -577,6 +577,13 @@ export interface ReleaseGateBinding {
|
|
|
577
577
|
releaseDigest: string;
|
|
578
578
|
/** Reads the document stored under a digest and says whether it is empty (`evaluateGate`'s `verifyEmpty`). */
|
|
579
579
|
verifyEmpty?: (planDigest: string) => Promise<boolean>;
|
|
580
|
+
/**
|
|
581
|
+
* The workspace gate a release train's promote started this run under
|
|
582
|
+
* (#4037, ws-039): it stands in for the release gate only when its approval
|
|
583
|
+
* covers this member's gate, change set, environment and release, and the
|
|
584
|
+
* member opts in at base.
|
|
585
|
+
*/
|
|
586
|
+
workspace?: WorkspaceGateStandIn;
|
|
580
587
|
}
|
|
581
588
|
|
|
582
589
|
/** Run a single capability step. Never throws for a capability-run failure; returns a fail record instead. */
|
|
@@ -689,6 +696,7 @@ async function runPhase(
|
|
|
689
696
|
// #4551: a release gate's plan digest is its change set's, so the fact cites it.
|
|
690
697
|
...(gates.releaseGate && gates.planDigest !== undefined ? { fields: { changeSet: gates.planDigest } } : {}),
|
|
691
698
|
...(gates.releaseGate?.verifyEmpty ? { verifyEmpty: gates.releaseGate.verifyEmpty } : {}),
|
|
699
|
+
...(gates.releaseGate?.workspace ? { workspace: gates.releaseGate.workspace } : {}),
|
|
692
700
|
...(gate.description ? { description: gate.description } : {}),
|
|
693
701
|
...(gate.timeout ? { timeout: gate.timeout } : {}),
|
|
694
702
|
...(gates.now ? { now: gates.now } : {}),
|