Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion providers/msdns/msdnsProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func init() {
func newDNS(config map[string]string, metadata json.RawMessage) (providers.DNSServiceProvider, error) {
if runtime.GOOS != "windows" {
printer.Println("INFO: MSDNS deactivated. Required OS not detected.")
return providers.None{}, nil
return &msdnsProvider{}, nil
}

var err error
Expand Down
20 changes: 20 additions & 0 deletions providers/none/api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package none

/*

A front-end to the SDK.

Use the Facade Pattern to create a simplified interface to the SDK.

This isn't needed if the SDK offers the functions you want. Feel free to delete this file.

Rate-limiting and re-try logic should be here. This is the module that should
implement re-trying if the provider replies with a 429 or other "you're going
too fast" or "temporary error, please re-try later) errors.

Pagination logic. This is the module that should implement any any pagination
logic. The vendor's SDK might return data in pages (typically each reply
includes the next 100 records and you must request additional "pages" of
records. This file is typically where logic to get all pages is implemented.

*/
19 changes: 19 additions & 0 deletions providers/none/convert.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package none

// toRc converts a native record (what is received from the API) to a RecordConfig.
//func toRc(domain string, r theSdkModule.NativeRecordType) (*models.RecordConfig, error) {
//}

// toRc converts a RecordConfig to a native record (what is received from the API).
//func toNative(rc *models.RecordConfig) theSdkModule.NativeRecordType {
//}

/* Or...

If your provider stores all records at the same label (or label+type) in one type (often called a RecordSet).

func toRcs(n theSdkModule.NativeRecordSet, origin string) (rcs []*models.RecordConfig, err error) {}

func toNative(rcs []*models.RecordConfig, origin string) []theSdkModule.NativeRecordSet {}

*/
3 changes: 3 additions & 0 deletions providers/none/convert_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package none

/* add test cases here */
52 changes: 52 additions & 0 deletions providers/none/dnsprovider.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package none

import (
"github.com/StackExchange/dnscontrol/v4/models"
)

// GetZoneRecordsCorrections gets the records of a zone and returns them in RecordConfig format.
func (n None) GetZoneRecordsCorrections(dc *models.DomainConfig, records models.Records) ([]*models.Correction, int, error) {

/*
// if your provider does updates one record at a time...
changes, err := diff2.ByRecord(existing, dc, nil)

// if your provider does updates on all the records at a set (label+type) at once...
changes, err := diff2.ByRecordSet(existing, dc, nil)

// if your provider does updates on all the records at a label at once...
changes, err := diff2.ByLabel(existing, dc, nil)

if err != nil {
return nil, err
}

var corrections []*models.Correction

for _, change := range changes {
switch change.Type {
case diff2.REPORT:
corr = change.CreateMessage()
case diff2.CREATE:
corr = change.CreateCorrection(func() error { return c.createRecord(FILL_IN) })
case diff2.CHANGE:
corr = change.CreateCorrection(func() error { return c.modifyRecord(FILL_IN) })
case diff2.DELETE:
corr = change.CreateCorrection(func() error { return c.deleteRecord(FILL_IN) })
default:
panic("unhandled change.TYPE %s", change.Type)
}

corrections = append(corrections, corr)
}

return corrections, nil
*/

return nil, 0, nil
}

//// GetDomainCorrections returns corrections to update a domain.
//func (n None) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Correction, error) {
//return nil, nil
//}
29 changes: 29 additions & 0 deletions providers/none/noneProvider.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package none

import "github.com/StackExchange/dnscontrol/v4/providers"

/*
Provider: None

None is a basic provider type that does absolutely nothing. Can be useful as a placeholder for third parties or unimplemented providers.

*/

// None is the struct that is used to hold state for the provider.
//
// This same struct is used for all domains that use this provider. Thus
// per-domain data should be stored as a map[domain]thing and be protected by
// mutexes.
type None struct{}

var featuresNone = providers.DocumentationNotes{
// The default for unlisted capabilities is 'Cannot'.
// See providers/capabilities.go for the entire list of capabilities.
providers.CanConcur: providers.Can(),
}

func init() {
providers.RegisterRegistrarType("NONE", func(map[string]string) (providers.Registrar, error) {
return None{}, nil
}, featuresNone)
}
8 changes: 8 additions & 0 deletions providers/none/protocol.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package none

/* This implements the low-level protocol used for speaking to the API.
You can delete this file if it isn't needed.

For example if Go didn't include native support for HTTP+REST, we'd implement it here.

*/
15 changes: 15 additions & 0 deletions providers/none/registrar.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package none

import "github.com/StackExchange/dnscontrol/v4/models"

// This file completes the "Registrar" interface.

// GetNameservers returns the current nameservers for a domain.
func (n None) GetNameservers(string) ([]*models.Nameserver, error) {
return nil, nil
}

// GetRegistrarCorrections returns corrections to update registrars.
func (n None) GetRegistrarCorrections(dc *models.DomainConfig) ([]*models.Correction, error) {
return nil, nil
}
7 changes: 7 additions & 0 deletions providers/none/zonecreator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package none

// EnsureZoneExists ensures that the zone exists on the DNS server. It will create it if it does not.
// This is a no-op for the None provider; it pretends that all zones already exist.
func (n None) EnsureZoneExists(domain string) error {
return nil
}
7 changes: 7 additions & 0 deletions providers/none/zonelister.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package none

// ListZones returns a list of zones that the None provider manages.
// Since the None provider does not manage any zones, it returns an empty list.
func (n None) ListZones() ([]string, error) {
return nil, nil
}
40 changes: 0 additions & 40 deletions providers/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,46 +153,6 @@ func AuditRecords(dType string, rcs models.Records) []error {
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.
type None struct{}

// GetRegistrarCorrections returns corrections to update registrars.
func (n None) GetRegistrarCorrections(dc *models.DomainConfig) ([]*models.Correction, error) {
return nil, nil
}

// GetNameservers returns the current nameservers for a domain.
func (n None) GetNameservers(string) ([]*models.Nameserver, error) {
return nil, nil
}

// GetZoneRecords gets the records of a zone and returns them in RecordConfig format.
func (n None) GetZoneRecords(domain string, meta map[string]string) (models.Records, error) {
return nil, nil
}

// GetZoneRecordsCorrections gets the records of a zone and returns them in RecordConfig format.
func (n None) GetZoneRecordsCorrections(dc *models.DomainConfig, records models.Records) ([]*models.Correction, int, error) {
return nil, 0, nil
}

// GetDomainCorrections returns corrections to update a domain.
func (n None) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Correction, error) {
return nil, nil
}

var featuresNone = DocumentationNotes{
// The default for unlisted capabilities is 'Cannot'.
// See providers/capabilities.go for the entire list of capabilities.
CanConcur: Can(),
}

func init() {
RegisterRegistrarType("NONE", func(map[string]string) (Registrar, error) {
return None{}, nil
}, featuresNone)
}

// CustomRType stores an rtype that is only valid for this DSP.
type CustomRType struct {
Name string
Expand Down
Loading