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

Vet and Lint the entire system (#296)

* govet and golint corrections
This commit is contained in:
Tom Limoncelli
2018-01-09 12:53:16 -05:00
committed by GitHub
parent 1a91a7f536
commit b7c251190f
64 changed files with 540 additions and 433 deletions

View File

@@ -77,6 +77,7 @@ func (args *GetDNSConfigArgs) flags() []cli.Flag {
)
}
// GetDNSConfig reads the json-formatted IR file.
func GetDNSConfig(args GetDNSConfigArgs) (*models.DNSConfig, error) {
if args.JSONFile != "" {
f, err := os.Open(args.JSONFile)
@@ -145,6 +146,7 @@ func (args *PrintJSONArgs) flags() []cli.Flag {
}
}
// GetCredentialsArgs encapsulates the flags/args for sub-commands that use the creds.json file.
type GetCredentialsArgs struct {
CredsFile string
}
@@ -160,6 +162,7 @@ func (args *GetCredentialsArgs) flags() []cli.Flag {
}
}
// FilterArgs encapsulates the flags/args for sub-commands that can filter by provider or domain.
type FilterArgs struct {
Providers string
Domains string

View File

@@ -20,6 +20,7 @@ var _ = cmd(catUtils, func() *cli.Command {
}
}())
// CreateDomainsArgs args required for the create-domain subcommand.
type CreateDomainsArgs struct {
GetDNSConfigArgs
GetCredentialsArgs
@@ -31,6 +32,7 @@ func (args *CreateDomainsArgs) flags() []cli.Flag {
return flags
}
// CreateDomains contains all data/flags needed to run create-domains, independently of CLI.
func CreateDomains(args CreateDomainsArgs) error {
cfg, err := GetDNSConfig(args.GetDNSConfigArgs)
if err != nil {

View File

@@ -52,6 +52,7 @@ var _ = cmd(catMain, func() *cli.Command {
}
}())
// PushArgs contains all data/flags needed to run push, independently of CLI
type PushArgs struct {
PreviewArgs
Interactive bool
@@ -67,10 +68,12 @@ func (args *PushArgs) flags() []cli.Flag {
return flags
}
// Preview implements the preview subcommand.
func Preview(args PreviewArgs) error {
return run(args, false, false, printer.ConsolePrinter{})
}
// Push implements the push subcommand.
func Push(args PushArgs) error {
return run(args.PreviewArgs, true, args.Interactive, printer.ConsolePrinter{})
}

View File

@@ -46,6 +46,7 @@ var _ = cmd(catDebug, func() *cli.Command {
}
}())
// PrintIRArgs encapsulates the flags/arguments for the print-ir command.
type PrintIRArgs struct {
GetDNSConfigArgs
PrintJSONArgs
@@ -62,6 +63,7 @@ func (args *PrintIRArgs) flags() []cli.Flag {
return flags
}
// PrintIR implements the print-ir subcommand.
func PrintIR(args PrintIRArgs) error {
cfg, err := GetDNSConfig(args.GetDNSConfigArgs)
if err != nil {
@@ -76,6 +78,7 @@ func PrintIR(args PrintIRArgs) error {
return PrintJSON(args.PrintJSONArgs, cfg)
}
// PrintValidationErrors formats and prints the validation errors and warnings.
func PrintValidationErrors(errs []error) (fatal bool) {
if len(errs) == 0 {
return false
@@ -92,6 +95,7 @@ func PrintValidationErrors(errs []error) (fatal bool) {
return
}
// ExecuteDSL executes the dnsconfig.js contents.
func ExecuteDSL(args ExecuteDSLArgs) (*models.DNSConfig, error) {
if args.JSFile == "" {
return nil, fmt.Errorf("No config specified")
@@ -107,6 +111,7 @@ func ExecuteDSL(args ExecuteDSLArgs) (*models.DNSConfig, error) {
return dnsConfig, nil
}
// PrintJSON outputs/prettyprints the IR data.
func PrintJSON(args PrintJSONArgs, config *models.DNSConfig) (err error) {
var dat []byte
if args.Pretty {