From 28c2f41134ff9aabeb6aa7f5536ff616c7589019 Mon Sep 17 00:00:00 2001 From: lex00 <121451605+lex00@users.noreply.github.com> Date: Sun, 15 Nov 2026 10:50:59 -0700 Subject: [PATCH 1/6] feat(k8s): a workspace kind for plain manifest directories; read ApplicationSet and AppProject (#5096) --- CHANGELOG.md | 1 + .../docs/reference/workspace-kinds.mdx | 8 +- lexicons/k8s/src/config-schema.ts | 3 +- lexicons/k8s/src/config.ts | 9 +- .../workspace-members/argo-set/all.yaml | 43 ++++++ .../workspace-members/plain/deploy.yaml | 27 ++++ .../testdata/workspace-members/plain/es.yaml | 15 ++ .../workspace-members/templated/block.yaml | 6 + .../workspace-members/templated/chart-cm.yaml | 4 + .../workspace-members/templated/cm.yaml | 6 + lexicons/k8s/src/workspace-kinds.test.ts | 10 +- lexicons/k8s/src/workspace-member.test.ts | 57 +++++++- lexicons/k8s/src/workspace-member.ts | 131 +++++++++++++++--- lexicons/k8s/workspace-kinds.json | 42 +++++- 14 files changed, 327 insertions(+), 35 deletions(-) create mode 100644 lexicons/k8s/src/testdata/workspace-members/argo-set/all.yaml create mode 100644 lexicons/k8s/src/testdata/workspace-members/plain/deploy.yaml create mode 100644 lexicons/k8s/src/testdata/workspace-members/plain/es.yaml create mode 100644 lexicons/k8s/src/testdata/workspace-members/templated/block.yaml create mode 100644 lexicons/k8s/src/testdata/workspace-members/templated/chart-cm.yaml create mode 100644 lexicons/k8s/src/testdata/workspace-members/templated/cm.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a70bd81ef..3a4deb0df4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ This file records changes to what chant prints or writes for a plain project, th ## Unreleased +- [#5096](https://github.com/INTENTIUS/chant/issues/5096) The k8s lexicon supplies a `manifests` workspace kind (precedence 305, below every other kind that reads YAML): a directory of plain Kubernetes manifests is a member, with a node for every document that has an `apiVersion` and a `kind`, custom resources included. A directory no other kind claimed that holds such files is now a `manifests` member in `chant workspace init` and `chant workspace graph`, where it was left out before. The `argo-app` kind also reads `ApplicationSet` and `AppProject` documents and claims a directory that holds only those. A YAML file that does not parse is a warning that names it. - [#5060](https://github.com/INTENTIUS/chant/issues/5060) In a product's workflow (`runIf`) with `beforeMerge` and a spec `control`, the Op waves control job runs again. It used to need the last wave's record jobs and sit inside the product's push `runIf`, so it could never run. It now runs on the default branch's push run, outside the product's `runIf`, after the jobs `firstWaveNeeds` names, and tells the control repo the waves applied at `github.sha` or `$CI_COMMIT_SHA`, adding up no outcomes. GitHub, Forgejo and GitLab. Without `beforeMerge`, or without `runIf`, the job renders as before. Floor: `OP_WAVES_CONTROL_BEFORE_MERGE_FLOOR`. - [#5061](https://github.com/INTENTIUS/chant/issues/5061) With `wavesBeforeMerge` and the product plan's `reach`, and no `locks: "plan"`, the comment job (GitHub, Forgejo) and the note poll (GitLab, `chantNoteRuns`) answer `/ lock` on an open pull request by taking the locks of what the reach line prints at stage `apply` in `_locks/.json`, without applying, refused with the holder named while another open pull request holds one, and `/ unlock` by releasing the pull request's locks. Both reply, run none of the change's code, and are refused for a fork or a commenter without write access. The product plan takes `reach` without `locks: "plan"` under `wavesBeforeMerge`, and then writes no reach lock job. With `locks: "plan"`, or without `wavesBeforeMerge` and `reach`, nothing changes. Floor: `WAVES_BEFORE_MERGE_LOCKS_FLOOR`. - [#5056](https://github.com/INTENTIUS/chant/issues/5056) `approvals.remainder` resumes the waves terragucci's own records resume. The terraform step gives a live choudoufu root planned through `live-plan-set` its `resourceDigests`, from the set's plan, as the `plan -out` path does, so the applied line names its changes; before, such a wave never resumed as a remainder. Those digests also reach a pull request's recorded plans, so `approvals.preview` compares a live root resource by resource, as it does a `plan -out` root. The remainder's cover leaves out the cost member `(monthly cost)` on both sides, since it digests the wave's monthly change, which moves once part of the wave applied; every change is still compared. Floor: `OP_WAVES_REMAINDER_PARITY_FLOOR`. diff --git a/docs/src/content/docs/reference/workspace-kinds.mdx b/docs/src/content/docs/reference/workspace-kinds.mdx index cbfa23a0b5..924dd7d541 100644 --- a/docs/src/content/docs/reference/workspace-kinds.mdx +++ b/docs/src/content/docs/reference/workspace-kinds.mdx @@ -496,17 +496,18 @@ The file also holds a SHA-256 digest of the migration files it ran, and for Flyw ## Platform kinds -Seven kinds cover the files a platform repository holds besides Terraform ([#3179](https://github.com/INTENTIUS/chant/issues/3179)). Each is data in the kinds file of the package that knows the substrate. All seven have a `graph` block, so [`chant workspace graph`](/chant/cli/workspace-graph/) draws their members (see [below](#how-the-platform-kinds-are-read)). +Eight kinds cover the files a platform repository holds besides Terraform ([#3179](https://github.com/INTENTIUS/chant/issues/3179)). Each is data in the kinds file of the package that knows the substrate. All eight have a `graph` block, so [`chant workspace graph`](/chant/cli/workspace-graph/) draws their members (see [below](#how-the-platform-kinds-are-read)). | Kind | Package | Precedence | Probe | |---|---|---|---| -| `argo-app` | `@intentius/chant-lexicon-k8s` | 360 | a YAML file with `apiVersion: argoproj.io/*` and `kind: Application` | +| `argo-app` | `@intentius/chant-lexicon-k8s` | 360 | a YAML file with `apiVersion: argoproj.io/*` and `kind: Application`, `ApplicationSet` or `AppProject` | | `flux-kustomization` | `@intentius/chant-lexicon-k8s` | 350 | a YAML file with `apiVersion: kustomize.toolkit.fluxcd.io/*` and `kind: Kustomization`. kustomize's own `kustomization.yaml` uses another apiVersion and isn't claimed | | `kustomize` | `@intentius/chant-lexicon-k8s` | 340 | `kustomization.yaml`, `kustomization.yml` or `Kustomization` | | `helm-chart` | `@intentius/chant-lexicon-helm` | 330 | `Chart.yaml`, which the kind also checks (`apiVersion`, `name`, `version`) | | `cloudformation` | `@intentius/chant-lexicon-aws` | 320 | a `.yaml`, `.yml`, `.json` or `.template` file with `AWSTemplateFormatVersion` or `Resources` at its top. YAML short-form tags such as `!Ref` are allowed | | `cdk` | `@intentius/chant-lexicon-aws` | 315 | `cdk.json`, which the kind also checks (`app`) | | `pulumi` | `@intentius/chant-lexicon-pulumi` | 310 | `Pulumi.yaml`, which the kind also checks (`name`, `runtime`). The kind was in `@intentius/chant-lexicon-terraform` until [#4453](https://github.com/INTENTIUS/chant/issues/4453); a workspace that reads Pulumi members pins the pulumi lexicon | +| `manifests` | `@intentius/chant-lexicon-k8s` | 305 | a YAML file with an `apiVersion` and a `kind`, whatever their values. Every kind above outranks it, so a directory with a `kustomization.yaml`, a `Chart.yaml` or an Argo CD document goes to that kind | [`chant workspace init`](/chant/cli/workspace-init/) proposes these kinds, and pins the packages, when the packages are installed at the root. @@ -514,8 +515,9 @@ Seven kinds cover the files a platform repository holds besides Terraform ([#317 | Kind | What the graph holds | Needs | |---|---|---| -| `argo-app` | an `Application` per document, as a node | nothing; the manifests are read as data | +| `argo-app` | an `Application`, `ApplicationSet` or `AppProject` per document, as a node | nothing; the manifests are read as data | | `flux-kustomization` | a Flux `Kustomization` per document, as a node | nothing | +| `manifests` | a node per document with an `apiVersion` and a `kind`, including custom resources the k8s lexicon has no class for, with its `spec` at `--detail 3`. A file that does not parse, or holds `{{ ... }}` template syntax, is named in the member's warnings and the other files are still read. A directory that a `kustomization.yaml` in the workspace lists in `resources` is left to the kustomize member (`coveredBy` on `meta.k8sMember`), so its objects are not drawn twice | nothing | | `cloudformation` | a node per resource; an edge per `Ref`, `Fn::GetAtt`, `Fn::Sub` reference and `DependsOn` between resources of the template | nothing | | `kustomize` | the objects `kustomize build` renders, as nodes | `kustomize`, or `kubectl` | | `helm-chart` | the objects `helm template` renders, as nodes | `helm` | diff --git a/lexicons/k8s/src/config-schema.ts b/lexicons/k8s/src/config-schema.ts index 0b03ff02a9..9f28004d7d 100644 --- a/lexicons/k8s/src/config-schema.ts +++ b/lexicons/k8s/src/config-schema.ts @@ -75,9 +75,10 @@ export const k8sConfigSchema = z.strictObject({ .optional(), member: z .strictObject({ - kind: z.enum(["kustomize", "argo-app", "flux-kustomization"]), + kind: z.enum(["kustomize", "argo-app", "flux-kustomization", "manifests"]), dir: z.string().min(1), label: z.string().optional(), + workspace: z.string().optional(), }) .optional(), receipts: z diff --git a/lexicons/k8s/src/config.ts b/lexicons/k8s/src/config.ts index 116c5d7cbe..2851be3996 100644 --- a/lexicons/k8s/src/config.ts +++ b/lexicons/k8s/src/config.ts @@ -124,7 +124,7 @@ export interface K8sChantConfig { /** * One workspace member read into the graph (#3179). `chant workspace graph` * writes this into the reader project it makes for a member of kind - * `kustomize`, `argo-app` or `flux-kustomization`; it is not meant to be + * `kustomize`, `argo-app`, `flux-kustomization` or `manifests`; it is not meant to be * written by hand. `dir` is the member's directory, absolute; `label` names * the entities (`