mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
wip!
This commit is contained in:
@ -122,8 +122,6 @@ func (hp *hostingdeProvider) GetDomainCorrections(dc *models.DomainConfig) ([]*m
|
||||
return nil, err
|
||||
}
|
||||
|
||||
zoneChanged := false
|
||||
|
||||
// TTL must be between (inclusive) 1m and 1y (in fact, a little bit more)
|
||||
for _, r := range dc.Records {
|
||||
if r.TTL < 60 {
|
||||
@ -140,6 +138,19 @@ func (hp *hostingdeProvider) GetDomainCorrections(dc *models.DomainConfig) ([]*m
|
||||
|
||||
records := hp.APIRecordsToStandardRecordsModel(dc.Name, zone.Records)
|
||||
|
||||
return hp.GetZoneRecordsCorrections(dc, records)
|
||||
}
|
||||
|
||||
func (hp *hostingdeProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, records models.Records) ([]*models.Correction, error) {
|
||||
var err error
|
||||
|
||||
zoneChanged := false
|
||||
|
||||
zone, err := hp.getZone(dc.Name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var create, del, mod diff.Changeset
|
||||
if !diff2.EnableDiff2 {
|
||||
_, create, del, mod, err = diff.New(dc).IncrementalDiff(records)
|
||||
|
@ -237,7 +237,12 @@ func (api *inwxAPI) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Cor
|
||||
models.PostProcessRecords(foundRecords)
|
||||
txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records
|
||||
|
||||
err = checkRecords(dc.Records)
|
||||
return api.GetZoneRecordsCorrections(dc, foundRecords)
|
||||
}
|
||||
|
||||
func (api *inwxAPI) GetZoneRecordsCorrections(dc *models.DomainConfig, foundRecords models.Records) ([]*models.Correction, error) {
|
||||
|
||||
err := checkRecords(dc.Records)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -148,6 +148,10 @@ func (api *linodeProvider) GetDomainCorrections(dc *models.DomainConfig) ([]*mod
|
||||
// Normalize
|
||||
models.PostProcessRecords(existingRecords)
|
||||
|
||||
return api.GetZoneRecordsCorrections(dc, existingRecords)
|
||||
}
|
||||
|
||||
func (api *linodeProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) {
|
||||
// Linode doesn't allow selecting an arbitrary TTL, only a set of predefined values
|
||||
// We need to make sure we don't change it every time if it is as close as it's going to get
|
||||
// By experimentation, Linode always rounds up. 300 -> 300, 301 -> 3600.
|
||||
@ -156,8 +160,19 @@ func (api *linodeProvider) GetDomainCorrections(dc *models.DomainConfig) ([]*mod
|
||||
record.TTL = fixTTL(record.TTL)
|
||||
}
|
||||
|
||||
if api.domainIndex == nil {
|
||||
if err := api.fetchDomainList(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
domainID, ok := api.domainIndex[dc.Name]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("'%s' not a zone in Linode account", dc.Name)
|
||||
}
|
||||
|
||||
var corrections []*models.Correction
|
||||
var create, del, modify diff.Changeset
|
||||
var err error
|
||||
if !diff2.EnableDiff2 {
|
||||
differ := diff.New(dc)
|
||||
_, create, del, modify, err = differ.IncrementalDiff(existingRecords)
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
// GetDomainCorrections gets existing records, diffs them against existing, and returns corrections.
|
||||
func (client *msdnsProvider) GenerateDomainCorrections(dc *models.DomainConfig, foundRecords models.Records) ([]*models.Correction, error) {
|
||||
func (client *msdnsProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, foundRecords models.Records) ([]*models.Correction, error) {
|
||||
|
||||
// Normalize
|
||||
models.PostProcessRecords(foundRecords)
|
||||
|
@ -91,7 +91,7 @@ func (client *msdnsProvider) GetDomainCorrections(dc *models.DomainConfig) ([]*m
|
||||
|
||||
clean := PrepFoundRecords(existing)
|
||||
PrepDesiredRecords(dc)
|
||||
return client.GenerateDomainCorrections(dc, clean)
|
||||
return client.GetZoneRecordsCorrections(dc, clean)
|
||||
}
|
||||
|
||||
// GetZoneRecords gathers the DNS records and converts them to
|
||||
|
@ -164,6 +164,14 @@ func (n None) GetZoneRecords(domain string) (models.Records, error) {
|
||||
// a single function. For most providers this should be relatively easy.
|
||||
}
|
||||
|
||||
// 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, error) {
|
||||
return nil, fmt.Errorf("not implemented")
|
||||
// This enables the get-zones subcommand.
|
||||
// Implement this by extracting the code from GetDomainCorrections into
|
||||
// a single function. For most providers this should be relatively easy.
|
||||
}
|
||||
|
||||
// GetDomainCorrections returns corrections to update a domain.
|
||||
func (n None) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Correction, error) {
|
||||
return nil, nil
|
||||
|
Reference in New Issue
Block a user