1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

bind puts output inside correction text

This commit is contained in:
Craig Peterson
2017-03-14 14:47:40 -07:00
parent 36c7911926
commit 004d817349

View File

@ -18,6 +18,7 @@ bind -
*/
import (
"bytes"
"encoding/json"
"flag"
"fmt"
@ -200,30 +201,32 @@ func (c *Bind) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Correcti
differ := diff.New(dc)
_, create, del, mod := differ.IncrementalDiff(foundRecords)
buf := &bytes.Buffer{}
// Print a list of changes. Generate an actual change that is the zone
changes := false
for _, i := range create {
changes = true
if zone_file_found {
fmt.Println(i)
fmt.Fprintln(buf, i)
}
}
for _, i := range del {
changes = true
if zone_file_found {
fmt.Println(i)
fmt.Fprintln(buf, i)
}
}
for _, i := range mod {
changes = true
if zone_file_found {
fmt.Println(i)
fmt.Fprintln(buf, i)
}
}
msg := fmt.Sprintf("GENERATE_ZONEFILE: %s", dc.Name)
msg := fmt.Sprintf("GENERATE_ZONEFILE: %s\n", dc.Name)
if !zone_file_found {
msg = msg + fmt.Sprintf(" (%d records)", len(create))
msg = msg + fmt.Sprintf(" (%d records)\n", len(create))
}
msg += buf.String()
corrections := []*models.Correction{}
if changes {
corrections = append(corrections,