CHORE: More cleanups (#2632)

This commit is contained in:
Tom Limoncelli 2023-11-19 13:44:49 -05:00 committed by GitHub
parent 159fdf07ad
commit 3dab594757
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 38 additions and 15 deletions

View file

@ -66,13 +66,12 @@ func testFormat(t *testing.T, domain, format string) {
log.Fatal(fmt.Errorf("can't read expected %q: %w", outfile.Name(), err))
}
// // Update got -> want
// err = os.WriteFile(expectedFilename, got, 0644)
// if err != nil {
// log.Fatal(err)
// }
if w, g := string(want), string(got); w != g {
// If the test fails, output a file showing "got"
err = os.WriteFile(expectedFilename+".ACTUAL", got, 0644)
if err != nil {
log.Fatal(err)
}
t.Errorf("testFormat mismatch (-got +want):\n%s", diff.LineDiff(g, w))
}
}

View file

@ -45,6 +45,8 @@ export AZURE_CLIENT_SECRET=BBBBBBBBB
```
{% endcode %}
NOTE: The ResourceGroup is case sensitive.
## Metadata
This provider does not recognize any special metadata fields unique to Azure DNS.

View file

@ -13,7 +13,7 @@ import (
// It is for backwards compatibility only. New providers should use pkg/diff2.
//
// To use this simply change New() to NewCompat(). If that doesn't
// work please report a bug. The extraValues feature is not supported.
// work please report a bug. The extraValues parameter is not supported.
func NewCompat(dc *models.DomainConfig, extraValues ...func(*models.RecordConfig) map[string]string) Differ {
if len(extraValues) != 0 {
panic("extraValues not supported")

View file

@ -215,6 +215,7 @@ func mkCompareBlobs(rc *models.RecordConfig, f func(*models.RecordConfig) string
}
}
// We do this to save memory. This assures the first return value uses the same memory as the second.
lenWithoutTTL := len(comp)
compFull := comp + fmt.Sprintf(" ttl=%d", rc.TTL)

View file

@ -324,7 +324,7 @@ func TestCheckDuplicates(t *testing.T) {
}
errs := checkDuplicates(records)
if len(errs) != 0 {
t.Errorf("Expect duplicate NOT found but found %q", errs)
t.Errorf("Expected duplicate NOT found but found %q", errs)
}
}

View file

@ -9,6 +9,16 @@ import (
// Keep these in alphabetical order.
// TxtHasBackslash audits TXT records for strings that contains one or more backslashes.
func TxtHasBackslash(rc *models.RecordConfig) error {
for _, txt := range rc.TxtStrings {
if strings.Contains(txt, `\`) {
return fmt.Errorf("txtstring contains backslash")
}
}
return nil
}
// TxtHasBackticks audits TXT records for strings that contain backticks.
func TxtHasBackticks(rc *models.RecordConfig) error {
for _, txt := range rc.TxtStrings {

View file

@ -4,7 +4,6 @@ import (
"bytes"
"encoding/json"
"fmt"
"sort"
"github.com/StackExchange/dnscontrol/v4/models"
"github.com/StackExchange/dnscontrol/v4/pkg/diff"
@ -237,7 +236,7 @@ func (c *desecProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, exist
// However the code doesn't seem to have such situation. All tests
// pass. That said, if this breaks anything, the easiest fix might
// be to just remove the sort.
sort.Slice(corrections, func(i, j int) bool { return diff.CorrectionLess(corrections, i, j) })
//sort.Slice(corrections, func(i, j int) bool { return diff.CorrectionLess(corrections, i, j) })
return corrections, nil
}

View file

@ -1,10 +1,18 @@
package powerdns
import "github.com/StackExchange/dnscontrol/v4/models"
import (
"github.com/StackExchange/dnscontrol/v4/models"
"github.com/StackExchange/dnscontrol/v4/pkg/rejectif"
)
// 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 {
return nil
a := rejectif.Auditor{}
a.Add("TXT", rejectif.TxtHasDoubleQuotes) // Last verified 2023-11-11
a.Add("TXT", rejectif.TxtHasBackslash) // Last verified 2023-11-11
return a.Audit(records)
}

View file

@ -10,10 +10,14 @@ import (
// supported, an empty list is returned.
func AuditRecords(records []*models.RecordConfig) []error {
a := rejectif.Auditor{}
a.Add("MX", rejectif.MxNull) // Last verified 2023-01-28
a.Add("TXT", rejectif.TxtHasBackticks) // Last verified 2023-01-28
a.Add("MX", rejectif.MxNull) // Last verified 2023-01-28
a.Add("TXT", rejectif.TxtHasBackticks) // Last verified 2023-01-28
a.Add("TXT", rejectif.TxtHasTrailingSpace) // Last verified 2023-01-28
a.Add("TXT", rejectif.TxtIsEmpty) // Last verified 2023-01-28
a.Add("TXT", rejectif.TxtIsEmpty) // Last verified 2023-01-28
return a.Audit(records)
}