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

BIND: reset zonefile for reading records (#2407)

This commit is contained in:
Florian Ritterhoff
2023-05-31 18:14:04 +02:00
committed by GitHub
parent e6f3fb42f2
commit 23ba49e753

View File

@ -158,13 +158,19 @@ func (c *bindProvider) GetZoneRecords(domain string, meta map[string]string) (mo
if _, err := os.Stat(c.directory); os.IsNotExist(err) {
printer.Printf("\nWARNING: BIND directory %q does not exist! (will create)\n", c.directory)
}
if c.zonefile == "" {
_, okTag := meta[models.DomainTag]
_, okUnique := meta[models.DomainUniqueName]
if !okTag && !okUnique {
// This layering violation is needed for tests only.
// Otherwise, this is set already.
// Note: In this situation there is no "uniquename" or "tag".
c.zonefile = filepath.Join(c.directory,
makeFileName(c.filenameformat, domain, domain, ""))
} else {
c.zonefile = filepath.Join(c.directory,
makeFileName(c.filenameformat,
meta[models.DomainUniqueName], domain, meta[models.DomainTag]),
)
}
content, err := os.ReadFile(c.zonefile)
if os.IsNotExist(err) {