config migrate: detect missing attributes within existing sections #40
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
nagonag
nagonag/ignore
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
heiko/gogogo#40
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
Extend
gogogo config migrateto detect missing attributes within existing sections, not just entirely-missing top-level sections.Today: a user with
formats:but noformats.deb.sectiongets no migration help —migrateonly flags whole-section gaps.Want:
migrateshould also surface missing leaves likeformats.deb.section,build.test.skip, etc.Shape of the change
Schema model
Replace
[]Unit{Name string}(ininternal/cmd/migrate/schema.go) with a flat list of typed paths:Source of truth: reflect over
internal/config.Config. It already has yaml tags. That makes the Go struct authoritative;default.ymlbecomes example/comment source only.Detection (
diff.go)Generalize
missingUnits→missingFields:yaml.Node, walk it once to build the set of dotted paths the user has.Field, classify:# name:line scan to# dotted.path:lines.Emission (
emit.go)Both classes go in the existing trailing
# ============block — append-only, so user formatting in existing sections stays untouched. The two cases differ only in whatextractSectionlooks up:#name:indefault.yml, emit children)build:→commands:) and emit just that subtree's example, prefixed# build.commands:as the idempotency marker.Tradeoffs
yaml.Node, which loses comments and re-flows the file — not worth it.default.ymlandconfig.Configshows up as "example not found" stubs in migrate output — useful self-test.formats.deb.depends: []written by the user is "considered" — we don't second-guess explicit choices.Decisions (resolved during planning)
extractSection: required for the path-aware variant. Trickiest piece — needs a small dedicated test fixture.Test plan
missingFieldstable-test: empty user, partial sections, full config, with and without idempotency markers.config.Configshow up as test diffs.Runtest with a user config that hasformats:but noformats.deb— expect a# formats.deb:block to be appended.Files affected
internal/cmd/migrate/schema.go— replaceUnitwithField, build via reflection overconfig.Config.internal/cmd/migrate/diff.go—missingFields, dotted-path idempotency scan.internal/cmd/migrate/emit.go— path-awareextractSection(indentation tracking).internal/cmd/migrate/migrate.go— call sites; publicRun/NeedsUpdate/CheckIdempotentAPI stays the same.internal/cmd/migrate/migrate_test.go— extend tests; add fixture for nested partial cases.AI attribution comment added per repository instruction for this open issue.\n\n(co)authored by ai:gpt-5-codex