Commit Graph
2 Commits
Author SHA1 Message Date
Aleksei Sviridkin e90736ed5f test(presets): surface diff on FormatDeprecationMessages mismatch
Address review feedback from coderabbitai on
pkg/apis/apps/presets/legacy_test.go:151.

Replace the index-by-index loop over `got` with a single t.Fatalf
that prints both slices via %#v. The previous loop iterated only
across `got`, so extra entries in `want` would slip past unreported
when `got` was shorter than `want`; t.Fatalf with full slice
representations names both sides regardless of length.

Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-05-12 03:07:48 +03:00
Aleksei SviridkinandMatthieu ROBIN 3a922f654e feat(api): warn on deprecated flat resourcesPreset values
cozystack-api now scans each app CR Create and Update for the legacy
flat resourcesPreset names (nano, micro, small, medium, large, xlarge,
2xlarge) and emits a klog warning per occurrence with the dotted JSON
path inside the spec and the suggested 1:1 instance-type replacement.

Example log line:

  Postgres/foo in tenant-x uses deprecated resourcesPreset "small" at
  spec.resourcesPreset; migrate to "t1.small" (1:1 equivalent CPU and
  memory)

Warnings are non-blocking. Legacy values still render correctly through
the cozy-lib legacy alias table; the warning helps operators discover
remaining legacy data after the platform upgrade.

The mapping table lives in pkg/apis/apps/presets/legacy.go and is the
single Go-side source of truth. The walker handles top-level, nested,
in-array, non-string and malformed-spec inputs. The wrapper warns are
emitted via a pure helper deprecationMessagesFor so the message format
is unit-testable without intercepting klog.

Co-authored-by: Matthieu ROBIN <matthieu@hidora.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-05-11 21:09:01 +03:00