mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-12-17 14:18:55 +08:00
HOSTINGDE: Adopt diff2 in compatibility mode (#1890)
This commit is contained in:
parent
e73982c699
commit
8c8d08b72f
2 changed files with 72 additions and 48 deletions
|
|
@ -1,10 +1,17 @@
|
||||||
package hostingde
|
package hostingde
|
||||||
|
|
||||||
import "github.com/StackExchange/dnscontrol/v3/models"
|
import (
|
||||||
|
"github.com/StackExchange/dnscontrol/v3/models"
|
||||||
|
"github.com/StackExchange/dnscontrol/v3/pkg/rejectif"
|
||||||
|
)
|
||||||
|
|
||||||
// AuditRecords returns a list of errors corresponding to the records
|
// AuditRecords returns a list of errors corresponding to the records
|
||||||
// that aren't supported by this provider. If all records are
|
// that aren't supported by this provider. If all records are
|
||||||
// supported, an empty list is returned.
|
// supported, an empty list is returned.
|
||||||
func AuditRecords(records []*models.RecordConfig) []error {
|
func AuditRecords(records []*models.RecordConfig) []error {
|
||||||
return nil
|
a := rejectif.Auditor{}
|
||||||
|
|
||||||
|
a.Add("SRV", rejectif.SrvHasNullTarget) // Last verified 2023-01-19
|
||||||
|
|
||||||
|
return a.Audit(records)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -128,11 +128,13 @@ func (hp *hostingdeProvider) GetDomainCorrections(dc *models.DomainConfig) ([]*m
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var corrections []*models.Correction
|
var create, del, mod diff.Changeset
|
||||||
if !diff2.EnableDiff2 || true { // Remove "|| true" when diff2 version arrives
|
if !diff2.EnableDiff2 {
|
||||||
|
differ = diff.New(dc)
|
||||||
differ := diff.New(dc)
|
} else {
|
||||||
_, create, del, mod, err := differ.IncrementalDiff(records)
|
differ = diff.NewCompat(dc)
|
||||||
|
}
|
||||||
|
_, create, del, mod, err = differ.IncrementalDiff(records)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -173,9 +175,24 @@ func (hp *hostingdeProvider) GetDomainCorrections(dc *models.DomainConfig) ([]*m
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
msg := []string{}
|
||||||
|
for _, c := range append(del, append(create, mod...)...) {
|
||||||
|
msg = append(msg, c.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert Future diff2 version here.
|
if len(create) == 0 && len(del) == 0 && len(mod) == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
corrections := []*models.Correction{
|
||||||
|
{
|
||||||
|
Msg: fmt.Sprintf("\n%s", strings.Join(msg, "\n")),
|
||||||
|
F: func() error {
|
||||||
|
return hp.updateRecords(dc.Name, create, del, mod)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
return corrections, nil
|
return corrections, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue