Skip to content

Commit

Permalink
cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
tlimoncelli committed Oct 1, 2023
1 parent 3b5af12 commit dac3851
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 110 deletions.
97 changes: 0 additions & 97 deletions providers/azuredns/azureDnsProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,35 +276,6 @@ func (a *azurednsProvider) recordDelete(zoneName string, reckey models.RecordKey
return err
}

// func nativeToRecordType(recordType *string) (adns.RecordType, error) {
// recordTypeStripped := strings.TrimPrefix(*recordType, "Microsoft.Network/dnszones/")
// switch recordTypeStripped {
// case "A", "AZURE_ALIAS_A":
// return adns.RecordTypeA, nil
// case "AAAA", "AZURE_ALIAS_AAAA":
// return adns.RecordTypeAAAA, nil
// case "CAA":
// return adns.RecordTypeCAA, nil
// case "CNAME", "AZURE_ALIAS_CNAME":
// return adns.RecordTypeCNAME, nil
// case "MX":
// return adns.RecordTypeMX, nil
// case "NS":
// return adns.RecordTypeNS, nil
// case "PTR":
// return adns.RecordTypePTR, nil
// case "SRV":
// return adns.RecordTypeSRV, nil
// case "TXT":
// return adns.RecordTypeTXT, nil
// case "SOA":
// return adns.RecordTypeSOA, nil
// default:
// // Unimplemented type. Return adns.A as a decoy, but send an error.
// return adns.RecordTypeA, fmt.Errorf("nativeToRecordType rtype %v unimplemented", *recordType)
// }
// }

