Remove the ConfigMap, RPZ and managed-directory editors the cluster objects replace

Zones, address redirects, inline rules, lists and groups are cluster objects now
(see the previous commits and deploy/MIGRATION.md), so the mechanisms that held
them are gone:

* internal/kubezones and the resolver's service-account access to a ConfigMap,
  the address-overrides read/write path and its poller, the zone-file poller and
  the Local zones editor with its /api/local-zones routes.
* localzone.Managed, the directory of console-written master files, and the
  blocklist.managed_zones key. The resolver now writes no zone data at all; its
  zone hooks only list. The shared half of that file (the record validator, the
  renderer and the round-trip check) stays as zonestate.go, because DNSZone
  rendering is built on it. Its tests are ported to RenderZone, which keeps the
  coverage of every editable record type, wildcards, relative owners, the
  SOA/NS rule and the delegation rule.
* Tests of the removed write paths: the contract test now builds its zone from a
  DNSZone, and a new test pins that every zone write route on the resolver is
  refused and changes nothing.

Standalone installs keep editing master files on disk and SIGHUP, and the
YAML-backed domain, client, upstream and settings editors, which have not moved.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
matsandClaude Sonnet 5.5 committed 2026-10-16 10:17:17 +02:00
1 parent 2f25463347
commit 467733a7f9
21 files changed
+505 -2312

No files matched your search

