fluxcd-flux2/cmd
SAY-5 e8d8562b9e cmd/flux: search for kind within the YAML document instead of line+1
detectFileUpgrades hard-coded the kind: lookup at apiVersion line+1,
so manifests with any other field (metadata:, comments, annotations)
or reversed field order silently returned "no migration needed" even
when apiVersion was deprecated (#5839).

Search within the current YAML document boundaries: scan backwards
to the previous '---' separator or start-of-file, then forwards to
the next '---' separator. First kind: line wins. The order is
backwards-then-forwards so that for a conventional apiVersion/kind
ordering we only scan the single line + the document boundary; the
forward fallback covers the reversed-order case.

Adds a regression fixture with three documents covering:
  - apiVersion first, kind after metadata:
  - kind first, apiVersion after metadata:
  - kind first, apiVersion last

Fixes #5839

Signed-off-by: SAY-5 <SAY-5@users.noreply.github.com>
2026-04-21 17:06:51 -07:00
..
flux cmd/flux: search for kind within the YAML document instead of line+1 2026-04-21 17:06:51 -07:00