mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
CHORE: More cleanups (#2632)
This commit is contained in:
@ -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))
|
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 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))
|
t.Errorf("testFormat mismatch (-got +want):\n%s", diff.LineDiff(g, w))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,8 @@ export AZURE_CLIENT_SECRET=BBBBBBBBB
|
|||||||
```
|
```
|
||||||
{% endcode %}
|
{% endcode %}
|
||||||
|
|
||||||
|
NOTE: The ResourceGroup is case sensitive.
|
||||||
|
|
||||||
## Metadata
|
## Metadata
|
||||||
This provider does not recognize any special metadata fields unique to Azure DNS.
|
This provider does not recognize any special metadata fields unique to Azure DNS.
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
// It is for backwards compatibility only. New providers should use pkg/diff2.
|
// It is for backwards compatibility only. New providers should use pkg/diff2.
|
||||||
//
|
//
|
||||||
// To use this simply change New() to NewCompat(). If that doesn't
|
// 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 {
|
func NewCompat(dc *models.DomainConfig, extraValues ...func(*models.RecordConfig) map[string]string) Differ {
|
||||||
if len(extraValues) != 0 {
|
if len(extraValues) != 0 {
|
||||||
panic("extraValues not supported")
|
panic("extraValues not supported")
|
||||||
|
@ -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)
|
lenWithoutTTL := len(comp)
|
||||||
compFull := comp + fmt.Sprintf(" ttl=%d", rc.TTL)
|
compFull := comp + fmt.Sprintf(" ttl=%d", rc.TTL)
|
||||||
|
|
||||||
|
@ -324,7 +324,7 @@ func TestCheckDuplicates(t *testing.T) {
|
|||||||
}
|
}
|
||||||
errs := checkDuplicates(records)
|
errs := checkDuplicates(records)
|
||||||
if len(errs) != 0 {
|
if len(errs) != 0 {
|
||||||
t.Errorf("Expect duplicate NOT found but found %q", errs)
|
t.Errorf("Expected duplicate NOT found but found %q", errs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,16 @@ import (
|
|||||||
|
|
||||||
// Keep these in alphabetical order.
|
// 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.
|
// TxtHasBackticks audits TXT records for strings that contain backticks.
|
||||||
func TxtHasBackticks(rc *models.RecordConfig) error {
|
func TxtHasBackticks(rc *models.RecordConfig) error {
|
||||||
for _, txt := range rc.TxtStrings {
|
for _, txt := range rc.TxtStrings {
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
|
||||||
|
|
||||||
"github.com/StackExchange/dnscontrol/v4/models"
|
"github.com/StackExchange/dnscontrol/v4/models"
|
||||||
"github.com/StackExchange/dnscontrol/v4/pkg/diff"
|
"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
|
// However the code doesn't seem to have such situation. All tests
|
||||||
// pass. That said, if this breaks anything, the easiest fix might
|
// pass. That said, if this breaks anything, the easiest fix might
|
||||||
// be to just remove the sort.
|
// 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
|
return corrections, nil
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,18 @@
|
|||||||
package powerdns
|
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
|
// 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("TXT", rejectif.TxtHasDoubleQuotes) // Last verified 2023-11-11
|
||||||
|
a.Add("TXT", rejectif.TxtHasBackslash) // Last verified 2023-11-11
|
||||||
|
|
||||||
|
return a.Audit(records)
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,14 @@ import (
|
|||||||
// supported, an empty list is returned.
|
// supported, an empty list is returned.
|
||||||
func AuditRecords(records []*models.RecordConfig) []error {
|
func AuditRecords(records []*models.RecordConfig) []error {
|
||||||
a := rejectif.Auditor{}
|
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.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)
|
return a.Audit(records)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user