mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-09-07 13:44:18 +08:00
fix names for internal transformed records (#358)
* fix names for internal transformed records * activedirectory use standard messaged * add test for fqdn consistency in final validation pass
This commit is contained in:
parent
2e8c4a758f
commit
17e64ca28d
3 changed files with 20 additions and 13 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -17,3 +17,4 @@ certs/
|
|||
spfcache*
|
||||
adzonedump.*
|
||||
zones/
|
||||
stack.sh
|
|
@ -1,6 +1,7 @@
|
|||
package normalize
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
|
@ -195,7 +196,7 @@ func importTransform(srcDomain, dstDomain *models.DomainConfig, transforms []tra
|
|||
newRec := func() *models.RecordConfig {
|
||||
rec2, _ := rec.Copy()
|
||||
newlabel := rec2.GetLabelFQDN()
|
||||
rec2.SetLabelFromFQDN(newlabel, dstDomain.Name)
|
||||
rec2.SetLabel(newlabel, dstDomain.Name)
|
||||
if ttl != 0 {
|
||||
rec2.TTL = ttl
|
||||
}
|
||||
|
@ -357,17 +358,20 @@ func NormalizeAndValidateConfig(config *models.DNSConfig) (errs []error) {
|
|||
}
|
||||
}
|
||||
|
||||
for _, d := range config.Domains {
|
||||
// Check that CNAMES don't have to co-exist with any other records
|
||||
for _, d := range config.Domains {
|
||||
errs = append(errs, checkCNAMEs(d)...)
|
||||
}
|
||||
|
||||
// Check that if any aliases / ptr / etc.. are used in a domain, every provider for that domain supports them
|
||||
for _, d := range config.Domains {
|
||||
// Check that if any advanced record types are used in a domain, every provider for that domain supports them
|
||||
err := checkProviderCapabilities(d)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
// Validate FQDN consistency
|
||||
for _, r := range d.Records {
|
||||
if r.NameFQDN == "" || !strings.HasSuffix(r.NameFQDN, d.Name) {
|
||||
errs = append(errs, fmt.Errorf("Record named '%s' does not have correct FQDN in domain '%s'. FQDN: %s", r.Name, d.Name, r.NameFQDN))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return errs
|
||||
|
|
|
@ -58,10 +58,10 @@ func (c *adProvider) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Co
|
|||
// Generate changes.
|
||||
corrections := []*models.Correction{}
|
||||
for _, del := range dels {
|
||||
corrections = append(corrections, c.deleteRec(dc.Name, del.Existing))
|
||||
corrections = append(corrections, c.deleteRec(dc.Name, del))
|
||||
}
|
||||
for _, cre := range creates {
|
||||
corrections = append(corrections, c.createRec(dc.Name, cre.Desired)...)
|
||||
corrections = append(corrections, c.createRec(dc.Name, cre)...)
|
||||
}
|
||||
for _, m := range modifications {
|
||||
corrections = append(corrections, c.modifyRec(dc.Name, m))
|
||||
|
@ -280,10 +280,11 @@ func (c *adProvider) generatePowerShellDelete(domainname, recName, recType, cont
|
|||
return fmt.Sprintf(text, c.adServer, domainname, recName, recType, content)
|
||||
}
|
||||
|
||||
func (c *adProvider) createRec(domainname string, rec *models.RecordConfig) []*models.Correction {
|
||||
func (c *adProvider) createRec(domainname string, cre diff.Correlation) []*models.Correction {
|
||||
rec := cre.Desired
|
||||
arr := []*models.Correction{
|
||||
{
|
||||
Msg: fmt.Sprintf("CREATE record: %s %s ttl(%d) %s", rec.GetLabel(), rec.Type, rec.TTL, rec.GetTargetField()),
|
||||
Msg: cre.String(),
|
||||
F: func() error {
|
||||
return c.powerShellDoCommand(c.generatePowerShellCreate(domainname, rec), true)
|
||||
}},
|
||||
|
@ -301,9 +302,10 @@ func (c *adProvider) modifyRec(domainname string, m diff.Correlation) *models.Co
|
|||
}
|
||||
}
|
||||
|
||||
func (c *adProvider) deleteRec(domainname string, rec *models.RecordConfig) *models.Correction {
|
||||
func (c *adProvider) deleteRec(domainname string, cor diff.Correlation) *models.Correction {
|
||||
rec := cor.Existing
|
||||
return &models.Correction{
|
||||
Msg: fmt.Sprintf("DELETE record: %s %s ttl(%d) %s", rec.GetLabel(), rec.Type, rec.TTL, rec.GetTargetField()),
|
||||
Msg: cor.String(),
|
||||
F: func() error {
|
||||
return c.powerShellDoCommand(c.generatePowerShellDelete(domainname, rec.GetLabel(), rec.Type, rec.GetTargetField()), true)
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue