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 ( import (
"bytes"
"encoding/json" "encoding/json"
"flag" "flag"
"fmt" "fmt"
@ -200,30 +201,32 @@ func (c *Bind) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Correcti
differ := diff.New(dc) differ := diff.New(dc)
_, create, del, mod := differ.IncrementalDiff(foundRecords) _, create, del, mod := differ.IncrementalDiff(foundRecords)
buf := &bytes.Buffer{}
// Print a list of changes. Generate an actual change that is the zone // Print a list of changes. Generate an actual change that is the zone
changes := false changes := false
for _, i := range create { for _, i := range create {
changes = true changes = true
if zone_file_found { if zone_file_found {
fmt.Println(i) fmt.Fprintln(buf, i)
} }
} }
for _, i := range del { for _, i := range del {
changes = true changes = true
if zone_file_found { if zone_file_found {
fmt.Println(i) fmt.Fprintln(buf, i)
} }
} }
for _, i := range mod { for _, i := range mod {
changes = true changes = true
if zone_file_found { 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 { 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{} corrections := []*models.Correction{}
if changes { if changes {
corrections = append(corrections, corrections = append(corrections,