c730cfaa45
Add flexible DNS management to Docker Watcher. By default, wildcard DNS is assumed (current behavior). When disabled, users can configure a Cloudflare DNS provider with API token and zone selection. DNS A records are automatically created/updated/deleted in sync with proxy consumers (deployed instances and standalone proxies). - Settings: wildcard_dns toggle, dns_provider, cloudflare credentials - Cloudflare client: Provider interface with EnsureRecord/DeleteRecord/ListRecords - DNS lifecycle hooks in deployer and proxy manager (best-effort) - Settings UI: DNS config section with provider picker, zone selector, test button - DNS Records page at /dns with filtering, sync status, reconciliation - Records visible in both wildcard and managed modes - Cleanup on provider change: removes old records when switching modes
2.4 KiB
2.4 KiB
Phase 1: Settings Model & API
Status: ⬜ Not Started Parent plan: PLAN.md Domain: backend
Objective
Extend the Settings model and API to support DNS provider configuration.
Tasks
- Task 1: Add new fields to
Settingsstruct ininternal/store/models.goWildcardDNS(bool, default true)DNSProvider(string, default "")CloudflareAPIToken(string, encrypted)CloudflareZoneID(string)
- Task 2: Add migration columns in
internal/store/store.gowildcard_dnsINTEGER DEFAULT 1dns_providerTEXT DEFAULT ''cloudflare_api_tokenTEXT DEFAULT ''cloudflare_zone_idTEXT DEFAULT ''
- Task 3: Update
GetSettings()andUpdateSettings()ininternal/store/settings.go- Read/write new fields
- Encrypt/decrypt
cloudflare_api_token
- Task 4: Update
GET /api/settingshandler to include new fields (mask token) - Task 5: Update
PUT /api/settingshandler to accept new fields - Task 6: Add
POST /api/settings/dns/testendpoint — validate Cloudflare token + zone - Task 7: Add
GET /api/settings/dns/zonesendpoint — list Cloudflare zones for picker - Task 8: Register new routes in
internal/api/router.go
Files to Modify/Create
internal/store/models.go— add fields to Settings structinternal/store/store.go— add migration columnsinternal/store/settings.go— update read/write queriesinternal/api/settings.go— update handlers, add new endpointsinternal/api/router.go— register new routes
Acceptance Criteria
- New settings fields are persisted and retrievable
- Cloudflare API token is encrypted at rest
- GET /api/settings returns new fields (token masked)
- PUT /api/settings accepts and stores new fields
- DNS test and zones endpoints registered (can return placeholder until Phase 2)
Notes
- Token encryption uses existing
crypto.Encrypt/Decrypt has_cloudflare_api_tokenbool in GET response (same pattern as npm_password)- DNS test/zones endpoints will make real Cloudflare API calls — Phase 2 client needed for full implementation, but can use inline HTTP calls for these two endpoints
Review Checklist
- All tasks completed
- Code follows project conventions
- No unintended side effects
- Build passes
- Tests pass (new + existing)