Home / Stories / Naming conventions
Story · Repository hygiene Live

From app.yaml to a name that says what is inside.

Every repository grows a directory where one file is called app.yaml, another svc.yaml and a third autoscale.yaml. Nobody can tell what they hold without opening them. Once a week the assistant reads each file, works out what it really contains, and proposes one rename MR per directory that also fixes every reference to the old names.

Starts fromYAML files whose names do not follow <kind>_<identifier>.yaml.
Looks atEvery YAML file in your GitOps repositories: the kinds and metadata.names inside, and the kustomization.yaml files that reference them.
You getA draft MR that renames a whole directory consistently and rewrites the kustomization entries in the same diff.
01 · The weekly walk

Every YAML file, every Monday morning.

The naming review runs once a week. For each configured repository it lists every YAML file and parses what is actually inside: the kind, the name and the namespace of each document.

In apps/shop/orders-api/ it finds three files whose names say nothing about their content.

02 · Why names matter here

Names are how related files find each other.

The convention is <kind>_<identifier>[-qualifier].yaml, for example deployment_orders-api.yaml. It is not just tidiness: the repository scanner batches files that share an identifier, so a Deployment and its autoscaler are analysed in the same context and a fix can touch both.

autoscale.yaml shares nothing with app.yaml, so today they are looked at apart.

03 · Suggest the names

A model proposes, as a structured list.

The model sees the parsed summary of every file in the directory and returns a list of from → to pairs, each with a confidence. Low-confidence suggestions are dropped.

It also flags files sitting in a flat root that belong in a subdirectory, and resources of one application named inconsistently. None of this is applied yet: every suggestion now has to pass deterministic checks.

04 · Grounded in the file, not its neighbours

Every part of the new name must come from the file itself.

Each token of a proposed name has to be explained by the file it renames: a word from its current name, a Kubernetes kind, or a word from a metadata.name inside it. A token borrowed from a neighbouring file is rejected.

The kind prefix must match the file's actual kind too. A CloudNativePG Cluster is not a statefulset_, however familiar that word is.

05 · What is left alone

Some renames are not worth making, or not safe to make.

  • A file holding several resources is never squeezed into a single-kind name.
  • Two files that would land on the same new name: both are dropped, a human picks.
  • Vendored bundles (upstream install manifests) are recognised by content and skipped.
  • Directories without a kustomization.yaml are left alone: Flux reads every file there anyway, so a rename is pure churn.
  • A skip annotation on the file opts it out for good.
06 · One directory, one MR

Renames land together, or the directory gets worse.

Merging renames one file at a time leaves a directory half in the old style and half in the new. Suggestions in the same directory that make the same kind of change are grouped into a single proposal, so the directory is uniform the moment it merges.

07 · Rewrite every reference

A rename that breaks kustomize build is not a rename.

Every kustomization.yaml that names the old file is rewritten in the same diff. Afterwards the result is parsed again across every reference field kustomize knows (resources, patches, generators and more) to prove the old name is gone.

If a reference has a shape the rewriter cannot edit safely, such as a flow-style list or a generator's files: entry, the proposal is held as NEEDS_REVIEW with high risk, naming the exact reference to rewire by hand.

08 · The proposal

Three renames, one kustomization patch, zero content changes.

The MR moves files and edits references, nothing else. Merge it and Flux applies exactly the same objects as before. The full MR is below.

naming review · apps/shop/orders-api/weekly
  • kustomization.yaml Kustomization · 3 resources
  • app.yaml Deployment orders-api
  • svc.yaml Service orders-api
  • autoscale.yaml HorizontalPodAutoscaler orders-api
  • servicemonitor_orders-api.yaml already follows the convention
3 of 5 files: name does not reveal kind or identifier
app.yamlgroup: app
svc.yamlgroup: svc
autoscale.yamlgroup: autoscale
today: three separate batches for the repository scanner
deployment_orders-api+ service_ + hpa_
One batchidentifier: orders-api
after: related resources are analysed together
model output · structured renames
{ "renames": [
  { "from": "apps/shop/orders-api/app.yaml",
    "to":   "apps/shop/orders-api/deployment_orders-api.yaml" },
  { "from": "…/svc.yaml",       "to": "…/service_orders-api.yaml" },
  { "from": "…/autoscale.yaml", "to": "…/hpa_orders-api.yaml" }
], "confidence": 0.9 }
suggestion only · deterministic checks decide what ships
grounding check · tokens of each new name
  • deployment_orders-api "deployment" = kind in file · "orders-api" = metadata.name
  • hpa_orders-api "hpa" = HorizontalPodAutoscaler · name matches
  • helmrelease_vault_external-secrets "vault" only appears in a neighbouring SecretStore · rejected
  • statefulset_orders-db file's kind is Cluster (CloudNativePG) · prefix mismatch · rejected
