Add --bind-conf flag for BIND domains.conf generation

Generate a BIND-format domains.conf file alongside catalog zones.
New input properties: file= (zone data path) and dnssec (bare flag).
When --bind-conf is set, every zone must have file= or it errors.

Renames ZoneEntry.File to ZonesFile (input path for error messages)
and adds ZoneFile (BIND file path) and DNSSEC (bool) fields.
This commit is contained in:
2026-03-28 11:15:06 -07:00
parent 44d7867a0c
commit 0eddb9fcfe
9 changed files with 451 additions and 51 deletions

14
main.go
View File

@@ -12,8 +12,9 @@ import (
func main() {
configPath := flag.String("config", "", "path to YAML config (default: catz.yaml next to input file)")
outputDir := flag.String("output-dir", "", "directory for output zone files (default: same as input file)")
bindConf := flag.String("bind-conf", "", "path to write BIND domains.conf")
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: catalog-zone-gen [--config path] [--output-dir path] <input-file>\n")
fmt.Fprintf(os.Stderr, "Usage: catalog-zone-gen [--config path] [--output-dir path] [--bind-conf path] <input-file>\n")
flag.PrintDefaults()
}
flag.Parse()
@@ -39,7 +40,7 @@ func main() {
os.Exit(1)
}
members, err := parseInput(inputFile, cfg)
entries, members, err := parseInput(inputFile, cfg)
if err != nil {
fmt.Fprintf(os.Stderr, "error: %s\n", err)
os.Exit(1)
@@ -70,6 +71,15 @@ func main() {
}
}
if *bindConf != "" {
if err := writeBindConf(*bindConf, entries); err != nil {
fmt.Fprintf(os.Stderr, "error: %s\n", err)
hasErrors = true
} else {
fmt.Fprintf(os.Stderr, "%s: written\n", *bindConf)
}
}
if hasErrors {
os.Exit(1)
}