Allow catalog-only zones without file= in --bind-conf mode

Zones without a file= property (e.g. ddns zones) are included in
catalog zone output for secondaries but skipped in domains.conf.
Previously --bind-conf required every zone to have file= set.
This commit is contained in:
2026-03-28 11:56:49 -07:00
parent 0eddb9fcfe
commit 49f7ad2987
4 changed files with 61 additions and 40 deletions

View File

@@ -23,6 +23,10 @@ func generateBindConf(entries []ZoneEntry) string {
b.WriteString("#\n")
for _, entry := range sorted {
if entry.ZoneFile == "" {
continue // catalog-only zone, no BIND config needed
}
// Strip trailing dot for BIND zone name
zoneName := strings.TrimSuffix(entry.Zone, ".")
@@ -40,22 +44,9 @@ func generateBindConf(entries []ZoneEntry) string {
return b.String()
}
// validateBindConf checks that every zone entry has a non-empty ZoneFile.
func validateBindConf(entries []ZoneEntry) error {
for _, entry := range entries {
if entry.ZoneFile == "" {
return fmt.Errorf("%s:%d: zone %s missing file= property (required for --bind-conf)",
entry.ZonesFile, entry.Line, entry.Zone)
}
}
return nil
}
// writeBindConf validates entries and writes the BIND config to path.
// writeBindConf writes the BIND config to path.
// Zones without a ZoneFile are skipped (catalog-only zones).
func writeBindConf(path string, entries []ZoneEntry) error {
if err := validateBindConf(entries); err != nil {
return err
}
content := generateBindConf(entries)
if err := os.WriteFile(path, []byte(content), 0o644); err != nil {
return fmt.Errorf("writing bind config %s: %w", path, err)