38 lines
809 B
Go

package main
import (
"bytes"
"text/template"
"gitlab.smoothnet.org/nhyatt/bind-response-policy-zone-creator/assets"
"gitlab.smoothnet.org/nhyatt/bind-response-policy-zone-creator/internal/common"
"gitlab.smoothnet.org/nhyatt/bind-response-policy-zone-creator/internal/log"
)
func buildBindResponsePolicyFile() error {
var (
output bytes.Buffer
)
outputTemplate := assets.BindRecord
t, err := template.New("response-policy-zone").Parse(string(outputTemplate))
if err != nil {
return err
}
if err := t.Execute(&output, cfg.ConfigFile.ZoneConfig); err != nil {
return err
}
bytesWritten, err := common.WriteFile(cfg.BindOutputFileName, output.Bytes())
if err != nil {
return err
}
log.Debug("file created", "file", cfg.BindOutputFileName, "bytes", bytesWritten)
return nil
}