mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
gofmt (#826)
This commit is contained in:
@ -8,9 +8,9 @@ import (
|
|||||||
|
|
||||||
// DomainConfig describes a DNS domain (tecnically a DNS zone).
|
// DomainConfig describes a DNS domain (tecnically a DNS zone).
|
||||||
type DomainConfig struct {
|
type DomainConfig struct {
|
||||||
Name string `json:"name"` // NO trailing "."
|
Name string `json:"name"` // NO trailing "."
|
||||||
RegistrarName string `json:"registrar"`
|
RegistrarName string `json:"registrar"`
|
||||||
DNSProviderNames map[string]int `json:"dnsProviders"`
|
DNSProviderNames map[string]int `json:"dnsProviders"`
|
||||||
|
|
||||||
Metadata map[string]string `json:"meta,omitempty"`
|
Metadata map[string]string `json:"meta,omitempty"`
|
||||||
Records Records `json:"records"`
|
Records Records `json:"records"`
|
||||||
|
@ -47,7 +47,7 @@ type differ struct {
|
|||||||
dc *models.DomainConfig
|
dc *models.DomainConfig
|
||||||
extraValues []func(*models.RecordConfig) map[string]string
|
extraValues []func(*models.RecordConfig) map[string]string
|
||||||
|
|
||||||
compiledIgnoredNames []glob.Glob
|
compiledIgnoredNames []glob.Glob
|
||||||
compiledIgnoredTargets []glob.Glob
|
compiledIgnoredTargets []glob.Glob
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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) {
|
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
|
// from https://github.com/StackExchange/dnscontrol/issues/552
|
||||||
|
18
pkg/js/js.go
18
pkg/js/js.go
@ -120,8 +120,8 @@ func require(call otto.FunctionCall) otto.Value {
|
|||||||
|
|
||||||
func listFiles(call otto.FunctionCall) otto.Value {
|
func listFiles(call otto.FunctionCall) otto.Value {
|
||||||
// Check amount of arguments provided
|
// Check amount of arguments provided
|
||||||
if ! (len(call.ArgumentList) >= 1 && len(call.ArgumentList) <= 3) {
|
if !(len(call.ArgumentList) >= 1 && len(call.ArgumentList) <= 3) {
|
||||||
throw(call.Otto, "glob requires at least one argument: folder (string). " +
|
throw(call.Otto, "glob requires at least one argument: folder (string). "+
|
||||||
"Optional: recursive (bool) [true], fileExtension (string) [.js]")
|
"Optional: recursive (bool) [true], fileExtension (string) [.js]")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,8 +143,8 @@ func listFiles(call otto.FunctionCall) otto.Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Second: Recursive?
|
// Second: Recursive?
|
||||||
var recursive bool = true;
|
var recursive bool = true
|
||||||
if call.Argument(1).IsDefined() && ! call.Argument(1).IsNull() {
|
if call.Argument(1).IsDefined() && !call.Argument(1).IsNull() {
|
||||||
if call.Argument(1).IsBoolean() {
|
if call.Argument(1).IsBoolean() {
|
||||||
recursive, _ = call.Argument(1).ToBoolean() // If it should be recursive
|
recursive, _ = call.Argument(1).ToBoolean() // If it should be recursive
|
||||||
} else {
|
} else {
|
||||||
@ -153,11 +153,11 @@ func listFiles(call otto.FunctionCall) otto.Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Third: File extension filter.
|
// Third: File extension filter.
|
||||||
var fileExtension string = ".js";
|
var fileExtension string = ".js"
|
||||||
if call.Argument(2).IsDefined() && ! call.Argument(2).IsNull() {
|
if call.Argument(2).IsDefined() && !call.Argument(2).IsNull() {
|
||||||
if call.Argument(2).IsString() {
|
if call.Argument(2).IsString() {
|
||||||
fileExtension = call.Argument(2).String() // Which file extension to filter for.
|
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.
|
// If it doesn't start with a dot, probably user forgot it and we do it instead.
|
||||||
fileExtension = "." + fileExtension
|
fileExtension = "." + fileExtension
|
||||||
}
|
}
|
||||||
@ -169,14 +169,14 @@ func listFiles(call otto.FunctionCall) otto.Value {
|
|||||||
// Now we're doing the actual work: Listing files.
|
// 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.
|
// 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.
|
// 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
|
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 {
|
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
|
// 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),
|
// require() doesn't seem to handle well. For the sake of compatibility (and because slash looks nicer),
|
||||||
// we simply replace "\\" to "/" using filepath.ToSlash()..
|
// we simply replace "\\" to "/" using filepath.ToSlash()..
|
||||||
path = filepath.ToSlash(filepath.Clean(path)) // convert to slashes for directories
|
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
|
// 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.
|
// 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
|
// So: Why this way? Because Walk() is always recursive and otherwise would require a complete
|
||||||
|
@ -73,10 +73,10 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *azureDNSProvider) getExistingZones() (*adns.ZoneListResult, error) {
|
func (a *azureDNSProvider) getExistingZones() (*adns.ZoneListResult, error) {
|
||||||
// Please note — this function doesn't work with > 100 zones
|
// Please note — this function doesn't work with > 100 zones
|
||||||
// https://github.com/StackExchange/dnscontrol/issues/792
|
// https://github.com/StackExchange/dnscontrol/issues/792
|
||||||
// Copied this code to getZones and ListZones and modified it for using a paging
|
// Copied this code to getZones and ListZones and modified it for using a paging
|
||||||
// As a result getExistingZones is not used anymore
|
// As a result getExistingZones is not used anymore
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 6000*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 6000*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
zonesIterator, zonesErr := a.zonesClient.ListByResourceGroupComplete(ctx, *a.resourceGroup, to.Int32Ptr(100))
|
zonesIterator, zonesErr := a.zonesClient.ListByResourceGroupComplete(ctx, *a.resourceGroup, to.Int32Ptr(100))
|
||||||
@ -98,7 +98,7 @@ func (a *azureDNSProvider) getZones() error {
|
|||||||
return zonesErr
|
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() {
|
for zonesIterator.NotDone() {
|
||||||
zonesResult := zonesIterator.Response()
|
zonesResult := zonesIterator.Response()
|
||||||
for _, z := range *zonesResult.Value {
|
for _, z := range *zonesResult.Value {
|
||||||
@ -146,7 +146,7 @@ func (a *azureDNSProvider) ListZones() ([]string, error) {
|
|||||||
return nil, zonesErr
|
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() {
|
for zonesIterator.NotDone() {
|
||||||
zonesResult := zonesIterator.Response()
|
zonesResult := zonesIterator.Response()
|
||||||
for _, z := range *zonesResult.Value {
|
for _, z := range *zonesResult.Value {
|
||||||
|
Reference in New Issue
Block a user