a name is only accepted if the file itself explains every word of it
filters · elsewhere in the same repository
14 suggestions in · 9 kept
  • platform/redis/redis.yaml 4 documents · not renamed to a single kind
  • mysql-prod.yaml + mysql.yaml both → deployment_mysql.yaml · collision · both dropped
  • crds/operator-install.yaml vendored upstream bundle · skipped
  • sandbox/*.yaml no kustomization.yaml · Flux reads all files · churn only
  • payments/legacy.yaml skip annotation · operator opted out
grouping · apps/shop/orders-api/
  • app.yaml → deployment_orders-api.yaml
  • svc.yaml → service_orders-api.yaml
  • autoscale.yaml → hpa_orders-api.yaml
apps/shop/orders-api/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
-  - app.yaml
-  - svc.yaml
-  - autoscale.yaml
+  - deployment_orders-api.yaml
+  - service_orders-api.yaml
+  - hpa_orders-api.yaml
   - servicemonitor_orders-api.yaml
re-parsed after rewrite: 0 references to old names in any kustomize field
Elsewhere: held for review
configMapGenerator.files: [nginx.conf, settings.yaml] is flow-style. The old name cannot be rewritten safely, so that rename ships as NEEDS_REVIEW, risk high, with the line to fix by hand.
Draft · Rename 3 files in apps/shop/orders-api/ to kind_identifier
rename app.yaml        deployment_orders-api.yaml
rename svc.yaml        service_orders-api.yaml
rename autoscale.yaml  hpa_orders-api.yaml
edit   kustomization.yaml  +3 −3
category:architecturesource:naming_scan:acme-appsrisk:lowxrev::LGTM
↓ the full merge request is below

The merge request you get.

Illustrative. File names, the repository and the MR number are fictional; the shape of the proposal is the real one.

Draft

Rename 3 files in apps/shop/orders-api/ to <kind>_<identifier>

from gitops-ai/naming-orders-api-7a2e into main · 4 files · 3 renamed · +3 −3
category:architecturesource:naming_scan:acme-appsrisk:lowxrev::LGTM
OverviewChangesValidation
Summary

Three files in apps/shop/orders-api/ do not follow the repository's <kind>_<identifier>.yaml convention. This MR renames them together so the directory is consistent, and updates the kustomization that lists them.

Current nameContainsNew name
app.yamlDeployment orders-apideployment_orders-api.yaml
svc.yamlService orders-apiservice_orders-api.yaml
autoscale.yamlHorizontalPodAutoscaler orders-apihpa_orders-api.yaml
Why

With a shared identifier, the Deployment, Service and autoscaler are analysed together by later scans, and a reader can tell what each file holds from the directory listing.

What does not change

File contents. The rendered objects are identical before and after this MR.

renamed:  apps/shop/orders-api/app.yaml → apps/shop/orders-api/deployment_orders-api.yaml
renamed:  apps/shop/orders-api/svc.yaml → apps/shop/orders-api/service_orders-api.yaml
renamed:  apps/shop/orders-api/autoscale.yaml → apps/shop/orders-api/hpa_orders-api.yaml

apps/shop/orders-api/kustomization.yaml
 resources:
-  - app.yaml
-  - svc.yaml
-  - autoscale.yaml
+  - deployment_orders-api.yaml
+  - service_orders-api.yaml
+  - hpa_orders-api.yaml
   - servicemonitor_orders-api.yaml
Checked before this MR was opened
  • Every word of each new name is found in the file itself (kind or metadata.name); no token borrowed from another file.
  • Each kind prefix matches the kind of the single resource in the file.
  • No two renames target the same new path.
  • Every kustomization field that can reference a file was re-parsed after the rewrite: no reference to an old name remains.
After merge, expect
  • Flux reconciles the shop kustomization with no object created, changed or deleted.
  • kustomize build apps/shop/orders-api output identical to before.
R
independent reviewer second opinion, no pipeline context

Pure renames plus a matching kustomization edit. Checked the directory for other references to the old names (none). LGTM.

What keeps it honest.

The model suggests names. Deterministic checks decide which renames are allowed out.

Grounded in the fileEvery token of a new name must come from the file's current name, its kinds or its resource names. Words borrowed from neighbouring files are rejected.
Kind prefix must be trueThe prefix has to match the file's actual kind, including custom resources. A familiar but wrong kind is refused.
No dangling referencesKustomization entries are rewritten in the same diff and re-checked across every reference field. Anything the rewriter cannot edit safely is held for review with the exact line named.
Collisions need a humanWhen two files would land on the same name, both renames are dropped rather than guessing which one wins.
Whole directories at onceRenames sharing a directory and a convention change ship as one MR, so a directory is never left half-converted.
No churn for its own sakeMulti-resource files, vendored bundles, directories Flux reads wholesale, and files you annotate as skipped are left alone.

Where this stands.

Live
  • Weekly naming review across all configured repositories
  • Rename MRs with kustomization references rewritten in the same diff
  • Grounding, kind-prefix, collision, multi-resource and vendored-bundle guards
  • Directory-level grouping and per-file skip annotations
In development
  • Renames that keep a kustomization entry's position and comment block in place, instead of remove-and-append
Roadmap
  • Your own naming convention as a per-repository setting, instead of the built-in <kind>_<identifier> table
← Previous storyRepository scanner