func nativeToRecordTypeDiff2(recordType *string) (adns.RecordType, error) {
recordTypeStripped := strings.TrimPrefix(*recordType, "Microsoft.Network/dnszones/")
switch recordTypeStripped {
Expand Down Expand Up @@ -483,74 +454,6 @@ func nativeToRecords(set *adns.RecordSet, origin string) []*models.RecordConfig
return results
}

// func (a *azurednsProvider) recordToNative(recordKey models.RecordKey, recordConfig []*models.RecordConfig) (*adns.RecordSet, adns.RecordType, error) {
// recordSet := &adns.RecordSet{Type: to.StringPtr(recordKey.Type), Properties: &adns.RecordSetProperties{}}
// for _, rec := range recordConfig {
// switch recordKey.Type {
// case "A":
// if recordSet.Properties.ARecords == nil {
// recordSet.Properties.ARecords = []*adns.ARecord{}
// }
// recordSet.Properties.ARecords = append(recordSet.Properties.ARecords, &adns.ARecord{IPv4Address: to.StringPtr(rec.GetTargetField())})
// case "AAAA":
// if recordSet.Properties.AaaaRecords == nil {
// recordSet.Properties.AaaaRecords = []*adns.AaaaRecord{}
// }
// recordSet.Properties.AaaaRecords = append(recordSet.Properties.AaaaRecords, &adns.AaaaRecord{IPv6Address: to.StringPtr(rec.GetTargetField())})
// case "CNAME":
// recordSet.Properties.CnameRecord = &adns.CnameRecord{Cname: to.StringPtr(rec.GetTargetField())}
// case "NS":
// if recordSet.Properties.NsRecords == nil {
// recordSet.Properties.NsRecords = []*adns.NsRecord{}
// }
// recordSet.Properties.NsRecords = append(recordSet.Properties.NsRecords, &adns.NsRecord{Nsdname: to.StringPtr(rec.GetTargetField())})
// case "PTR":
// if recordSet.Properties.PtrRecords == nil {
// recordSet.Properties.PtrRecords = []*adns.PtrRecord{}
// }
// recordSet.Properties.PtrRecords = append(recordSet.Properties.PtrRecords, &adns.PtrRecord{Ptrdname: to.StringPtr(rec.GetTargetField())})
// case "TXT":
// if recordSet.Properties.TxtRecords == nil {
// recordSet.Properties.TxtRecords = []*adns.TxtRecord{}
// }
// // Empty TXT record needs to have no value set in it's properties
// if !(len(rec.TxtStrings) == 1 && rec.TxtStrings[0] == "") {
// var txts []*string
// for _, txt := range rec.TxtStrings {
// txts = append(txts, to.StringPtr(txt))
// }
// recordSet.Properties.TxtRecords = append(recordSet.Properties.TxtRecords, &adns.TxtRecord{Value: txts})
// }
// case "MX":
// if recordSet.Properties.MxRecords == nil {
// recordSet.Properties.MxRecords = []*adns.MxRecord{}
// }
// recordSet.Properties.MxRecords = append(recordSet.Properties.MxRecords, &adns.MxRecord{Exchange: to.StringPtr(rec.GetTargetField()), Preference: to.Int32Ptr(int32(rec.MxPreference))})
// case "SRV":
// if recordSet.Properties.SrvRecords == nil {
// recordSet.Properties.SrvRecords = []*adns.SrvRecord{}
// }
// recordSet.Properties.SrvRecords = append(recordSet.Properties.SrvRecords, &adns.SrvRecord{Target: to.StringPtr(rec.GetTargetField()), Port: to.Int32Ptr(int32(rec.SrvPort)), Weight: to.Int32Ptr(int32(rec.SrvWeight)), Priority: to.Int32Ptr(int32(rec.SrvPriority))})
// case "CAA":
// if recordSet.Properties.CaaRecords == nil {
// recordSet.Properties.CaaRecords = []*adns.CaaRecord{}
// }
// recordSet.Properties.CaaRecords = append(recordSet.Properties.CaaRecords, &adns.CaaRecord{Value: to.StringPtr(rec.GetTargetField()), Tag: to.StringPtr(rec.CaaTag), Flags: to.Int32Ptr(int32(rec.CaaFlag))})
// case "AZURE_ALIAS_A", "AZURE_ALIAS_AAAA", "AZURE_ALIAS_CNAME":
// *recordSet.Type = rec.AzureAlias["type"]
// recordSet.Properties.TargetResource = &adns.SubResource{ID: to.StringPtr(rec.GetTargetField())}
// default:
// return nil, adns.RecordTypeA, fmt.Errorf("recordToNative rtype %v unimplemented", recordKey.Type) // ands.A is a placeholder
// }
// }

// rt, err := nativeToRecordType(to.StringPtr(*recordSet.Type))
// if err != nil {
// return nil, adns.RecordTypeA, err // adns.A is a placeholder
// }
// return recordSet, rt, nil
// }

// NOTE recordToNativeDiff2 is really "convert []RecordConfig to rrset".

func (a *azurednsProvider) recordToNativeDiff2(recordKey models.RecordKey, recordConfig []*models.RecordConfig) (*adns.RecordSet, adns.RecordType, error) {
Expand Down
3 changes: 2 additions & 1 deletion providers/gandiv5/gandi_v5Provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ func PrepDesiredRecords(dc *models.DomainConfig) {
}

// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (client *gandiv5Provider) GetZoneRecordsCorrections(dc *models.DomainConfig, existing models.Records) (corrections []*models.Correction, err error) {
func (client *gandiv5Provider) GetZoneRecordsCorrections(dc *models.DomainConfig, existing models.Records) ([]*models.Correction, error) {
var corrections []*models.Correction
if client.debug {
debugRecords("GenDC input", existing)
}
Expand Down
3 changes: 2 additions & 1 deletion providers/hetzner/hetznerProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ func (api *hetznerProvider) EnsureZoneExists(domain string) error {
}

// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (api *hetznerProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) (corrections []*models.Correction, err error) {
func (api *hetznerProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) {
var corrections []*models.Correction
domain := dc.Name

txtutil.SplitSingleLongTxt(dc.Records) // Autosplit long TXT records
Expand Down
3 changes: 2 additions & 1 deletion providers/hexonet/records.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ func (n *HXClient) GetZoneRecords(domain string, meta map[string]string) (models
}

// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (n *HXClient) GetZoneRecordsCorrections(dc *models.DomainConfig, actual models.Records) (corrections []*models.Correction, err error) {
func (n *HXClient) GetZoneRecordsCorrections(dc *models.DomainConfig, actual models.Records) ([]*models.Correction, error) {
var corrections []*models.Correction

txtutil.SplitSingleLongTxt(dc.Records)

Expand Down
5 changes: 3 additions & 2 deletions providers/linode/linodeProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ func (api *linodeProvider) GetZoneRecords(domain string, meta map[string]string)
}

// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (api *linodeProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) (corrections []*models.Correction, err error) {
func (api *linodeProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) {
var corrections []*models.Correction
// 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
// The documentation says that it will always round up to the next highest value: 300 -> 300, 301 -> 3600.
Expand All @@ -135,7 +136,7 @@ func (api *linodeProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, ex
}

if api.domainIndex == nil {
if err = api.fetchDomainList(); err != nil {
if err := api.fetchDomainList(); err != nil {
return nil, err
}
}
Expand Down
4 changes: 3 additions & 1 deletion providers/loopia/loopiaProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ func gatherAffectedLabels(groups map[models.RecordKey][]string) (labels map[stri
}

// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (c *APIClient) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) (corrections []*models.Correction, err error) {
func (c *APIClient) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) {
var corrections []*models.Correction

if c.Debug {
debugRecords("GenerateZoneRecordsCorrections input:\n", existingRecords)
}
Expand Down
3 changes: 2 additions & 1 deletion providers/luadns/luadnsProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ func (l *luadnsProvider) GetZoneRecords(domain string, meta map[string]string) (
}

// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (l *luadnsProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, records models.Records) (corrections []*models.Correction, err error) {
func (l *luadnsProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, records models.Records) ([]*models.Correction, error) {
var corrections []*models.Correction

checkNS(dc)

Expand Down
3 changes: 2 additions & 1 deletion providers/msdns/corrections.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import (
)

// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (client *msdnsProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, foundRecords models.Records) (corrections []*models.Correction, err error) {
func (client *msdnsProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, foundRecords models.Records) ([]*models.Correction, error) {
var corrections []*models.Correction

// Normalize
models.PostProcessRecords(foundRecords)
Expand Down
3 changes: 2 additions & 1 deletion providers/namedotcom/records.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ func (n *namedotcomProvider) GetZoneRecords(domain string, meta map[string]strin
}

// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (n *namedotcomProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, actual models.Records) (corrections []*models.Correction, err error) {
func (n *namedotcomProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, actual models.Records) ([]*models.Correction, error) {
var corrections []*models.Correction

checkNSModifications(dc)

Expand Down
4 changes: 3 additions & 1 deletion providers/netlify/netlifyProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ func (n *netlifyProvider) GetZoneRecords(domain string, meta map[string]string)
}

// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (n *netlifyProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, records models.Records) (corrections []*models.Correction, err error) {
func (n *netlifyProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, records models.Records) ([]*models.Correction, error) {
var corrections []*models.Correction

_, create, del, modify, err := diff.NewCompat(dc).IncrementalDiff(records)
if err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion providers/ns1/ns1Provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ func (n *nsone) getDomainCorrectionsDNSSEC(domain, toggleDNSSEC string) *models.
}

// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (n *nsone) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) (corrections []*models.Correction, err error) {
func (n *nsone) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) {
var corrections []*models.Correction
domain := dc.Name

// add DNSSEC-related corrections
Expand Down
4 changes: 3 additions & 1 deletion providers/packetframe/packetframeProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ func (api *packetframeProvider) GetZoneRecords(domain string, meta map[string]st
}

// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (api *packetframeProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) (corrections []*models.Correction, err error) {
func (api *packetframeProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) {
var corrections []*models.Correction

zone, err := api.getZone(dc.Name)
if err != nil {
return nil, fmt.Errorf("no such zone %q in Packetframe account", dc.Name)
Expand Down
3 changes: 2 additions & 1 deletion providers/porkbun/porkbunProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ func (c *porkbunProvider) GetNameservers(domain string) ([]*models.Nameserver, e
}

// GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records.
func (c *porkbunProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) (corrections []*models.Correction, err error) {
func (c *porkbunProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, existingRecords models.Records) ([]*models.Correction, error) {
var corrections []*models.Correction

// Block changes to NS records for base domain
checkNSModifications(dc)
Expand Down

0 comments on commit dac3851

Please sign in to comment.