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

Switch to Go 1.13 error wrapping (#604)

* Replaced errors.Wrap with fmt.Errorf (#589)

* Find:    errors\.Wrap\(([^,]+),\s+(["`][^"`]*)(["`])\)
  Replace: fmt.Errorf($2: %w$3, $1)

* Replaced errors.Wrapf with fmt.Errorf (#589)

* Find:    errors\.Wrapf\(([^,]+),\s+(["`][^"`]*)(["`])\)
  Replace: fmt.Errorf($2: %w$3, $1)
* Find:    errors\.Wrapf\(([^,]+),\s+(["`][^"`]*)(["`])(,[^)]+)\)
* Replace: fmt.Errorf($2: %w$3$4, $1)

* Replaced errors.Errorf with fmt.Errorf (#589)

* Find:    errors\.Errorf
  Replace: fmt.Errorf

* Cleaned up remaining imports

* Cleanup

* Regenerate provider support matrix

This was broken by #533 ... and it's now the third time this has been missed.
This commit is contained in:
Patrick Gaskin
2020-01-28 11:06:56 -05:00
committed by Tom Limoncelli
parent cae35a2c8f
commit 825ba2d081
64 changed files with 328 additions and 379 deletions

View File

@ -7,10 +7,10 @@ import (
"sort"
"strings"
"github.com/urfave/cli"
"github.com/StackExchange/dnscontrol/v2/models"
"github.com/StackExchange/dnscontrol/v2/pkg/printer"
"github.com/pkg/errors"
"github.com/urfave/cli"
)
// categories of commands
@ -125,7 +125,7 @@ func preloadProviders(cfg *models.DNSConfig, err error) (*models.DNSConfig, erro
for _, d := range cfg.Domains {
reg, ok := cfg.RegistrarsByName[d.RegistrarName]
if !ok {
return nil, errors.Errorf("Registrar named %s expected for %s, but never registered", d.RegistrarName, d.Name)
return nil, fmt.Errorf("Registrar named %s expected for %s, but never registered", d.RegistrarName, d.Name)
}
d.RegistrarInstance = &models.RegistrarInstance{
ProviderBase: models.ProviderBase{
@ -136,7 +136,7 @@ func preloadProviders(cfg *models.DNSConfig, err error) (*models.DNSConfig, erro
for pName, n := range d.DNSProviderNames {
prov, ok := cfg.DNSProvidersByName[pName]
if !ok {
return nil, errors.Errorf("DNS Provider named %s expected for %s, but never registered", pName, d.Name)
return nil, fmt.Errorf("DNS Provider named %s expected for %s, but never registered", pName, d.Name)
}
d.DNSProviderInstances = append(d.DNSProviderInstances, &models.DNSProviderInstance{
ProviderBase: models.ProviderBase{

View File

@ -5,6 +5,8 @@ import (
"log"
"os"
"github.com/urfave/cli"
"github.com/StackExchange/dnscontrol/v2/models"
"github.com/StackExchange/dnscontrol/v2/pkg/nameservers"
"github.com/StackExchange/dnscontrol/v2/pkg/normalize"
@ -12,8 +14,6 @@ import (
"github.com/StackExchange/dnscontrol/v2/pkg/printer"
"github.com/StackExchange/dnscontrol/v2/providers"
"github.com/StackExchange/dnscontrol/v2/providers/config"
"github.com/pkg/errors"
"github.com/urfave/cli"
)
var _ = cmd(catMain, func() *cli.Command {
@ -101,7 +101,7 @@ func run(args PreviewArgs, push bool, interactive bool, out printer.CLI) error {
}
errs := normalize.NormalizeAndValidateConfig(cfg)
if PrintValidationErrors(errs) {
return errors.Errorf("Exiting due to validation errors")
return fmt.Errorf("Exiting due to validation errors")
}
// TODO:
notifier, err := InitializeProviders(args.CredsFile, cfg, args.Notify)
@ -169,10 +169,10 @@ DomainLoop:
notifier.Done()
out.Printf("Done. %d corrections.\n", totalCorrections)
if anyErrors {
return errors.Errorf("Completed with errors")
return fmt.Errorf("Completed with errors")
}
if totalCorrections != 0 && args.WarnChanges {
return errors.Errorf("There are pending changes")
return fmt.Errorf("There are pending changes")
}
return nil
}

View File

@ -5,11 +5,11 @@ import (
"fmt"
"os"
"github.com/urfave/cli"
"github.com/StackExchange/dnscontrol/v2/models"
"github.com/StackExchange/dnscontrol/v2/pkg/js"
"github.com/StackExchange/dnscontrol/v2/pkg/normalize"
"github.com/pkg/errors"
"github.com/urfave/cli"
)
var _ = cmd(catDebug, func() *cli.Command {
@ -72,7 +72,7 @@ func PrintIR(args PrintIRArgs) error {
if !args.Raw {
errs := normalize.NormalizeAndValidateConfig(cfg)
if PrintValidationErrors(errs) {
return errors.Errorf("Exiting due to validation errors")
return fmt.Errorf("Exiting due to validation errors")
}
}
return PrintJSON(args.PrintJSONArgs, cfg)
@ -98,12 +98,12 @@ func PrintValidationErrors(errs []error) (fatal bool) {
// ExecuteDSL executes the dnsconfig.js contents.
func ExecuteDSL(args ExecuteDSLArgs) (*models.DNSConfig, error) {
if args.JSFile == "" {
return nil, errors.Errorf("No config specified")
return nil, fmt.Errorf("No config specified")
}
dnsConfig, err := js.ExecuteJavascript(args.JSFile, args.DevMode)
if err != nil {
return nil, errors.Errorf("Executing javascript in %s: %s", args.JSFile, err)
return nil, fmt.Errorf("Executing javascript in %s: %s", args.JSFile, err)
}
return dnsConfig, nil
}