1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00
* fix linting
* rename AuditRecordsor to RecordAuditor
* gandi_v5 to gandiv5
This commit is contained in:
Tom Limoncelli
2021-03-08 20:14:30 -05:00
committed by GitHub
parent c883c1ac68
commit e69e6f27e4
36 changed files with 49 additions and 47 deletions

View File

@ -21,6 +21,7 @@ var _ = cmd(catUtils, func() *cli.Command {
}
}())
// FmtArgs stores arguments related to the fmt subcommand.
type FmtArgs struct {
InputFile string
OutputFile string
@ -44,6 +45,7 @@ func (args *FmtArgs) flags() []cli.Flag {
return flags
}
// FmtFile reads and formats a file.
func FmtFile(args FmtArgs) error {
fileBytes, readErr := ioutil.ReadFile(args.InputFile)
if readErr != nil {
@ -62,14 +64,13 @@ func FmtFile(args FmtArgs) error {
beautified = beautified + "\n"
}
if args.OutputFile != "" {
if args.OutputFile == "" {
fmt.Print(beautified)
} else {
if err := ioutil.WriteFile(args.OutputFile, []byte(beautified), 0744); err != nil {
return err
} else {
fmt.Fprintf(os.Stderr, "File %s successfully written\n", args.OutputFile)
}
} else {
fmt.Print(beautified)
fmt.Fprintf(os.Stderr, "File %s successfully written\n", args.OutputFile)
}
return nil
}

View File

@ -15,7 +15,7 @@ import (
_ "github.com/StackExchange/dnscontrol/v3/providers/dnsimple"
_ "github.com/StackExchange/dnscontrol/v3/providers/doh"
_ "github.com/StackExchange/dnscontrol/v3/providers/exoscale"
_ "github.com/StackExchange/dnscontrol/v3/providers/gandi_v5"
_ "github.com/StackExchange/dnscontrol/v3/providers/gandiv5"
_ "github.com/StackExchange/dnscontrol/v3/providers/gcloud"
_ "github.com/StackExchange/dnscontrol/v3/providers/hedns"
_ "github.com/StackExchange/dnscontrol/v3/providers/hetzner"

View File

@ -32,7 +32,7 @@ var features = providers.DocumentationNotes{
func init() {
fns := providers.DspFuncs{
Initializer: newDNS,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("ACTIVEDIRECTORY_PS", fns, features)
}

View File

@ -119,7 +119,7 @@ func initAxfrDdns(config map[string]string, providermeta json.RawMessage) (provi
func init() {
fns := providers.DspFuncs{
Initializer: initAxfrDdns,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("AXFRDDNS", fns, features)
}

View File

@ -70,7 +70,7 @@ var features = providers.DocumentationNotes{
func init() {
fns := providers.DspFuncs{
Initializer: newAzureDNSDsp,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("AZURE_DNS", fns, features)
providers.RegisterCustomRecordType("AZURE_ALIAS", "AZURE_DNS", "")

View File

@ -79,7 +79,7 @@ func initBind(config map[string]string, providermeta json.RawMessage) (providers
func init() {
fns := providers.DspFuncs{
Initializer: initBind,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("BIND", fns, features)
}

View File

@ -55,7 +55,7 @@ var features = providers.DocumentationNotes{
func init() {
fns := providers.DspFuncs{
Initializer: newCloudflare,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("CLOUDFLAREAPI", fns, features)
providers.RegisterCustomRecordType("CF_REDIRECT", "CLOUDFLAREAPI", "")

View File

@ -56,7 +56,7 @@ var features = providers.DocumentationNotes{
func init() {
fns := providers.DspFuncs{
Initializer: NewCloudns,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("CLOUDNS", fns, features)
}

View File

@ -58,7 +58,7 @@ var defaultNameServerNames = []string{
func init() {
fns := providers.DspFuncs{
Initializer: NewDeSec,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("DESEC", fns, features)
}

View File

@ -82,7 +82,7 @@ var features = providers.DocumentationNotes{
func init() {
fns := providers.DspFuncs{
Initializer: NewDo,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("DIGITALOCEAN", fns, features)
}

View File

@ -37,7 +37,7 @@ func init() {
providers.RegisterRegistrarType("DNSIMPLE", newReg)
fns := providers.DspFuncs{
Initializer: newDsp,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("DNSIMPLE", fns, features)
}

View File

@ -39,7 +39,7 @@ var features = providers.DocumentationNotes{
func init() {
fns := providers.DspFuncs{
Initializer: NewExoscale,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("EXOSCALE", fns, features)
}

View File

@ -1,4 +1,4 @@
package gandi_v5
package gandiv5
import (
"github.com/StackExchange/dnscontrol/v3/models"

View File

@ -1,4 +1,4 @@
package gandi_v5
package gandiv5
// Convert the provider's native record description to models.RecordConfig.

View File

@ -1,4 +1,4 @@
package gandi_v5
package gandiv5
import (
"testing"

View File

@ -1,4 +1,4 @@
package gandi_v5
package gandiv5
/*
@ -36,8 +36,8 @@ import (
// init registers the provider to dnscontrol.
func init() {
fns := providers.DspFuncs{
Initializer: newDsp,
AuditRecordsor: AuditRecords,
Initializer: newDsp,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("GANDI_V5", fns, features)
providers.RegisterRegistrarType("GANDI_V5", newReg)

View File

@ -39,7 +39,7 @@ func sPtr(s string) *string {
func init() {
fns := providers.DspFuncs{
Initializer: New,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("GCLOUD", fns, features)
}

View File

@ -62,7 +62,7 @@ var features = providers.DocumentationNotes{
func init() {
fns := providers.DspFuncs{
Initializer: newHEDNSProvider,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("HEDNS", fns, features)
}

View File

@ -28,7 +28,7 @@ var features = providers.DocumentationNotes{
func init() {
fns := providers.DspFuncs{
Initializer: New,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("HETZNER", fns, features)
}

View File

@ -68,7 +68,7 @@ func newDsp(conf map[string]string, meta json.RawMessage) (providers.DNSServiceP
func init() {
fns := providers.DspFuncs{
Initializer: newDsp,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterRegistrarType("HEXONET", newReg)
providers.RegisterDomainServiceProviderType("HEXONET", fns, features)

View File

@ -35,7 +35,7 @@ func init() {
providers.RegisterRegistrarType("HOSTINGDE", newHostingdeReg)
fns := providers.DspFuncs{
Initializer: newHostingdeDsp,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("HOSTINGDE", fns, features)
}

View File

@ -70,7 +70,7 @@ func init() {
providers.RegisterRegistrarType("INWX", newInwxReg)
fns := providers.DspFuncs{
Initializer: newInwxDsp,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("INWX", fns, features)
}

View File

@ -95,7 +95,7 @@ func init() {
// SRV support is in this provider, but Linode doesn't seem to support it properly
fns := providers.DspFuncs{
Initializer: NewLinode,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("LINODE", fns, features)
}

View File

@ -35,7 +35,7 @@ var features = providers.DocumentationNotes{
func init() {
fns := providers.DspFuncs{
Initializer: newDNS,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("MSDNS", fns, features)
}

View File

@ -43,7 +43,7 @@ func init() {
providers.RegisterRegistrarType("NAMECHEAP", newReg)
fns := providers.DspFuncs{
Initializer: newDsp,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("NAMECHEAP", fns, features)
providers.RegisterCustomRecordType("URL", "NAMECHEAP", "")

View File

@ -57,7 +57,7 @@ func init() {
providers.RegisterRegistrarType("NAMEDOTCOM", newReg)
fns := providers.DspFuncs{
Initializer: newDsp,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("NAMEDOTCOM", fns, features)
}

View File

@ -23,7 +23,7 @@ var features = providers.DocumentationNotes{
func init() {
fns := providers.DspFuncs{
Initializer: New,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("NETCUP", fns, features)
}

View File

@ -26,7 +26,7 @@ var docNotes = providers.DocumentationNotes{
func init() {
fns := providers.DspFuncs{
Initializer: newProvider,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("NS1", fns, providers.CanUseSRV, docNotes)
providers.RegisterCustomRecordType("NS1_URLFWD", "NS1", "URLFWD")

View File

@ -65,7 +65,7 @@ func initProvider(config map[string]string, providermeta json.RawMessage) (provi
func init() {
fns := providers.DspFuncs{
Initializer: initProvider,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("OCTODNS", fns, features)
}

View File

@ -37,7 +37,7 @@ var features = providers.DocumentationNotes{
func init() {
fns := providers.DspFuncs{
Initializer: New,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("ORACLE", fns, features)
}

View File

@ -57,7 +57,7 @@ func newReg(conf map[string]string) (providers.Registrar, error) {
func init() {
fns := providers.DspFuncs{
Initializer: newDsp,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterRegistrarType("OVH", newReg)
providers.RegisterDomainServiceProviderType("OVH", fns, features)

View File

@ -34,7 +34,7 @@ var features = providers.DocumentationNotes{
func init() {
fns := providers.DspFuncs{
Initializer: NewProvider,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("POWERDNS", fns, features)
}

View File

@ -40,15 +40,15 @@ var RegistrarTypes = map[string]RegistrarInitializer{}
// DspInitializer is a function to create a DNS service provider. Function will be passed the unprocessed json payload from the configuration file for the given provider.
type DspInitializer func(map[string]string, json.RawMessage) (DNSServiceProvider, error)
// AuditRecordsor is a function that verifies that all the records
// RecordAuditor is a function that verifies that all the records
// are supportable by this provider. It returns an error related to
// the first record that this provider can not support.
type AuditRecordsor func([]*models.RecordConfig) error
type RecordAuditor func([]*models.RecordConfig) error
// DspFuncs lists functions registered with a provider.
type DspFuncs struct {
Initializer DspInitializer
AuditRecordsor AuditRecordsor
RecordAuditor RecordAuditor
}
// DNSProviderTypes stores initializer for each DSP.
@ -90,15 +90,16 @@ func CreateDNSProvider(dType string, config map[string]string, meta json.RawMess
return p.Initializer(config, meta)
}
// AuditRecords calls the RecordAudit function for a provider.
func AuditRecords(dType string, rcs models.Records) error {
p, ok := DNSProviderTypes[dType]
if !ok {
return fmt.Errorf("DSP type %s not declared", dType)
}
if p.AuditRecordsor == nil {
return fmt.Errorf("DSP type %s has no AuditRecordsor", dType)
if p.RecordAuditor == nil {
return fmt.Errorf("DSP type %s has no RecordAuditor", dType)
}
return p.AuditRecordsor(rcs)
return p.RecordAuditor(rcs)
}
// None is a basic provider type that does absolutely nothing. Can be useful as a placeholder for third parties or unimplemented providers.

View File

@ -81,7 +81,7 @@ var features = providers.DocumentationNotes{
func init() {
fns := providers.DspFuncs{
Initializer: newRoute53Dsp,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("ROUTE53", fns, features)
providers.RegisterRegistrarType("ROUTE53", newRoute53Reg)

View File

@ -29,7 +29,7 @@ var features = providers.DocumentationNotes{
func init() {
fns := providers.DspFuncs{
Initializer: newReg,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("SOFTLAYER", fns, features)
}

View File

@ -39,7 +39,7 @@ var features = providers.DocumentationNotes{
func init() {
fns := providers.DspFuncs{
Initializer: NewProvider,
AuditRecordsor: AuditRecords,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("VULTR", fns, features)
}