+1 -14
View File
@@ -72,11 +72,7 @@ type Hooks struct {
// AddDomain adds an inline rule and persists it.
AddDomain func(ctx context.Context, in DomainInput) (any, error)
// DeleteDomain removes a rule and persists the change.
DeleteDomain func(ctx context.Context, name, action, list string) error
// LocalZones lists, saves and deletes UI-managed DNS master files.
LocalZones func(ctx context.Context) ([]ZoneFile, error)
SaveLocalZone func(ctx context.Context, name, content string) error
DeleteLocalZone func(ctx context.Context, name string) error
DeleteDomain func(ctx context.Context, name, action, list string) error
AddressOverrides func(ctx context.Context) (any, error)
SaveAddressOverride func(ctx context.Context, domain, address string) error
DeleteAddressOverride func(ctx context.Context, domain string) error
@@ -135,12 +131,6 @@ type DomainInput struct {
Content string `json:"content,omitempty"`
}
// ZoneFile is a UI-managed authoritative master file.
type ZoneFile struct {
Name string `json:"name"`
Content string `json:"content"`
}
// Server is the admin HTTP server.
type Server struct {
hooks Hooks
@@ -247,9 +237,6 @@ func (s *Server) routes(cfg *config.Config) *http.ServeMux {
mux.Handle("GET "+base+"address-overrides", s.authed(s.handleAddressOverrides, false))
mux.Handle("PUT "+base+"address-overrides", s.authed(s.handleAddressOverridePut, true))
mux.Handle("DELETE "+base+"address-overrides/{domain}", s.authed(s.handleAddressOverrideDelete, true))
mux.Handle("GET "+base+"local-zones", s.authed(s.handleLocalZones, false))
mux.Handle("PUT "+base+"local-zones/{name}", s.authed(s.handleLocalZonePut, true))
mux.Handle("DELETE "+base+"local-zones/{name}", s.authed(s.handleLocalZoneDelete, true))
mux.Handle("GET "+base+"zones", s.authed(s.handleZones, false))
mux.Handle("DELETE "+base+"zones", s.authed(s.handleZoneDelete, true))
mux.Handle("POST "+base+"zones/records", s.authed(s.handleZoneRecordAdd, true))
-46
View File
@@ -253,52 +253,6 @@ func (s *Server) handleAddressOverrideDelete(w http.ResponseWriter, r *http.Requ
writeJSON(w, http.StatusOK, map[string]any{"ok": true})
}
func (s *Server) handleLocalZones(w http.ResponseWriter, r *http.Request) {
if s.hooks.LocalZones == nil {
writeError(w, http.StatusNotImplemented, "local zone editor is unavailable")
return
}
zones, err := s.hooks.LocalZones(r.Context())
if err != nil {
writeError(w, http.StatusInternalServerError, err.Error())
return
}
writeJSON(w, http.StatusOK, map[string]any{"zones": zones})
}
func (s *Server) handleLocalZonePut(w http.ResponseWriter, r *http.Request) {
if s.hooks.SaveLocalZone == nil {
writeError(w, http.StatusNotImplemented, "local zone editor is unavailable")
return
}
var in struct {
Content string `json:"content"`
}
if err := decodeJSON(r, &in); err != nil {
writeError(w, http.StatusBadRequest, "malformed request body")
return
}
name := r.PathValue("name")
if err := s.hooks.SaveLocalZone(r.Context(), name, in.Content); err != nil {
writeError(w, http.StatusBadRequest, err.Error())
return
}
writeJSON(w, http.StatusOK, map[string]any{"ok": true, "name": name})
}
func (s *Server) handleLocalZoneDelete(w http.ResponseWriter, r *http.Request) {
if s.hooks.DeleteLocalZone == nil {
writeError(w, http.StatusNotImplemented, "local zone editor is unavailable")
return
}
name := r.PathValue("name")
if err := s.hooks.DeleteLocalZone(r.Context(), name); err != nil {
writeError(w, http.StatusBadRequest, err.Error())
return
}
writeJSON(w, http.StatusOK, map[string]any{"ok": true, "name": name})
}
// handleDomainAdd adds an inline rule.
func (s *Server) handleDomainAdd(w http.ResponseWriter, r *http.Request) {
if s.hooks.AddDomain == nil {
+3 -14
View File
@@ -1,7 +1,6 @@
package api
import (
"errors"
"net/http"
"strings"
"time"
@@ -109,22 +108,12 @@ func (s *Server) handleZoneDelete(w http.ResponseWriter, r *http.Request) {
return
}
if err := s.hooks.DeleteZone(r.Context(), zone); err != nil {
writeError(w, zoneWriteStatus(err), err.Error())
writeError(w, http.StatusNotFound, err.Error())
return
}
writeJSON(w, http.StatusOK, map[string]any{"ok": true, "zone": zone})
}
// zoneWriteStatus tells a configuration problem from a missing record: a
// console that is not allowed to write zone data is a 400 with something the
// operator can fix, while a name that is not there is a 404.
func zoneWriteStatus(err error) int {
if errors.Is(err, localzone.ErrNotManaged) {
return http.StatusBadRequest
}
return http.StatusNotFound
}
// handleZoneRecordAdd adds one record to a zone.
func (s *Server) handleZoneRecordAdd(w http.ResponseWriter, r *http.Request) {
if s.hooks.AddZoneRecord == nil {
@@ -186,7 +175,7 @@ func (s *Server) handleZoneRecordDelete(w http.ResponseWriter, r *http.Request)
return
}
if err := s.hooks.DeleteZoneRecord(r.Context(), zone, name, rrtype, r.URL.Query().Get("value")); err != nil {
writeError(w, zoneWriteStatus(err), err.Error())
writeError(w, http.StatusNotFound, err.Error())
return
}
writeJSON(w, http.StatusOK, map[string]any{"ok": true, "zone": zone, "name": name, "type": rrtype})
@@ -236,7 +225,7 @@ func (s *Server) handleZoneDelegationDelete(w http.ResponseWriter, r *http.Reque
return
}
if err := s.hooks.DeleteZoneDelegation(r.Context(), zone, name); err != nil {
writeError(w, zoneWriteStatus(err), err.Error())
writeError(w, http.StatusNotFound, err.Error())
return
}
writeJSON(w, http.StatusOK, map[string]any{"ok": true, "zone": zone, "name": name})