@intentius/chant 0.124.96 → 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/change-set-graph.d.ts +3 -1
- package/dist/change-set-graph.d.ts.map +1 -1
- package/dist/change-set-graph.js +7 -1
- package/dist/change-set.d.ts +5 -2
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +6 -3
- 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 +7 -1
- 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/reconcile.d.ts +9 -0
- package/dist/reconcile.d.ts.map +1 -1
- package/dist/release-floors.d.ts +9 -1
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +10 -2
- 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/change-set-graph.test.ts +33 -1
- package/src/change-set-graph.ts +7 -1
- package/src/change-set.ts +6 -3
- 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-before-merge.test.ts +18 -0
- 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 +7 -1
- 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/reconcile.ts +9 -0
- package/src/release-floors.ts +14 -2
- 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/drift-reader.test.ts +3 -3
- 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
package/src/floor-table.data.ts
CHANGED
|
@@ -84,6 +84,7 @@ export const FLOOR_ROWS: readonly FloorRow[] = [
|
|
|
84
84
|
{ name: "NORMALIZED_INPUTS_FLOOR", version: "0.124.68", gates: "The first chant that reads `inputs.normalize` and writes `normalizedInputs` on a skip record (#4718).", issue: "#4718", file: "components/unchanged-inputs.ts", modules: ["@intentius/chant/components/unchanged-inputs"] },
|
|
85
85
|
{ name: "CONTROL_CONSUMERS_FLOOR", version: "0.124.55", gates: "The first chant with the consumers join, joinControlConsumers and readControlConsumers on `@intentius/chant/ci-control` (#4600).", issue: "#4600", file: "control/consumers.ts", modules: ["@intentius/chant/ci-control","@intentius/chant/control/consumers"] },
|
|
86
86
|
{ name: "CONTROL_DEPENDENTS_FLOOR", version: "0.124.47", gates: "The first chant with `chant workspace run --dependents-of`, which the control repo's package.json pins.", file: "control/dispatch.ts", modules: ["@intentius/chant/ci-control","@intentius/chant/control/dispatch"] },
|
|
87
|
+
{ name: "CONTROL_TRAIN_FLOOR", version: NEXT_RELEASE, gates: "The first chant with release trains across repositories (#5119).", issue: "#5119", file: "control/train.ts", modules: ["@intentius/chant/ci-control","@intentius/chant/control/train"] },
|
|
87
88
|
{ name: "E2E_HARNESS_FLOOR", version: "0.124.56", gates: "The first chant with the e2e harness.", file: "e2e-harness/index.ts", modules: ["@intentius/chant/e2e-harness","@intentius/chant/e2e-harness/index"] },
|
|
88
89
|
{ name: "E2E_HARNESS_PULL_STEPS_FLOOR", version: "0.124.58", gates: "The first chant whose harness follows a pull request a product opened (chant#4650): the await-pull and comment steps, the pull and gated outcomes, and the forge reads under them.", issue: "#4650", file: "e2e-harness/index.ts", modules: ["@intentius/chant/e2e-harness","@intentius/chant/e2e-harness/index"] },
|
|
89
90
|
{ name: "ENGINE_FACTS_FLOOR", version: "0.124.54", gates: "The first chant whose graph carries `nodes[].facts` and `edges[].grain` (#4527, #4529, #4528): a live read through an engine (the terraform lexicon's read of `choudoufu live-graph -json -from-plan`, which writes `ResourceMetadata.facts` and the observation's `edges`), and a plunge member's checked-in `engine-graph.json` in the pulumi lexicon's member read.", issue: "#4527", file: "engine-facts.ts", modules: ["@intentius/chant","@intentius/chant/engine-facts","@intentius/chant/index"] },
|
|
@@ -243,9 +244,13 @@ export const FLOOR_ROWS: readonly FloorRow[] = [
|
|
|
243
244
|
{ name: "OP_WAVES_REMAINDER_PARITY_FLOOR", version: "0.124.94", gates: "The first chant whose `approvals.remainder` resumes the waves terragucci's own records resume (#5056): the terraform step gives a live choudoufu root's plan (`live-plan-set`) its `resourceDigests`, so its applied line names the changes, and the cover leaves out the cost member `(monthly cost)`, whose digest follows from the plans, on both sides.", issue: "#5056", file: "release-floors.ts", modules: ["@intentius/chant/ci-product","@intentius/chant/op/op-waves-remainder","@intentius/chant/release-floors"] },
|
|
244
245
|
{ name: "OP_WAVES_CONTROL_BEFORE_MERGE_FLOOR", version: "0.124.95", gates: "The first chant whose Op waves generators, in a product's workflow (`runIf`) with `beforeMerge` and a spec `control`, run the control job on the default branch's push, outside the product's `runIf` and after its `firstWaveNeeds` jobs, and tell the control repo the waves applied at the pushed commit without adding up outcomes, on GitHub, Forgejo and GitLab (#5060).", issue: "#5060", file: "release-floors.ts", modules: ["@intentius/chant/release-floors"] },
|
|
245
246
|
{ name: "WAVES_BEFORE_MERGE_LOCKS_FLOOR", version: "0.124.95", gates: "The first chant whose waves before merge lock and unlock on a comment by the product plan's reach line (#5061): with `wavesBeforeMerge` and `productPlan.reach`, and no `locks: \"plan\"`, the comment job (GitHub, Forgejo) and the note poll (GitLab, `chantNoteRuns`) answer `/<product> lock` on an open pull request by taking the locks of what the reach line prints at stage `apply` in `_locks/<reach.gate>.json` without applying (`decideLocksBeforeMerge`), refused with the holder named, and `/<product> unlock` by releasing the pull request's locks; and the product plan takes `reach` without `locks: \"plan\"` under `wavesBeforeMerge`, writing no reach lock job.", issue: "#5061", file: "release-floors.ts", modules: ["@intentius/chant/ci-product","@intentius/chant/release-floors"] },
|
|
246
|
-
{ name: "KIND_DRIFT_READER_FLOOR", version:
|
|
247
|
+
{ name: "KIND_DRIFT_READER_FLOOR", version: "0.124.96", gates: "The first chant whose kinds file takes `drift: { reader, config }` beside `graph` and whose `chant workspace drift --member` reads a member of such a kind with that module, `(input: { dir, config, member, observedAt, read?, resource?, stack? }) => DriftReaderOutput` from `@intentius/chant/workspace/drift-reader`, checked against `drift-reader.schema.json` (#5068).", issue: "#5068", file: "release-floors.ts", modules: ["@intentius/chant/release-floors"] },
|
|
248
|
+
{ name: "WORKSPACE_GRAPH_CATALOG_FLOOR", version: NEXT_RELEASE, gates: "The first chant whose `chant workspace graph` runs each lexicon's reference catalog over the composed declared graph, across members, on full attributes at every `--detail` (#5097): derived edges in `edges` with `origin: \"derived\"`, `rule` and `relation`, references to no node in `dangling` with their `rule` and `targetKind`, references to several nodes in `ambiguous` with every candidate, and `catalog` naming the lexicons and members read, each rule named, and per node the arguments not read because not literal; a catalog path takes a quoted key, `metadata.annotations[\"iam.gke.io/gcp-service-account\"]`; and a catalog takes `scopes` and `declaredNode`.", issue: "#5097", file: "release-floors.ts", modules: ["@intentius/chant/release-floors"] },
|
|
249
|
+
{ name: "WORKSPACE_GRAPH_CLUSTER_JOIN_FLOOR", version: NEXT_RELEASE, gates: "The first chant whose reference catalogs join an Argo CD cluster Secret to the cluster resource (#5101): an Application's `spec.destination.name` and `spec.destination.server` to the Secret whose `name` and `server` match, and the Secret's `name` (base64 `data` decoded) to a `google_container_cluster`, `aws_eks_cluster` or `azurerm_kubernetes_cluster` of that literal name, with a reference no rule of its id matched listed once in `dangling`; a member of kind `argo-app` or `manifests` reads a cluster Secret cut down to its `name` and `server`; and a workspace member entry takes `runsOn`, `<member>/<address>`, with `chant workspace graph --discover --runs-on <member>=<member>/<address>`, which draws a declared edge from each of the member's cluster Secrets to that node.", issue: "#5101", file: "release-floors.ts", modules: ["@intentius/chant/release-floors"] },
|
|
250
|
+
{ name: "WORKSPACE_GRAPH_APPLICATION_SET_FLOOR", version: NEXT_RELEASE, gates: "The first chant whose `chant workspace graph` expands an Argo CD ApplicationSet's `list` and `clusters` generators (#5102): one node per generated Application, with `generatedBy` naming the ApplicationSet, the rule, the generator, the parameters and the cluster Secret it was made for, a derived edge from the ApplicationSet to it under `k8s:K8s::Argo::ApplicationSet:spec.generators` and from it to the cluster Secret a clusters generator selected under `k8s:K8s::Argo::ApplicationSet:generators[].clusters`, and `expansion` on the ApplicationSet with the count and what was not expanded; and whose catalogs read an Application's `spec.source.path`, `spec.sources[].path` and `helm.valueFiles`, listing a path the workspace's own repository does not have in `dangling`, with `through` and `cluster` on a generated one.", issue: "#5102", file: "release-floors.ts", modules: ["@intentius/chant/release-floors"] },
|
|
247
251
|
{ name: "GITLAB_WAVE_EVIDENCE_RETRY_FLOOR", version: "0.124.89", gates: "The first chant whose `chant run resume` (`resumeGateRun`) on GitLab retries a wave job's `<wave job>-evidence` with the wave job when the evidence job already ran, and whose `ci evidence sign --from-job` waits for a job it reads to finish, so a resumed wave's evidence job signs from the new try (#4978).", issue: "#4978", file: "release-floors.ts", modules: ["@intentius/chant/ci-evidence-jobs","@intentius/chant/release-floors"] },
|
|
248
252
|
{ name: "TERRAFORM_COMMAND_TRACE_FLOOR", version: "0.124.91", gates: "The first chant whose terraform lexicon's engine runs carry what a product's own command tracing read: `runBinary` and the engine runner's `exec` and `execSync` answer stderr apart (`Ran.stderr`) and a spawn failure's message (`Ran.error`), a hook's `after` gets a binary that could not be started as a null code with `error`, `commandTrace` ends that span with the message, and `composeCommandHooks` runs a product's own hook and `commandTrace` as one `onCommand` (#5007).", issue: "#5007", file: "release-floors.ts", modules: ["@intentius/chant/release-floors"] },
|
|
253
|
+
{ name: "COMMENT_ALLOW_FLOOR", version: NEXT_RELEASE, gates: "The first chant whose product pipeline limits comment commands to logins and teams on GitHub and Forgejo (INTENTIUS/terragucci#1461): `commentAllow: { allow, tokenSecret? }` in `productPipelineJobs`, where `allow` maps `plan`, `apply`, `lock`, `unlock`, `agent` and `default` to logins and `team:<org>/<team>` entries.", issue: "#1461", file: "release-floors.ts", modules: ["@intentius/chant/ci-product","@intentius/chant/release-floors"] },
|
|
249
254
|
{ name: "RUN_EVENT_FLOOR", version: "0.124.28", gates: "The first chant that writes contract version 1 of the run-event stream.", file: "run-event.ts", modules: ["@intentius/chant","@intentius/chant/index","@intentius/chant/run-event"] },
|
|
250
255
|
{ name: "RUN_EVENT_FAILURE_FLOOR", version: "0.124.30", gates: "The first chant that writes `failure` on `run-settle` (#4094).", issue: "#4094", file: "run-event.ts", modules: ["@intentius/chant","@intentius/chant/index","@intentius/chant/run-event"] },
|
|
251
256
|
{ name: "RUN_EVENT_COMPONENT_SKIP_FLOOR", version: "0.124.29", gates: "The first chant that writes `blocked`, `already-applied` and `blockedBy` on `component-settle` (#4007).", issue: "#4007", file: "run-event.ts", modules: ["@intentius/chant","@intentius/chant/index","@intentius/chant/run-event"] },
|
|
@@ -269,6 +274,7 @@ export const FLOOR_ROWS: readonly FloorRow[] = [
|
|
|
269
274
|
{ name: "READ_CONTRACT_FLOOR", version: "0.81.0", gates: "The first chant release that writes contract version 1.", file: "workspace/reason-codes.ts", modules: ["@intentius/chant/workspace/reason-codes"] },
|
|
270
275
|
{ name: "RELEASE_CANDIDATES_CLOSES_FLOOR", version: "0.124.63", gates: "The first chant whose candidates carry `changes[].closes` and `groups[].issue` (#4649).", issue: "#4649", file: "workspace/release-candidates.ts", modules: ["@intentius/chant/workspace/release-candidates"] },
|
|
271
276
|
{ name: "RELEASE_CANDIDATES_LANE_FLOOR", version: "0.124.64", gates: "The first chant whose candidates document carries `lane` and reads a lane's tags (#4692).", issue: "#4692", file: "workspace/release-candidates.ts", modules: ["@intentius/chant/workspace/release-candidates"] },
|
|
277
|
+
{ name: "TRAIN_PROMOTE_FLOOR", version: NEXT_RELEASE, gates: "The first chant that writes ReleaseTrainRecord.trainDigest and has `chant workspace train promote` (#4037).", issue: "#4037", file: "workspace/release-train.ts", modules: ["@intentius/chant/workspace/release-train"] },
|
|
272
278
|
{ name: "MODULE_CONSUMERS_FLOOR", version: "0.124.55", gates: "The first chant whose terraform lexicon has `moduleConsumers`, the scan of every registry module call a root makes, with `readRegistryCatalog` and `deprecatedPins` beside it on `./registry` (#4599).", issue: "#4599", file: "lexicons/terraform/src/chant-floors.ts", modules: ["@intentius/chant-lexicon-terraform/chant-floors","@intentius/chant-lexicon-terraform/registry","@intentius/chant-lexicon-terraform/registry/index"] },
|
|
273
279
|
{ name: "USED_SOURCES_FLOOR", version: "0.124.55", gates: "The first chant whose terraform lexicon has `usedSources`, every module source and provider address a root uses, with `moduleSourceForms`, `providerAddressForms` and `lockedProviders` on `./registry` (#3924).", issue: "#3924", file: "lexicons/terraform/src/chant-floors.ts", modules: ["@intentius/chant-lexicon-terraform/chant-floors","@intentius/chant-lexicon-terraform/registry","@intentius/chant-lexicon-terraform/registry/index"] },
|
|
274
280
|
{ name: "MODULE_CATALOG_FLOOR", version: "0.124.55", gates: "The first chant whose terraform lexicon has `./module-catalog`, the known-module catalog TF047 reads (#4560).", issue: "#4560", file: "lexicons/terraform/src/chant-floors.ts", modules: ["@intentius/chant-lexicon-terraform/chant-floors","@intentius/chant-lexicon-terraform/module-catalog","@intentius/chant-lexicon-terraform/module-catalog/index"] },
|
package/src/graph-detail.ts
CHANGED
|
@@ -119,6 +119,12 @@ function toStacks(ir: GraphIR): GraphIR {
|
|
|
119
119
|
return { nodes, edges: sortEdges([...seen.values()]), groups: {} };
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
/** A node's attrs as a tier prints them: all of them at T3, the resource view at T2, overlay paint below. */
|
|
123
|
+
export function nodeAttrsAt(attrs: Record<string, unknown>, level: DetailLevel): Record<string, unknown> {
|
|
124
|
+
if (level === 3) return attrs;
|
|
125
|
+
return level === 2 ? resourceAttrs(attrs) : paintAttrs(attrs);
|
|
126
|
+
}
|
|
127
|
+
|
|
122
128
|
/** T2 — every resource, each carrying the resource view of its attrs (the
|
|
123
129
|
* scalar/reference projection; the full property tree is T3's addition). */
|
|
124
130
|
function toDeclarables(ir: GraphIR): GraphIR {
|
|
@@ -153,25 +159,24 @@ function rollupStatus(members: IRNode[]): Record<string, unknown> {
|
|
|
153
159
|
return { _status: worst, ...(Object.keys(notGood).length > 0 ? { _memberStatus: notGood } : {}) };
|
|
154
160
|
}
|
|
155
161
|
|
|
156
|
-
/**
|
|
157
|
-
*
|
|
158
|
-
|
|
162
|
+
/**
|
|
163
|
+
* The composite instances of a graph, and the node each node is drawn as at
|
|
164
|
+
* T1: a member of an instance is drawn as the instance, any other node as
|
|
165
|
+
* itself.
|
|
166
|
+
*/
|
|
167
|
+
function compositeCollapse(ir: GraphIR): { instances: Map<string, IRNode[]>; collapsedId: Map<string, string>; idMap: Map<string, string> } {
|
|
159
168
|
// A composite instance is its export name plus the composite that made it:
|
|
160
169
|
// an AWS FargateAlb and a GCP CloudRunServiceComposite both exported as
|
|
161
170
|
// `web` are two instances (#4178). One composite whose members span
|
|
162
171
|
// lexicons stays one instance.
|
|
163
172
|
const instanceKey = (n: IRNode) => `${n.compositeInstance}\0${n.compositeParent ?? ""}`;
|
|
164
173
|
const instances = new Map<string, IRNode[]>();
|
|
165
|
-
const plain: IRNode[] = [];
|
|
166
174
|
for (const n of ir.nodes) {
|
|
167
|
-
if (n.compositeInstance)
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
} else {
|
|
173
|
-
plain.push({ ...n, attrs: paintAttrs(n.attrs) });
|
|
174
|
-
}
|
|
175
|
+
if (!n.compositeInstance) continue;
|
|
176
|
+
const key = instanceKey(n);
|
|
177
|
+
const arr = instances.get(key) ?? [];
|
|
178
|
+
arr.push(n);
|
|
179
|
+
instances.set(key, arr);
|
|
175
180
|
}
|
|
176
181
|
|
|
177
182
|
// The collapsed id is the instance name, or `<instance>@<composite>` when
|
|
@@ -189,6 +194,26 @@ function toComposites(ir: GraphIR): GraphIR {
|
|
|
189
194
|
|
|
190
195
|
const idMap = new Map<string, string>();
|
|
191
196
|
for (const n of ir.nodes) idMap.set(n.id, n.compositeInstance ? collapsedId.get(instanceKey(n))! : n.id);
|
|
197
|
+
return { instances, collapsedId, idMap };
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* The node each node of the base IR is drawn as at a detail tier (#5097): at
|
|
202
|
+
* T0 its lexicon's stack node, at T1 the composite instance it belongs to,
|
|
203
|
+
* and itself at T2 and T3. A reader that derives edges from the base IR maps
|
|
204
|
+
* them through this to put them on the tier's nodes.
|
|
205
|
+
*/
|
|
206
|
+
export function detailIdMap(ir: GraphIR, level: DetailLevel): Map<string, string> {
|
|
207
|
+
if (level === 0) return new Map(ir.nodes.map((n) => [n.id, n.lexicon]));
|
|
208
|
+
if (level === 1) return compositeCollapse(ir).idMap;
|
|
209
|
+
return new Map(ir.nodes.map((n) => [n.id, n.id]));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** T1 — collapse each composite instance to one node; internal edges disappear.
|
|
213
|
+
* Topology view: surviving plain nodes keep only overlay paint, not properties. */
|
|
214
|
+
function toComposites(ir: GraphIR): GraphIR {
|
|
215
|
+
const { instances, collapsedId, idMap } = compositeCollapse(ir);
|
|
216
|
+
const plain: IRNode[] = ir.nodes.filter((n) => !n.compositeInstance).map((n) => ({ ...n, attrs: paintAttrs(n.attrs) }));
|
|
192
217
|
|
|
193
218
|
const nodes: IRNode[] = [...plain];
|
|
194
219
|
for (const [key, members] of instances) {
|
package/src/graph-refs.test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { reconstructEdges, readPath, mergeCatalogs, containmentGroups, type ReferenceCatalog } from "./graph-refs";
|
|
2
|
+
import { reconstructEdges, reconstructIndexedEdges, readPath, parsePath, mergeCatalogs, containmentGroups, type ReferenceCatalog } from "./graph-refs";
|
|
3
3
|
import type { IRNode } from "./graph-ir";
|
|
4
4
|
|
|
5
5
|
const node = (id: string, kind: string, attrs: Record<string, unknown>, physicalId?: string): IRNode => ({
|
|
@@ -11,6 +11,26 @@ const node = (id: string, kind: string, attrs: Record<string, unknown>, physical
|
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
describe("readPath", () => {
|
|
14
|
+
it("reads a quoted key that holds dots and a slash (#5097)", () => {
|
|
15
|
+
const sa = { metadata: { annotations: { "iam.gke.io/gcp-service-account": "x", iam: { "gke.io/gcp-service-account": "wrong" } } } };
|
|
16
|
+
expect(readPath(sa, 'metadata.annotations["iam.gke.io/gcp-service-account"]')).toEqual(["x"]);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("fans a quoted key out over a list, and escapes a quote as JSON does", () => {
|
|
20
|
+
expect(readPath({ m: { "a.b": [{ id: "1" }, { id: "2" }] } }, 'm["a.b"][].id')).toEqual(["1", "2"]);
|
|
21
|
+
expect(readPath({ 'say "hi"': "y" }, '["say \\"hi\\""]')).toEqual(["y"]);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("parses steps, and keeps a bracket that opens no quoted key as part of the key", () => {
|
|
25
|
+
expect(parsePath('a.b[]["c.d"].e')).toEqual([
|
|
26
|
+
{ key: "a", fanOut: false },
|
|
27
|
+
{ key: "b", fanOut: true },
|
|
28
|
+
{ key: "c.d", fanOut: false },
|
|
29
|
+
{ key: "e", fanOut: false },
|
|
30
|
+
]);
|
|
31
|
+
expect(parsePath('a["open')).toEqual([{ key: 'a["open', fanOut: false }]);
|
|
32
|
+
});
|
|
33
|
+
|
|
14
34
|
it("reads nested keys", () => {
|
|
15
35
|
expect(readPath({ a: { b: "x" } }, "a.b")).toEqual(["x"]);
|
|
16
36
|
});
|
|
@@ -244,3 +264,27 @@ describe("containment is traversable without being drawn", () => {
|
|
|
244
264
|
expect(containmentEdges.some((e) => e.to === "sub-2")).toBe(false);
|
|
245
265
|
});
|
|
246
266
|
});
|
|
267
|
+
|
|
268
|
+
describe("rules that share an id (#5101)", () => {
|
|
269
|
+
const catalog: ReferenceCatalog = {
|
|
270
|
+
identities: [],
|
|
271
|
+
refs: ["a_cluster", "b_cluster"].map((targetKind) => ({ from: "holder", path: "cluster", targetKind, relation: "reference" as const })),
|
|
272
|
+
};
|
|
273
|
+
const nodes = (...kinds: string[]): IRNode[] => [
|
|
274
|
+
{ id: "h", kind: "holder", lexicon: "x", attrs: { cluster: "prod" } },
|
|
275
|
+
...kinds.map((kind, i) => ({ id: `t${i}`, kind, lexicon: "x", attrs: {}, nativeId: "prod" })),
|
|
276
|
+
];
|
|
277
|
+
const run = (n: IRNode[]) => reconstructIndexedEdges(n, [{ lexicon: "x", catalog }], () => ({ account: "w" }));
|
|
278
|
+
|
|
279
|
+
it("do not report a value dangling under the kinds that found nothing when another kind found it", () => {
|
|
280
|
+
const out = run(nodes("b_cluster"));
|
|
281
|
+
expect(out.edges.map((e) => e.to)).toEqual(["t0"]);
|
|
282
|
+
expect(out.dangling).toEqual([]);
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
it("report it once when no kind found it, and not as an edge", () => {
|
|
286
|
+
const out = run(nodes("c_cluster"));
|
|
287
|
+
expect(out.edges).toEqual([]);
|
|
288
|
+
expect(out.dangling).toHaveLength(1);
|
|
289
|
+
});
|
|
290
|
+
});
|
package/src/graph-refs.ts
CHANGED
|
@@ -77,6 +77,43 @@ export interface RefRule {
|
|
|
77
77
|
* reference and drawing the line twice.
|
|
78
78
|
*/
|
|
79
79
|
viaAttr?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Reads the references itself, for a rule whose value does not name its
|
|
82
|
+
* target by one identifier (#5098): an ExternalSecret's key names a cloud
|
|
83
|
+
* secret only inside the project of the store it reads through, so the
|
|
84
|
+
* match spans the holder, a second node and the target. `path` and
|
|
85
|
+
* `targetKind` still name the rule (its id, its entry in a document's
|
|
86
|
+
* `catalog.rules`, the kind a dangling entry looks for), but the pass does
|
|
87
|
+
* not read `path` itself: it calls `join` with the holder and `find`, which
|
|
88
|
+
* returns the nodes a value names from the holder's scope, the way the
|
|
89
|
+
* pass's own lookup would. Each {@link JoinedRef} it returns is then
|
|
90
|
+
* resolved like a value read from `path`: no target is dangling (unless
|
|
91
|
+
* `optional`), two are ambiguous, one is an edge. Only the catalog pass
|
|
92
|
+
* over indexed nodes and declared graphs calls it. Pure.
|
|
93
|
+
*/
|
|
94
|
+
join?(holder: IRNode, find: FindNodes): JoinedRef[];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* What a {@link RefRule.join} looks nodes up with. `find(value)` returns the
|
|
99
|
+
* nodes `value` names from the holder's own scope. `find(value, scope)`
|
|
100
|
+
* returns those named inside the scope called `scope` (a Kubernetes
|
|
101
|
+
* namespace), whatever scope the holder sits in, for a holder that names its
|
|
102
|
+
* target's namespace itself (#5099): a cloud IAM binding naming
|
|
103
|
+
* `<ns>/<name>`.
|
|
104
|
+
*/
|
|
105
|
+
export type FindNodes = (value: string, scope?: string) => readonly IRNode[];
|
|
106
|
+
|
|
107
|
+
/** One reference a {@link RefRule.join} found on a holder. */
|
|
108
|
+
export interface JoinedRef {
|
|
109
|
+
/** What the holder wrote, as a dangling or ambiguous entry reports it. */
|
|
110
|
+
value: string;
|
|
111
|
+
/** The nodes it names, from `find`; none is dangling. */
|
|
112
|
+
targets: readonly IRNode[];
|
|
113
|
+
/** The edge's `viaAttr`, when the first step of the rule's path does not say enough. */
|
|
114
|
+
via?: string;
|
|
115
|
+
/** A node the value was read through, named on a dangling entry (the store a key is read from). */
|
|
116
|
+
through?: IRNode;
|
|
80
117
|
}
|
|
81
118
|
|
|
82
119
|
/**
|
|
@@ -96,12 +133,182 @@ export interface TagRefRule {
|
|
|
96
133
|
label?: string;
|
|
97
134
|
}
|
|
98
135
|
|
|
136
|
+
/**
|
|
137
|
+
* A kind whose names are unique only inside a scope the node names itself
|
|
138
|
+
* (#5097): a namespaced Kubernetes kind, whose scope is the value at
|
|
139
|
+
* `metadata.namespace`. Read on a declared graph, where nothing else says
|
|
140
|
+
* where a node sits. Over an index the node's location says it instead.
|
|
141
|
+
*/
|
|
142
|
+
export interface ScopeRule {
|
|
143
|
+
kind: string;
|
|
144
|
+
/**
|
|
145
|
+
* The attr path whose value names the scope. With none (#5100), the kind's
|
|
146
|
+
* names are unique inside the member that holds the node, which is what a
|
|
147
|
+
* namespaced kind with no namespace on the node gets.
|
|
148
|
+
*/
|
|
149
|
+
path?: string;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* What the catalog pass on a declared graph reads for one node, when the
|
|
154
|
+
* node as printed is not what the rules are written against (#5097). A
|
|
155
|
+
* declared terraform block is `Terraform::Resource` with its arguments under
|
|
156
|
+
* `body`; its view has the provider type as `kind` and the literal arguments
|
|
157
|
+
* as `attrs`.
|
|
158
|
+
*/
|
|
159
|
+
export interface DeclaredCatalogNode {
|
|
160
|
+
kind: string;
|
|
161
|
+
attrs: Record<string, unknown>;
|
|
162
|
+
/** Arguments left out of `attrs` because their value is not literal (an interpolation, a reference). */
|
|
163
|
+
nonLiteral: number;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* A node a lexicon adds to a declared workspace graph because several members
|
|
168
|
+
* name the same thing (#5100): one Helm chart that a kustomization, an Argo CD
|
|
169
|
+
* Application and a Terraform `helm_release` all name is one node, owned by
|
|
170
|
+
* none of them. The catalog pass draws an edge to it from each holder.
|
|
171
|
+
*/
|
|
172
|
+
export interface SharedCatalogNode {
|
|
173
|
+
/** The node's own id; the pass places it as `<member>/<id>`, in the member of its first holder. */
|
|
174
|
+
id: string;
|
|
175
|
+
kind: string;
|
|
176
|
+
attrs: Record<string, unknown>;
|
|
177
|
+
/** The nodes that name it, by the id the pass read them under, with the attribute each reads it through. */
|
|
178
|
+
holders: Array<{ from: string; via: string; label?: string }>;
|
|
179
|
+
}
|
|
180
|
+
|
|
99
181
|
/** A lexicon's reference knowledge — its identity map and reference rules. */
|
|
100
182
|
export interface ReferenceCatalog {
|
|
101
183
|
identities: IdentityRule[];
|
|
102
184
|
refs: RefRule[];
|
|
103
185
|
/** Typed tag rules, used over indexed nodes only (#4522). */
|
|
104
186
|
tagRefs?: TagRefRule[];
|
|
187
|
+
/** Kinds whose names are scoped by a value on the node, on a declared graph (#5097). */
|
|
188
|
+
scopes?: ScopeRule[];
|
|
189
|
+
/**
|
|
190
|
+
* The node the catalog reads for a declared node of this lexicon, or
|
|
191
|
+
* undefined to read the node as it is (#5097). An instance node
|
|
192
|
+
* (`instanceOf`) carries no attrs of its own, so it is handed its block
|
|
193
|
+
* node as `block` (#5117). Pure.
|
|
194
|
+
*/
|
|
195
|
+
declaredNode?(node: IRNode, block?: IRNode): DeclaredCatalogNode | undefined;
|
|
196
|
+
/**
|
|
197
|
+
* True for a node of this lexicon that registers a cluster, the one a
|
|
198
|
+
* workspace member runs on (an Argo CD cluster Secret, #5101). A member's
|
|
199
|
+
* `runsOn` draws a declared edge from each such node to the cluster
|
|
200
|
+
* resource it names. Reads the node as the document holds it. Pure.
|
|
201
|
+
*/
|
|
202
|
+
registersCluster?(node: IRNode): boolean;
|
|
203
|
+
/**
|
|
204
|
+
* Nodes of this catalog's lexicon that the declared graph has none of until
|
|
205
|
+
* every member is read (#5100), each with the nodes that name it. Called with
|
|
206
|
+
* every node the pass reads, after `declaredNode`. Pure. An edge from a holder
|
|
207
|
+
* carries the rule id `<lexicon>:<holder kind>:<via>`.
|
|
208
|
+
*/
|
|
209
|
+
sharedNodes?(nodes: readonly IRNode[]): SharedCatalogNode[];
|
|
210
|
+
/** Nodes a node of this lexicon makes, on a declared graph (#5102): the Applications an ApplicationSet generates. */
|
|
211
|
+
generates?: GenerateRule[];
|
|
212
|
+
/** Paths in the repository a node of this lexicon names, on a declared graph (#5102): an Application's source path. */
|
|
213
|
+
pathRefs?: PathRule[];
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* A node that stands for several the system it declares will make (#5102):
|
|
218
|
+
* an Argo CD ApplicationSet, whose generators yield parameter sets that its
|
|
219
|
+
* template turns into Applications. `from`, `path`, `targetKind` and `label`
|
|
220
|
+
* name the rule as a {@link RefRule}'s do, and the edge from the holder to
|
|
221
|
+
* each node it makes carries its id. `generate` is handed the holder and
|
|
222
|
+
* every node the pass reads (as `declaredNode` gives them), so a generator
|
|
223
|
+
* can select from nodes of any member. Only the catalog pass over a declared
|
|
224
|
+
* graph calls it. Pure.
|
|
225
|
+
*/
|
|
226
|
+
export interface GenerateRule {
|
|
227
|
+
from: string;
|
|
228
|
+
path: string;
|
|
229
|
+
targetKind: string;
|
|
230
|
+
label?: string;
|
|
231
|
+
generate(holder: IRNode, nodes: readonly IRNode[]): Generated;
|
|
232
|
+
/**
|
|
233
|
+
* The rule of the edge from a generated node to the cluster registration
|
|
234
|
+
* its generator selected it for ({@link GeneratedNode.cluster}): its id is
|
|
235
|
+
* `<lexicon>:<from>:<path>`. The selection names the registration, so the
|
|
236
|
+
* edge is drawn whatever the node's own references say, and an edge another
|
|
237
|
+
* rule draws for the same pair is left out.
|
|
238
|
+
*/
|
|
239
|
+
cluster?: { path: string; targetKind: string; label?: string };
|
|
240
|
+
/**
|
|
241
|
+
* The nodes the files a generated node names make (#5094): a generated
|
|
242
|
+
* Application's Helm values file and the objects under its `extraObjects`,
|
|
243
|
+
* as the reader makes them for one written by hand. `readFile` returns a
|
|
244
|
+
* workspace-relative file's text, or undefined when it is not in the
|
|
245
|
+
* workspace's repository; `nodes` are every node the pass reads, so a file
|
|
246
|
+
* a node already holds is not read twice. The pass gives each the id
|
|
247
|
+
* `<holder id>/<key>`, so one file named by several of a holder's
|
|
248
|
+
* generated nodes is one node. Only the catalog pass over a declared graph
|
|
249
|
+
* calls it, and only when its caller can read the repository.
|
|
250
|
+
*/
|
|
251
|
+
files?(node: IRNode, readFile: (path: string) => string | undefined, nodes: readonly IRNode[]): FileNode[];
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** One node a {@link GenerateRule.files} read from a file. */
|
|
255
|
+
export interface FileNode {
|
|
256
|
+
/** Unique among the holder's file nodes: `values/<path>`, and `values/<path>/<object>` for an object in it. */
|
|
257
|
+
key: string;
|
|
258
|
+
kind: string;
|
|
259
|
+
/** The lexicon whose node it is: a values file is the helm lexicon's, the objects in it the holder's. */
|
|
260
|
+
lexicon: string;
|
|
261
|
+
attrs: Record<string, unknown>;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** What a {@link GenerateRule} made of one holder. */
|
|
265
|
+
export interface Generated {
|
|
266
|
+
nodes: GeneratedNode[];
|
|
267
|
+
/** What the rule left unexpanded and why, one line each: a generator it does not read, a template function it does not know. */
|
|
268
|
+
notExpanded: string[];
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* One node a {@link GenerateRule} made. The pass gives it the id
|
|
273
|
+
* `<holder id>/<key>`, the holder's lexicon and member, and reads it with the
|
|
274
|
+
* other nodes, so the catalog's rules join it as they join a declared node
|
|
275
|
+
* of its kind.
|
|
276
|
+
*/
|
|
277
|
+
export interface GeneratedNode {
|
|
278
|
+
/** Unique among the holder's nodes: a generated Application's name. */
|
|
279
|
+
key: string;
|
|
280
|
+
kind: string;
|
|
281
|
+
attrs: Record<string, unknown>;
|
|
282
|
+
/** The generator that yielded it, such as `clusters` or `list`. */
|
|
283
|
+
generator: string;
|
|
284
|
+
/** The parameters it was made with, flattened to `a.b.c` keys. */
|
|
285
|
+
params: Record<string, string>;
|
|
286
|
+
/** With a generator that reads cluster registrations: the node it was made for, when there is one. */
|
|
287
|
+
cluster?: IRNode;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* A path in a repository that a node names (#5102): an Argo CD Application's
|
|
292
|
+
* `spec.source.path`, a values file. `from` and `path` name the rule as a
|
|
293
|
+
* {@link RefRule}'s do. `read` returns each path the holder names; the pass
|
|
294
|
+
* looks for it in the workspace's repository and reports one that is not
|
|
295
|
+
* there as dangling. Pure.
|
|
296
|
+
*/
|
|
297
|
+
export interface PathRule {
|
|
298
|
+
from: string;
|
|
299
|
+
path: string;
|
|
300
|
+
label?: string;
|
|
301
|
+
read(holder: IRNode): RepoPathRef[];
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/** One path a {@link PathRule} read. */
|
|
305
|
+
export interface RepoPathRef {
|
|
306
|
+
/** The path from the repository's root, as the holder resolves it. */
|
|
307
|
+
value: string;
|
|
308
|
+
/** The repository the path is in, as the holder writes it (`repoURL`). */
|
|
309
|
+
repo: string;
|
|
310
|
+
/** Whether the path names a directory or a file. */
|
|
311
|
+
type: "dir" | "file";
|
|
105
312
|
}
|
|
106
313
|
|
|
107
314
|
/** `child` is contained by `parent` (subnet ∈ VPC). For #779's boundary boxes. */
|
|
@@ -118,6 +325,8 @@ export interface DanglingRef {
|
|
|
118
325
|
path: string;
|
|
119
326
|
value: string;
|
|
120
327
|
targetKind?: string;
|
|
328
|
+
/** The id of the node the value was read through (#5098): the store whose cloud secret a key names. */
|
|
329
|
+
through?: string;
|
|
121
330
|
}
|
|
122
331
|
|
|
123
332
|
export interface ReconstructedEdges {
|
|
@@ -156,21 +365,86 @@ function toStr(v: unknown): string | undefined {
|
|
|
156
365
|
return undefined;
|
|
157
366
|
}
|
|
158
367
|
|
|
368
|
+
/** One step of an attr path: a key, and whether the value under it fans out as an array. */
|
|
369
|
+
export interface PathStep {
|
|
370
|
+
key: string;
|
|
371
|
+
fanOut: boolean;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/** Catalog paths, parsed once: a catalog is a fixed list, so this stays small. */
|
|
375
|
+
const parsedPaths = new Map<string, PathStep[]>();
|
|
376
|
+
|
|
377
|
+
/** The index of the closing quote of the quoted key opened at `i`, when `"]` closes it and it parses as JSON. */
|
|
378
|
+
function quotedEnd(path: string, i: number): number | undefined {
|
|
379
|
+
let j = i + 2;
|
|
380
|
+
while (j < path.length && path[j] !== '"') j += path[j] === "\\" ? 2 : 1;
|
|
381
|
+
if (path[j] !== '"' || path[j + 1] !== "]") return undefined;
|
|
382
|
+
try {
|
|
383
|
+
return typeof JSON.parse(path.slice(i + 1, j + 1)) === "string" ? j : undefined;
|
|
384
|
+
} catch {
|
|
385
|
+
return undefined;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
159
389
|
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
390
|
+
* Split an attr path into its steps. A bare step runs to the next `.`, `[]`
|
|
391
|
+
* or quoted step; `[]` after a step fans it out over an array. A quoted step,
|
|
392
|
+
* `["iam.gke.io/gcp-service-account"]`, is one key whatever it holds (#5097):
|
|
393
|
+
* a JSON string in brackets, so `\"` and `\\` escape as they do in JSON. It
|
|
394
|
+
* follows the step before it with no `.`, and can fan out too (`["a.b"][]`).
|
|
395
|
+
*/
|
|
396
|
+
export function parsePath(path: string): PathStep[] {
|
|
397
|
+
const steps: PathStep[] = [];
|
|
398
|
+
let bare = "";
|
|
399
|
+
let inBare = false;
|
|
400
|
+
const endBare = (): void => {
|
|
401
|
+
if (inBare) steps.push({ key: bare, fanOut: false });
|
|
402
|
+
bare = "";
|
|
403
|
+
inBare = false;
|
|
404
|
+
};
|
|
405
|
+
let i = 0;
|
|
406
|
+
while (i < path.length) {
|
|
407
|
+
const c = path[i];
|
|
408
|
+
if (c === ".") {
|
|
409
|
+
endBare();
|
|
410
|
+
i++;
|
|
411
|
+
} else if (c === "[" && path[i + 1] === "]") {
|
|
412
|
+
endBare();
|
|
413
|
+
if (steps.length > 0) steps[steps.length - 1].fanOut = true;
|
|
414
|
+
else steps.push({ key: "", fanOut: true });
|
|
415
|
+
i += 2;
|
|
416
|
+
} else if (c === "[" && path[i + 1] === '"' && quotedEnd(path, i) !== undefined) {
|
|
417
|
+
endBare();
|
|
418
|
+
const j = quotedEnd(path, i)!;
|
|
419
|
+
steps.push({ key: JSON.parse(path.slice(i + 1, j + 1)) as string, fanOut: false });
|
|
420
|
+
i = j + 2;
|
|
421
|
+
} else {
|
|
422
|
+
bare += c;
|
|
423
|
+
inBare = true;
|
|
424
|
+
i++;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
endBare();
|
|
428
|
+
return steps;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Read all scalar values at an attr path. Supports nested keys (`a.b`), array
|
|
433
|
+
* fan-out (`arr[]`, `arr[].id`) and quoted keys for a key that holds dots or
|
|
434
|
+
* slashes (`metadata.annotations["eks.amazonaws.com/role-arn"]`, #5097).
|
|
435
|
+
* Returns every scalar found: a path through an array yields one value per
|
|
436
|
+
* element.
|
|
163
437
|
*/
|
|
164
438
|
export function readPath(obj: unknown, path: string): string[] {
|
|
439
|
+
let steps = parsedPaths.get(path);
|
|
440
|
+
if (!steps) parsedPaths.set(path, (steps = parsePath(path)));
|
|
165
441
|
let cur: unknown[] = [obj];
|
|
166
|
-
for (const
|
|
167
|
-
const isArr = part.endsWith("[]");
|
|
168
|
-
const key = isArr ? part.slice(0, -2) : part;
|
|
442
|
+
for (const { key, fanOut } of steps) {
|
|
169
443
|
const next: unknown[] = [];
|
|
170
444
|
for (const c of cur) {
|
|
171
445
|
if (c == null || typeof c !== "object") continue;
|
|
172
446
|
const val = (c as Record<string, unknown>)[key];
|
|
173
|
-
if (
|
|
447
|
+
if (fanOut) {
|
|
174
448
|
if (Array.isArray(val)) next.push(...val);
|
|
175
449
|
} else if (val !== undefined) {
|
|
176
450
|
next.push(val);
|
|
@@ -227,7 +501,7 @@ export function reconstructEdges(nodes: IRNode[], catalog: ReferenceCatalog): Re
|
|
|
227
501
|
|
|
228
502
|
for (const node of nodes) {
|
|
229
503
|
for (const rule of catalog.refs) {
|
|
230
|
-
if (rule.from !== node.kind) continue;
|
|
504
|
+
if (rule.from !== node.kind || rule.join) continue;
|
|
231
505
|
for (const value of readPath(node.attrs, rule.path)) {
|
|
232
506
|
const candidates = index.get(value) ?? [];
|
|
233
507
|
// `chant graph --live` keeps its first-candidate pick: its values are
|
|
@@ -322,8 +596,18 @@ export interface IndexedNodeScope {
|
|
|
322
596
|
account: string;
|
|
323
597
|
/** The region or location; undefined for a global type. */
|
|
324
598
|
region?: string;
|
|
599
|
+
/**
|
|
600
|
+
* The member that holds the node, on a declared graph (#5100). A holder also
|
|
601
|
+
* looks in {@link memberRegion} of its own member, whatever its own region, so
|
|
602
|
+
* a node that names no scope but its member (a values file) is reached by a
|
|
603
|
+
* holder scoped by namespace.
|
|
604
|
+
*/
|
|
605
|
+
member?: string;
|
|
325
606
|
}
|
|
326
607
|
|
|
608
|
+
/** The region of a node held by one member (a `ScopeRule` with no `path`). */
|
|
609
|
+
export const memberRegion = (member: string): string => `member:${member}`;
|
|
610
|
+
|
|
327
611
|
/** A reference whose value matched several nodes: no edge is drawn (behold#1023 Q3). */
|
|
328
612
|
export interface AmbiguousRef {
|
|
329
613
|
from: string;
|
|
@@ -352,8 +636,7 @@ const PLACEHOLDER_VALUES: ReadonlySet<string> = new Set(["[REDACTED]", "<chant:u
|
|
|
352
636
|
|
|
353
637
|
/** The attribute a rule reads through, as a declared graph's `viaAttr` names it: `SecurityGroupIds[]` is `SecurityGroupIds`. */
|
|
354
638
|
function topAttr(path: string): string {
|
|
355
|
-
|
|
356
|
-
return first.endsWith("[]") ? first.slice(0, -2) : first;
|
|
639
|
+
return parsePath(path)[0]?.key ?? path;
|
|
357
640
|
}
|
|
358
641
|
|
|
359
642
|
/** `<lexicon>:<from kind>:<path>`, the id a derived edge carries. */
|
|
@@ -388,10 +671,18 @@ export function reconstructIndexedEdges(
|
|
|
388
671
|
const sorted = [...nodes].sort((a, b) => byString(a.id, b.id));
|
|
389
672
|
const keyOf = (scope: IndexedNodeScope, value: string) => `${scope.account}\u0000${scope.region ?? ""}\u0000${value}`;
|
|
390
673
|
const index = new Map<string, Map<string, string>>();
|
|
674
|
+
// The same nodes by the name of the scope they sit in (the text after the
|
|
675
|
+
// first `:` of a region), for a join that names a scope itself.
|
|
676
|
+
const named = new Map<string, Map<string, string>>();
|
|
391
677
|
const add = (scope: IndexedNodeScope, value: string | undefined, node: IRNode): void => {
|
|
392
678
|
if (value === undefined || value === "" || PLACEHOLDER_VALUES.has(value)) return;
|
|
393
679
|
const k = keyOf(scope, value);
|
|
394
680
|
(index.get(k) ?? index.set(k, new Map()).get(k)!).set(node.id, node.kind);
|
|
681
|
+
const colon = scope.region?.indexOf(":") ?? -1;
|
|
682
|
+
if (scope.region !== undefined && colon > 0) {
|
|
683
|
+
const nk = `${scope.region.slice(colon + 1)}\u0000${value}`;
|
|
684
|
+
(named.get(nk) ?? named.set(nk, new Map()).get(nk)!).set(node.id, node.kind);
|
|
685
|
+
}
|
|
395
686
|
};
|
|
396
687
|
const identities = catalogs.flatMap((c) => c.catalog.identities);
|
|
397
688
|
for (const node of sorted) {
|
|
@@ -406,10 +697,12 @@ export function reconstructIndexedEdges(
|
|
|
406
697
|
}
|
|
407
698
|
}
|
|
408
699
|
|
|
700
|
+
const byId = new Map(sorted.map((n) => [n.id, n]));
|
|
409
701
|
const lookup = (holder: IRNode, value: string): Map<string, string> => {
|
|
410
702
|
const scope = scopeOf(holder);
|
|
411
703
|
const out = new Map<string, string>();
|
|
412
704
|
const keys = scope.region !== undefined ? [keyOf(scope, value), keyOf({ account: scope.account }, value)] : [keyOf(scope, value)];
|
|
705
|
+
if (scope.member !== undefined) keys.push(keyOf({ account: scope.account, region: memberRegion(scope.member) }, value));
|
|
413
706
|
for (const k of keys) for (const [id, kind] of index.get(k) ?? []) out.set(id, kind);
|
|
414
707
|
return out;
|
|
415
708
|
};
|
|
@@ -420,15 +713,22 @@ export function reconstructIndexedEdges(
|
|
|
420
713
|
// and template-shape rules for the same path) report a reference once.
|
|
421
714
|
const dangling = new Map<string, IndexedDanglingRef>();
|
|
422
715
|
const ambiguous = new Map<string, AmbiguousRef>();
|
|
716
|
+
// A value some rule of an id found a node for. Rules of one id and different
|
|
717
|
+
// target kinds are alternatives (a cluster Secret's name is a GKE, an EKS or
|
|
718
|
+
// an AKS cluster), so the kinds that found nothing do not report it dangling.
|
|
719
|
+
const found = new Set<string>();
|
|
423
720
|
|
|
424
721
|
const resolve = (
|
|
425
722
|
holder: IRNode,
|
|
426
723
|
value: string,
|
|
427
724
|
rule: { id: string; path: string; targetKind?: string; relation: "reference" | "containment"; via: string; label?: string; optional?: boolean },
|
|
725
|
+
joined?: { targets: readonly IRNode[]; through?: IRNode },
|
|
428
726
|
): void => {
|
|
429
727
|
if (PLACEHOLDER_VALUES.has(value)) return;
|
|
430
|
-
|
|
431
|
-
|
|
728
|
+
let candidates = joined
|
|
729
|
+
? joined.targets.map((t) => t.id)
|
|
730
|
+
: [...lookup(holder, value).entries()].filter(([, kind]) => rule.targetKind === undefined || kind === rule.targetKind).map(([id]) => id);
|
|
731
|
+
const through = joined?.through ? { through: joined.through.id } : {};
|
|
432
732
|
if (candidates.includes(holder.id)) {
|
|
433
733
|
if (candidates.length === 1) return; // a self-reference (an SG rule to its own group)
|
|
434
734
|
candidates = candidates.filter((id) => id !== holder.id);
|
|
@@ -436,9 +736,10 @@ export function reconstructIndexedEdges(
|
|
|
436
736
|
candidates.sort(byString);
|
|
437
737
|
if (candidates.length === 0) {
|
|
438
738
|
if (rule.optional) return;
|
|
439
|
-
dangling.set(`${holder.id}|${rule.id}|${value}`, { from: holder.id, path: rule.path, value, rule: rule.id, ...(rule.targetKind ? { targetKind: rule.targetKind } : {}) });
|
|
739
|
+
dangling.set(`${holder.id}|${rule.id}|${value}|${through.through ?? ""}`, { from: holder.id, path: rule.path, value, rule: rule.id, ...(rule.targetKind ? { targetKind: rule.targetKind } : {}), ...through });
|
|
440
740
|
return;
|
|
441
741
|
}
|
|
742
|
+
found.add(`${holder.id}|${rule.id}|${value}`);
|
|
442
743
|
if (candidates.length > 1) {
|
|
443
744
|
ambiguous.set(`${holder.id}|${rule.id}|${value}`, { from: holder.id, rule: rule.id, path: rule.path, value, candidates });
|
|
444
745
|
return;
|
|
@@ -484,6 +785,12 @@ export function reconstructIndexedEdges(
|
|
|
484
785
|
...(rule.label ? { label: rule.label } : {}),
|
|
485
786
|
...(rule.optional ? { optional: true } : {}),
|
|
486
787
|
};
|
|
788
|
+
if (rule.join) {
|
|
789
|
+
const find: FindNodes = (value, scope) =>
|
|
790
|
+
[...(scope === undefined ? lookup(node, value) : named.get(`${scope}\u0000${value}`) ?? new Map<string, string>()).keys()].map((id) => byId.get(id)!);
|
|
791
|
+
for (const j of rule.join(node, find)) resolve(node, j.value, { ...spec, via: j.via ?? spec.via }, j);
|
|
792
|
+
continue;
|
|
793
|
+
}
|
|
487
794
|
for (const value of new Set(readPath(node.attrs, rule.path))) resolve(node, value, spec);
|
|
488
795
|
}
|
|
489
796
|
for (const rule of catalog.tagRefs ?? []) {
|
|
@@ -513,7 +820,7 @@ export function reconstructIndexedEdges(
|
|
|
513
820
|
return {
|
|
514
821
|
edges: [...edges.values()].sort((a, b) => byString(edgeKey(a), edgeKey(b))),
|
|
515
822
|
containment: [...containment.values()].sort((a, b) => byString(`${a.child}|${a.parent}`, `${b.child}|${b.parent}`)),
|
|
516
|
-
dangling: [...dangling.values()].sort((a, b) => byString(`${a.from}|${a.rule}|${a.value}`, `${b.from}|${b.rule}|${b.value}`)),
|
|
823
|
+
dangling: [...dangling.values()].filter((d) => !found.has(`${d.from}|${d.rule}|${d.value}`)).sort((a, b) => byString(`${a.from}|${a.rule}|${a.value}|${a.through ?? ""}`, `${b.from}|${b.rule}|${b.value}|${b.through ?? ""}`)),
|
|
517
824
|
ambiguous: [...ambiguous.values()].sort((a, b) => byString(`${a.from}|${a.rule}|${a.value}`, `${b.from}|${b.rule}|${b.value}`)),
|
|
518
825
|
};
|
|
519
826
|
}
|