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

PERFORMANCE: Refactor auditrecords.go to loop only once #1570 (#1658)

* stash

* Use rejectif idea

* rename

* wip!

* Convert old systems to new

* fixup!

* fix typo
This commit is contained in:
Tom Limoncelli
2022-08-11 17:24:47 -04:00
committed by GitHub
parent 443b99aa59
commit 31723ad146
52 changed files with 497 additions and 569 deletions

View File

@@ -2,24 +2,20 @@ package rwth
import (
"github.com/StackExchange/dnscontrol/v3/models"
"github.com/StackExchange/dnscontrol/v3/pkg/recordaudit"
"github.com/StackExchange/dnscontrol/v3/pkg/rejectif"
)
// AuditRecords returns an error if any records are not
// supportable by this provider.
func AuditRecords(records []*models.RecordConfig) error {
// AuditRecords returns a list of errors corresponding to the records
// that aren't supported by this provider. If all records are
// supported, an empty list is returned.
func AuditRecords(records []*models.RecordConfig) []error {
a := rejectif.Auditor{}
if err := recordaudit.TxtNoMultipleStrings(records); err != nil {
return err
}
a.Add("TXT", rejectif.TxtHasMultipleSegments)
if err := recordaudit.TxtNoTrailingSpace(records); err != nil {
return err
}
a.Add("TXT", rejectif.TxtHasTrailingSpace)
if err := recordaudit.TxtNotEmpty(records); err != nil {
return err
}
a.Add("TXT", rejectif.TxtIsEmpty)
return nil
return a.Audit(records)
}