This commit is contained in:
Tom Limoncelli 2020-08-26 13:45:02 -04:00 committed by GitHub
parent 57d9cfa356
commit d6dd13820f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 21 deletions

View file

@ -8,9 +8,9 @@ import (
// DomainConfig describes a DNS domain (tecnically a DNS zone).
type DomainConfig struct {
Name string `json:"name"` // NO trailing "."
RegistrarName string `json:"registrar"`
DNSProviderNames map[string]int `json:"dnsProviders"`
Name string `json:"name"` // NO trailing "."
RegistrarName string `json:"registrar"`
DNSProviderNames map[string]int `json:"dnsProviders"`
Metadata map[string]string `json:"meta,omitempty"`
Records Records `json:"records"`

View file

@ -47,7 +47,7 @@ type differ struct {
dc *models.DomainConfig
extraValues []func(*models.RecordConfig) map[string]string
compiledIgnoredNames []glob.Glob
compiledIgnoredNames []glob.Glob
compiledIgnoredTargets []glob.Glob
}

View file

@ -298,7 +298,7 @@ func TestInvalidGlobIgnoredTarget(t *testing.T) {
}
}()
checkLengthsFull(t, existing, desired, 0, 1, 0, 0, false, nil, []*models.IgnoreTarget{{Pattern: "[.www3", Type: "CNAME"}} )
checkLengthsFull(t, existing, desired, 0, 1, 0, 0, false, nil, []*models.IgnoreTarget{{Pattern: "[.www3", Type: "CNAME"}})
}
func TestInvalidTypeIgnoredTarget(t *testing.T) {
@ -317,7 +317,7 @@ func TestInvalidTypeIgnoredTarget(t *testing.T) {
}
}()
checkLengthsFull(t, existing, desired, 0, 1, 0, 0, false, nil, []*models.IgnoreTarget{{Pattern: "1.1.1.1", Type: "A"}} )
checkLengthsFull(t, existing, desired, 0, 1, 0, 0, false, nil, []*models.IgnoreTarget{{Pattern: "1.1.1.1", Type: "A"}})
}
// from https://github.com/StackExchange/dnscontrol/issues/552

View file

@ -120,8 +120,8 @@ func require(call otto.FunctionCall) otto.Value {
func listFiles(call otto.FunctionCall) otto.Value {
// Check amount of arguments provided
if ! (len(call.ArgumentList) >= 1 && len(call.ArgumentList) <= 3) {
throw(call.Otto, "glob requires at least one argument: folder (string). " +
if !(len(call.ArgumentList) >= 1 && len(call.ArgumentList) <= 3) {
throw(call.Otto, "glob requires at least one argument: folder (string). "+
"Optional: recursive (bool) [true], fileExtension (string) [.js]")
}
@ -143,8 +143,8 @@ func listFiles(call otto.FunctionCall) otto.Value {
}
// Second: Recursive?
var recursive bool = true;
if call.Argument(1).IsDefined() && ! call.Argument(1).IsNull() {
var recursive bool = true
if call.Argument(1).IsDefined() && !call.Argument(1).IsNull() {
if call.Argument(1).IsBoolean() {
recursive, _ = call.Argument(1).ToBoolean() // If it should be recursive
} else {
@ -153,11 +153,11 @@ func listFiles(call otto.FunctionCall) otto.Value {
}
// Third: File extension filter.
var fileExtension string = ".js";
if call.Argument(2).IsDefined() && ! call.Argument(2).IsNull() {
var fileExtension string = ".js"
if call.Argument(2).IsDefined() && !call.Argument(2).IsNull() {
if call.Argument(2).IsString() {
fileExtension = call.Argument(2).String() // Which file extension to filter for.
if ! strings.HasPrefix(fileExtension, ".") {
if !strings.HasPrefix(fileExtension, ".") {
// If it doesn't start with a dot, probably user forgot it and we do it instead.
fileExtension = "." + fileExtension
}
@ -169,14 +169,14 @@ func listFiles(call otto.FunctionCall) otto.Value {
// Now we're doing the actual work: Listing files.
// Folders are ending with a slash. Can be identified later on from the user with JavaScript.
// Additionally, when more smart logic required, user can use regex in JS.
files := make([]string, 0) // init files list
files := make([]string, 0) // init files list
dirClean := filepath.Clean(dir) // let's clean it here once, instead of over-and-over again within loop
err := filepath.Walk(dir, func(path string, fi os.FileInfo, err error) error {
// quick fix to get it working on windows, as it returns paths with double-backslash, what usually
// require() doesn't seem to handle well. For the sake of compatibility (and because slash looks nicer),
// we simply replace "\\" to "/" using filepath.ToSlash()..
path = filepath.ToSlash(filepath.Clean(path)) // convert to slashes for directories
if ! recursive && fi.IsDir() {
if !recursive && fi.IsDir() {
// If recursive is disabled, it is a dir what we're processing, and the path is different
// than specified, we're apparently in a different folder. Therefore: Skip it.
// So: Why this way? Because Walk() is always recursive and otherwise would require a complete

View file

@ -73,10 +73,10 @@ func init() {
}
func (a *azureDNSProvider) getExistingZones() (*adns.ZoneListResult, error) {
// Please note — this function doesn't work with > 100 zones
// https://github.com/StackExchange/dnscontrol/issues/792
// Copied this code to getZones and ListZones and modified it for using a paging
// As a result getExistingZones is not used anymore
// Please note — this function doesn't work with > 100 zones
// https://github.com/StackExchange/dnscontrol/issues/792
// Copied this code to getZones and ListZones and modified it for using a paging
// As a result getExistingZones is not used anymore
ctx, cancel := context.WithTimeout(context.Background(), 6000*time.Second)
defer cancel()
zonesIterator, zonesErr := a.zonesClient.ListByResourceGroupComplete(ctx, *a.resourceGroup, to.Int32Ptr(100))
@ -98,7 +98,7 @@ func (a *azureDNSProvider) getZones() error {
return zonesErr
}
// Check getExistingZones and https://github.com/StackExchange/dnscontrol/issues/792 for the details
// Check getExistingZones and https://github.com/StackExchange/dnscontrol/issues/792 for the details
for zonesIterator.NotDone() {
zonesResult := zonesIterator.Response()
for _, z := range *zonesResult.Value {
@ -146,7 +146,7 @@ func (a *azureDNSProvider) ListZones() ([]string, error) {
return nil, zonesErr
}
// Check getExistingZones and https://github.com/StackExchange/dnscontrol/issues/792 for the details
// Check getExistingZones and https://github.com/StackExchange/dnscontrol/issues/792 for the details
for zonesIterator.NotDone() {
zonesResult := zonesIterator.Response()
for _, z := range *zonesResult.Value {