Skip to content

feat: add dns-sync fmt command with semantic record sorting - #66

Merged
cl8dep merged 1 commit into
mainfrom
feat/fmt-command
Jul 30, 2026
Merged

feat: add dns-sync fmt command with semantic record sorting#66
cl8dep merged 1 commit into
mainfrom
feat/fmt-command

Conversation

@cl8dep

@cl8dep cl8dep commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • New dns-sync fmt [DIR] command that reformats zone YAML files to a canonical sorted style
  • Records sorted semantically by type: NS → A → AAAA → CNAME → MX → TXT → SRV → CAA
  • Hostnames sorted alphabetically with apex ('') first
  • MX values ordered by preference ascending (tiebreak by exchange alphabetically)
  • --check flag for CI: exits 1 if any file would change, without writing
  • Sorting logic applied in ZoneYamlSerializer.Serialize, so import also produces sorted output

Test plan

  • 12 new tests covering: semantic type ordering, MX preference sorting, subdomain alphabetical order, idempotency, --check mode, nonexistent/empty directory handling, multi-file formatting
  • All 453 existing + new tests pass

Zone YAML files can now be reformatted to a canonical style with
`dns-sync fmt [DIR]`. Records are sorted semantically by type
(NS → A → AAAA → CNAME → MX → TXT → SRV → CAA), hostnames are
sorted alphabetically with apex first, and MX values are ordered
by preference ascending. Includes --check flag for CI validation.

The sorting logic lives in ZoneYamlSerializer.Serialize so imports
also produce canonically sorted output. 12 new tests cover the
command, sorting order, idempotency, and edge cases.
@cl8dep
cl8dep merged commit ff1e1ad into main Jul 30, 2026
1 check passed
@cl8dep
cl8dep deleted the feat/fmt-command branch July 30, 2026 18:03
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 87.67123% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/DnsSync/Program.cs 0.00% 5 Missing ⚠️
src/DnsSync/Commands/FmtCommand.cs 93.02% 3 Missing ⚠️
src/DnsSync/Providers/Yaml/ZoneYamlSerializer.cs 95.65% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants