Render empty forwarders for forward zones
A forward zone with no forwarders now renders "forwarders { };", which
BIND accepts and treats as disabling forwarding for the zone.
This commit is contained in:
@@ -154,9 +154,7 @@ func renderForwardZone(z bindv1alpha1.BindZone, indent string) string {
|
||||
b.WriteString(fmt.Sprintf("%szone \"%s\" {\n", indent, z.Spec.ZoneName))
|
||||
b.WriteString(indent + " type forward;\n")
|
||||
b.WriteString(indent + " forward only;\n")
|
||||
if len(z.Spec.Forwarders) > 0 {
|
||||
b.WriteString(fmt.Sprintf("%s forwarders { %s };\n", indent, terminate(z.Spec.Forwarders)))
|
||||
}
|
||||
b.WriteString(indent + " " + ForwardersClause(z.Spec.Forwarders) + ";\n")
|
||||
b.WriteString(indent + "};\n")
|
||||
return b.String()
|
||||
}
|
||||
@@ -398,6 +396,14 @@ func terminate(entries []string) string {
|
||||
return strings.Join(parts, " ")
|
||||
}
|
||||
|
||||
// ForwardersClause renders a zone forwarders clause; empty means "forwarders { }" (no forwarding).
|
||||
func ForwardersClause(entries []string) string {
|
||||
if list := terminate(entries); list != "" {
|
||||
return "forwarders { " + list + " }"
|
||||
}
|
||||
return "forwarders { }"
|
||||
}
|
||||
|
||||
func yesno(b bool) string {
|
||||
if b {
|
||||
return "yes"
|
||||
|
||||
Reference in New Issue
Block a user